You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
5.2 KiB
164 lines
5.2 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.TrackRecord;
|
||
|
using System;
|
||
|
using UnityEngine.EventSystems;
|
||
|
|
||
|
public class StairTrigger : MonoBehaviour {
|
||
|
|
||
|
/// <summary>
|
||
|
/// 上楼触发脚本
|
||
|
/// </summary>
|
||
|
public int HasCengNum=0;
|
||
|
private DateTime t1, t2;
|
||
|
float StayTime = 3f;
|
||
|
bool showOnce = false;
|
||
|
|
||
|
public List<String> TriggerList = new List<string>();
|
||
|
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.SANDTABLE)
|
||
|
{
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
if (this.name.Equals("TheStairsTrigger"))
|
||
|
{
|
||
|
triggerMode = TriggerMode.TheStairs;
|
||
|
}
|
||
|
else if (this.name.Equals("FireLiftTrigger"))
|
||
|
{
|
||
|
triggerMode = TriggerMode.FireLift;
|
||
|
}
|
||
|
MessageDispatcher.AddListener("clearTrigger", clearTrigger);
|
||
|
}
|
||
|
public void clearTrigger(IMessage meg)
|
||
|
{
|
||
|
TriggerList.Clear();
|
||
|
}
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("clearTrigger", clearTrigger);
|
||
|
}
|
||
|
|
||
|
|
||
|
public enum TriggerMode : int
|
||
|
{
|
||
|
FireLift=1,
|
||
|
TheStairs=2
|
||
|
}
|
||
|
public TriggerMode triggerMode = TriggerMode.TheStairs;
|
||
|
|
||
|
void OnTriggerEnter(Collider collider)
|
||
|
{
|
||
|
|
||
|
if (!LoadManager.Instance.IsPlayBacking
|
||
|
&& ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING
|
||
|
&& collider.gameObject.name.Contains("xiaofangyuan"))
|
||
|
{
|
||
|
if (collider.gameObject.GetComponent<UnityEngine.AI.NavMeshAgent>().enabled == true)
|
||
|
{
|
||
|
if (collider.gameObject.GetComponent<UnityEngine.AI.NavMeshAgent>().velocity.magnitude > 0)
|
||
|
{
|
||
|
StayTime = 3f;
|
||
|
showOnce = false;
|
||
|
TriggerList.Add(collider.gameObject.name);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
private void OnTriggerExit(Collider other)
|
||
|
{
|
||
|
if (!LoadManager.Instance.IsPlayBacking&& ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && other.gameObject.name.Contains("xiaofangyuan"))
|
||
|
{
|
||
|
if (TriggerList.Contains(other.name))
|
||
|
{
|
||
|
TriggerList.Remove(other.name);
|
||
|
}
|
||
|
if (TriggerList.Count == 0)
|
||
|
{
|
||
|
if (StairUI.Instance.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
StayTime = 3f;
|
||
|
showOnce = false;
|
||
|
StairUI.Instance.gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
private void OnTriggerStay(Collider other)
|
||
|
{
|
||
|
if (!LoadManager.Instance.IsPlayBacking && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && other.gameObject.name.Contains("xiaofangyuan"))
|
||
|
{
|
||
|
|
||
|
if (StairUI.Instance.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if (showOnce)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if (TriggerList.Count > 0)
|
||
|
{
|
||
|
StayTime -= Time.deltaTime;
|
||
|
if (StayTime < 0)
|
||
|
{
|
||
|
StairUI.Instance.gameObject.SetActive(true);
|
||
|
StairUI.Instance.GetRiseTop(HasCengNum, (int)triggerMode);
|
||
|
StayTime = 3;
|
||
|
showOnce = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void OnMouseDown()
|
||
|
{
|
||
|
/*
|
||
|
t2 = DateTime.Now;
|
||
|
|
||
|
if (t2 - t1 < new TimeSpan(0, 0, 0, 0, 400) && !EventSystem.current.IsPointerOverGameObject()
|
||
|
&& !LoadManager.Instance.IsPlayBacking && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING)
|
||
|
{
|
||
|
if (!StairUI.Instance.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
if (InputManager.Instance_.GetSelectedCharacters().Count != 0
|
||
|
&& InputManager.Instance_.GetSelectedCharacters()[0].name.Contains("xiaofangyuan"))
|
||
|
{
|
||
|
bool Has = false;
|
||
|
for (int i = 0; i < InputManager.Instance_.GetSelectedCharacters().Count; i++)
|
||
|
{
|
||
|
float distance = Vector3.Distance(InputManager.Instance_.GetSelectedCharacters()[0].transform.position,
|
||
|
this.gameObject.transform.position);
|
||
|
if (distance > 10f)
|
||
|
{
|
||
|
Has = true;
|
||
|
}
|
||
|
}
|
||
|
if (!Has)
|
||
|
{
|
||
|
StairUI.Instance.gameObject.SetActive(true);
|
||
|
StairUI.Instance.GetRiseTop(HasCengNum);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("Operatinghints", (object)"请人员靠近电梯");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("Operatinghints", (object)"请选择人员前往");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
t1 = t2;*/
|
||
|
}//双击
|
||
|
}
|