WayPointEditor.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace WildAttack
  5. {
  6. public class WayPointEditor : MonoBehaviour
  7. {
  8. private void Awake()
  9. {
  10. StartCoroutine(WayPointModule.GetInstance().LoadCSV("wayPoint.csv", () => { CreateWayPoint(); }));
  11. }
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. //CreateWayPoint();
  16. }
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. }
  21. public void CreateWayPoint()
  22. {
  23. // 读表get坐标
  24. Vector3[] ve3Arr = new Vector3[3];
  25. for (int i = 0; i < ve3Arr.Length; i++)
  26. {
  27. Vector2 ve2 = WayPointModule.GetInstance().GetDataByGroup(i + 1)[0].wayPoint[0];
  28. ve3Arr[i] = new Vector3(ve2.x, 35, ve2.y);
  29. }
  30. Dictionary<int, WayPointData> dataDic = WayPointModule.GetInstance().GetWayPointDic();
  31. for (int i = 0; i < dataDic.Count; i++)
  32. {
  33. Color color;
  34. if (dataDic[i + 1].spawnGroup == 1)
  35. {
  36. color = Color.red;
  37. }
  38. else if (dataDic[i + 1].spawnGroup == 2)
  39. {
  40. color = Color.blue;
  41. }
  42. else if (dataDic[i + 1].spawnGroup == 3)
  43. {
  44. color = Color.green;
  45. }
  46. else
  47. {
  48. color = Color.yellow;
  49. }
  50. for (int k = 0; k < dataDic[i + 1].wayPoint.Count; k++)
  51. {
  52. GameObject obj = Instantiate(Resources.Load<GameObject>("WayPoint"));
  53. obj.AddComponent<TestWay>().Init(i, k, dataDic[i + 1].wayPoint[k], color);
  54. }
  55. }
  56. // getY轴坐标
  57. //foreach (var item in wayPointObjs)
  58. //{
  59. // Ray ray = new Ray(item.transform.position, -item.transform.up);
  60. // RaycastHit hitInfo;
  61. // if (Physics.Raycast(ray, out hitInfo, 100, 1 << LayerMask.NameToLayer("Plane")))
  62. // {
  63. // if (hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("Plane"))
  64. // {
  65. // item.transform.position = new Vector3(item.transform.position.x, hitInfo.point.y, item.transform.position.z);
  66. // }
  67. // }
  68. //}
  69. }
  70. }
  71. }