123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TestPhoneTrigger : MonoBehaviour
- {
- public Transform player;
- public Text text;
- /// <summary>
- /// 所有触发器
- /// </summary>
- public List<GameObject> list_box;
- /// <summary>
- /// 对应触发器显示的效果
- /// </summary>
- public List<GameObject> list_Effects;
- /// <summary>
- /// 水晶点
- /// </summary>
- public List<GameObject> list_points;
- /// <summary>
- /// 显示路径的触发器
- /// </summary>
- public List<GameObject> list_RouteBox;
- public ShowRoute showRoute;
- public Transform mapPlayer;
- public TeshMap teshMap;
- public TestP6Car testP6Car;
- public GameObject other;
- // public LineMap linMap;
- void Start()
- {
- // text.text = "Test";
-
- // linMap.CreateLineMap();
- }
- private void LateUpdate()
- {
- //if (API_SVR.GetHead() != null && transform.position != API_SVR.GetHead().transform.position)
- //{
- // transform.position = API_SVR.GetHead().transform.position;
- // mapPlayer.position = transform.position;
- // mapPlayer.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
- // //transform.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
- //}
- if (player != null && transform.position != player.position)
- {
- transform.position = player.position;
- mapPlayer.position = transform.position;
- mapPlayer.eulerAngles = player.eulerAngles;
- //transform.eulerAngles = API_SVR.GetHead().transform.eulerAngles;
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- // text.text = "Enter " + other.name;
- Debug.Log(other.name);
- QueryBox(other, true);
-
-
- }
- private void OnTriggerExit(Collider other)
- {
- QueryBox(other, false);
-
- }
- /// <summary>
- /// 查找触发器
- /// </summary>
- /// <param name="other"></param>
- /// <param name="state"></param>
- private void QueryBox( Collider other , bool state)
- {
-
- for (int i = 0; i < list_RouteBox.Count; i++)
- {
- if(list_RouteBox[i].name == other.name)
- {
- if (state)
- this.other = other.gameObject;
- else this.other = null;
- showRoute.SettingRoute(i + 1, state);
- }
- }
- for (int i = 0; i < list_box.Count; i++)
- {
- if (other.name == list_box[i].name)
- {
- // 擎天柱大模型关闭
- //if (!state && i<list_Effects.Count&& list_Effects[i].name == "P6")
- //{
- // testP6Car.CloseTestObj();
- //}
- // SetShowObject( list_Effects[i], state);
- // 博物馆四个一起打开关闭
- //if (i == list_box.Count - 1)
- //{
- // for (int j = 0; j < 4; j++)
- // {
- // SetShowObject(list_points[j], list_Effects[j], state);
- // }
- //}
- //else
- SetShowObject(list_points[i], list_Effects[i], state);
- teshMap.testMinMapShow.ShowMap(state);
- teshMap.testMaxMapShow.ShowMap(state);
-
- }
- }
-
- }
- /// <summary>
- /// 设置显示效果(触发器判定选择)
- /// </summary>
- private void SetShowObject(GameObject Obj , GameObject Effect , bool state)
- {
- Effect.SetActive(state);
- Obj.SetActive(!state);
- }
- private void SetShowObject( GameObject Effect, bool state)
- {
- Effect.SetActive(state);
-
- }
- }
|