123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TestTrigger : MonoBehaviour
- {
- public Text text;
- /// <summary>
- /// 所有触发器
- /// </summary>
- public List<GameObject> list_box;
- /// <summary>
- /// 对应触发器显示的效果
- /// </summary>
- public List<GameObject> list_Effects;
- /// <summary>
- /// 水晶点
- /// </summary>
- public List<GameObject> list_points;
- public Transform mapPlayer;
- public TeshMap teshMap;
- public TestP6Car testP6Car;
- public List<string> list_TriggerName;
- public Robot robot;
- private bool IsShowRobot;
- public GameObject RobotCollider;
- /// <summary>
- /// 4个区域的累计触发次数
- /// </summary>
- private int[] udpTrigger;
- void Start()
- {
- udpTrigger = new int[4];
- for (int i = 0; i < udpTrigger.Length; i++)
- {
- udpTrigger[i] = 0;
- }
- IsShowRobot = false;
- }
- 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;
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- Debug.Log(other.name);
- QueryBox(other, true);
- }
- private void OnTriggerExit(Collider other)
- {
- QueryBox(other, false);
- AudioManager.Instance.StopMusic();
- }
- /// <summary>
- /// 查找触发器
- /// </summary>
- /// <param name="other"></param>
- /// <param name="state"></param>
- private void QueryBox(Collider other, bool state)
- {
- if (other.name == RobotCollider.name && !IsShowRobot)
- {
- robot.transform.parent.gameObject.SetActive(true);
- IsShowRobot = true;
- }
- for (int i = 0; i < list_box.Count; i++)
- {
- if (other.name == list_box[i].name)
- {
- if (state)
- {
- HttpSocket.Instance.SendIpToPointTrigger(list_TriggerName[i < 4 ? 0 : i % 3], AllTool.GetTimeStamp());
- }
- // 擎天柱大模型关闭
- if (!state && i < list_Effects.Count && list_Effects[i].name == "P6")
- {
- testP6Car.CloseTestObj();
- }
- 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);
- if (Effect.name == "Party")
- {
- GameObject.Find("SceneRoot/InitMask/Box009").gameObject.SetActive(!state);
- for (int i = 0; i < list_points.Count; i++)
- {
- list_points[i].SetActive(!state);
- }
- if (IsShowRobot)
- {
- robot.transform.parent.gameObject.SetActive(!state);
- }
- }
- if (IsShowRobot && state)
- {
- robot.Walk(Effect.name);
- }
- //if (state)
- // robot.Walk(Effect.name);
- //if (state == false && Effect.name == "Party")
- // robot.transform.parent.gameObject.SetActive(true);
- }
- private void SetShowObject(GameObject Effect, bool state)
- {
- Effect.SetActive(state);
- }
- }
|