using System.Collections; using System.Collections.Generic; using UnityEngine; using XFramework; //突发事件监测器 仅在学员端使用 public class TuFaTriggerInstanceCtrl : MonoBehaviour { SphereCollider thisCollider; TuFaEnum TuFa; int id; bool hasTriggered; private void Start() { thisCollider = this.gameObject.AddComponent(); thisCollider.radius = 50f; thisCollider.isTrigger = true;//仅做触发器 } // public void InitTrigger( TuFaEnum tuFaEnum,int id) { TuFa = tuFaEnum; this.id = id; } /// /// /// public int GetID() { return id; } private void OnTriggerEnter(Collider other) { if (hasTriggered) return; CarCtrl carCtrl= other.transform.GetComponentInParent(); if (carCtrl?.carType == CarPosType.firstCar)//首车可触发 { hasTriggered = true; // EventCenter.Instance.EventTrigger("TuFaTrigger", TuFa); 弃用 改为GameMain调用 GameMain.Instance.UIManager.ChangePanel("TuFaTrigger", TuFa);//显示答题面板 GameObjectManager.Instance.StopMove();//车辆停止前进 thisCollider.enabled = false;//触发后移除检测组件 } } }