TestPhoneTrigger.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TestPhoneTrigger : MonoBehaviour
  6. {
  7. public Transform player;
  8. public Text text;
  9. /// <summary>
  10. /// 所有触发器
  11. /// </summary>
  12. public List<GameObject> list_box;
  13. /// <summary>
  14. /// 对应触发器显示的效果
  15. /// </summary>
  16. public List<GameObject> list_Effects;
  17. /// <summary>
  18. /// 水晶点
  19. /// </summary>
  20. public List<GameObject> list_points;
  21. /// <summary>
  22. /// 显示路径的触发器
  23. /// </summary>
  24. public List<GameObject> list_RouteBox;
  25. public ShowRoute showRoute;
  26. public Transform mapPlayer;
  27. public TeshMap teshMap;
  28. public TestP6Car testP6Car;
  29. public GameObject other;
  30. // public LineMap linMap;
  31. void Start()
  32. {
  33. // text.text = "Test";
  34. // linMap.CreateLineMap();
  35. }
  36. private void LateUpdate()
  37. {
  38. //if (API_SVR.GetHead() != null && transform.position != API_SVR.GetHead().transform.position)
  39. //{
  40. // transform.position = API_SVR.GetHead().transform.position;
  41. // mapPlayer.position = transform.position;
  42. // mapPlayer.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
  43. // //transform.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
  44. //}
  45. if (player != null && transform.position != player.position)
  46. {
  47. transform.position = player.position;
  48. mapPlayer.position = transform.position;
  49. mapPlayer.eulerAngles = player.eulerAngles;
  50. //transform.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
  51. }
  52. }
  53. private void OnTriggerEnter(Collider other)
  54. {
  55. // text.text = "Enter " + other.name;
  56. Debug.Log(other.name);
  57. QueryBox(other, true);
  58. }
  59. private void OnTriggerExit(Collider other)
  60. {
  61. QueryBox(other, false);
  62. }
  63. /// <summary>
  64. /// 查找触发器
  65. /// </summary>
  66. /// <param name="other"></param>
  67. /// <param name="state"></param>
  68. private void QueryBox( Collider other , bool state)
  69. {
  70. for (int i = 0; i < list_RouteBox.Count; i++)
  71. {
  72. if(list_RouteBox[i].name == other.name)
  73. {
  74. if (state)
  75. this.other = other.gameObject;
  76. else this.other = null;
  77. showRoute.SettingRoute(i + 1, state);
  78. }
  79. }
  80. for (int i = 0; i < list_box.Count; i++)
  81. {
  82. if (other.name == list_box[i].name)
  83. {
  84. // 擎天柱大模型关闭
  85. //if (!state && i<list_Effects.Count&& list_Effects[i].name == "P6")
  86. //{
  87. // testP6Car.CloseTestObj();
  88. //}
  89. // SetShowObject( list_Effects[i], state);
  90. // 博物馆四个一起打开关闭
  91. //if (i == list_box.Count - 1)
  92. //{
  93. // for (int j = 0; j < 4; j++)
  94. // {
  95. // SetShowObject(list_points[j], list_Effects[j], state);
  96. // }
  97. //}
  98. //else
  99. SetShowObject(list_points[i], list_Effects[i], state);
  100. teshMap.testMinMapShow.ShowMap(state);
  101. teshMap.testMaxMapShow.ShowMap(state);
  102. }
  103. }
  104. }
  105. /// <summary>
  106. /// 设置显示效果(触发器判定选择)
  107. /// </summary>
  108. private void SetShowObject(GameObject Obj , GameObject Effect , bool state)
  109. {
  110. Effect.SetActive(state);
  111. Obj.SetActive(!state);
  112. }
  113. private void SetShowObject( GameObject Effect, bool state)
  114. {
  115. Effect.SetActive(state);
  116. }
  117. }