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.
106 lines
3.3 KiB
106 lines
3.3 KiB
using UnityEngine; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using AX.MessageSystem; |
|
using AX.TrackRecord; |
|
public class GuanXianIDScript : MonoBehaviour { |
|
|
|
Vector3 Vet3; |
|
public GameObject Begin; |
|
public GameObject End; |
|
public int Id; |
|
public List<GameObject> GuanXianList = new List<GameObject>(); |
|
|
|
void Awake() |
|
{ |
|
MessageDispatcher.AddListener("DeleteShuiYuan", DeleteShuiYuan); |
|
MessageDispatcher.AddListener("CheckConnectCar", CheckConnectCar); |
|
} |
|
public void CheckConnectCar(IMessage mesg)//检查是否连接车辆 |
|
{ |
|
Debug.Log(gameObject.name); |
|
if (!mesg.Sender.Equals(gameObject.name)) |
|
{ |
|
if (GuanXianList.Contains((GameObject)mesg.Data)) |
|
{ |
|
if (((GameObject)mesg.Data).name.Equals(Begin.name)) |
|
{ |
|
Begin.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
else if (((GameObject)mesg.Data).name.Equals(End.name)) |
|
{ |
|
End.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
} |
|
} |
|
|
|
} |
|
public void DeleteShuiYuan(IMessage mesg) //删除水源调用 |
|
{ |
|
if (GuanXianList.Contains((GameObject)mesg.Data)) |
|
{ |
|
GuanXianList.Remove((GameObject)mesg.Data); |
|
if (((GameObject)mesg.Data).name.Equals(Begin.name)) |
|
{ |
|
Begin = null; |
|
} |
|
else if (((GameObject)mesg.Data).name.Equals(End.name)) |
|
{ |
|
End = null; |
|
} |
|
DeletGuanXian(); |
|
} |
|
} |
|
public void GetTheMessage(GameObject begin,GameObject end) |
|
{ //接受管线第一次,第二次,ID |
|
GuanXianList.Clear(); |
|
|
|
Begin = begin; |
|
End = end; |
|
|
|
GuanXianList.Add(begin); |
|
GuanXianList.Add(end); |
|
|
|
if (LoadManager.Instance.IsPlayBacking) |
|
{ |
|
if (End.name.Contains("pmc")) |
|
{ |
|
End.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
else if (End.name.Contains("sgc")) |
|
{ |
|
End.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
else if (Begin.name.Contains("pmc")) |
|
{ |
|
begin.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
else if (Begin.name.Contains("sgc")) |
|
{ |
|
begin.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
} |
|
} |
|
GameObject GetRenYuan; //连接的人员 |
|
public void DeletGuanXian() |
|
{ |
|
for (int i = 0; i < GuanXianList.Count; i++) |
|
{ |
|
GameObject Game = GuanXianList[i] as GameObject; |
|
if (Game != null) |
|
{ |
|
if (Game.name.Contains("xiaofangyuan") || Game.name.Contains("xiaofangche") || Game.name.Contains("mb")) |
|
{ |
|
Game.GetComponent<RLineControl>().GetStopShui(this.gameObject); |
|
} |
|
} |
|
} |
|
|
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("DeleteShuiYuan", DeleteShuiYuan); |
|
MessageDispatcher.RemoveListener("CheckConnectCar", CheckConnectCar); |
|
} |
|
}
|
|
|