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.
256 lines
8.9 KiB
256 lines
8.9 KiB
|
|
using UnityEngine; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using AX.MessageSystem; |
|
using AX.TrackRecord; |
|
using System; |
|
/// <summary> |
|
/// 管线连接两个点操作 |
|
/// </summary> |
|
public enum TypeOfLink : int |
|
{ |
|
没有连接 = 0, |
|
xiaofangyuan = 1, |
|
xiaofangche = 2, |
|
xiaofangshuan = 3, |
|
xiaofangjing = 4 |
|
|
|
} |
|
public class RLineControl : MonoBehaviour { |
|
public TypeOfLink Link = TypeOfLink.没有连接; |
|
private GameObject LinkGanXian; //搭接的管线 |
|
public List<GameObject> LineList_GameObject = new List<GameObject>(); |
|
|
|
|
|
[HideInInspector] |
|
public bool Checkxfs = false; |
|
public GameObject hoseOfXFY; |
|
private Animator Ani; |
|
Enemy enemy; |
|
void Start() |
|
{ |
|
enemy = this.GetComponent<Enemy>(); |
|
Ani = this.gameObject.GetComponent<Animator>(); |
|
} |
|
|
|
//void Update() |
|
//{ |
|
// if (LineList_GameObject.Count < 1 && GetComponent<LineamentEvent>().isConnectCar) |
|
// {//如果水带链表没有元素,并且LineamentEvent.isConnectCar还是真 |
|
// Debug.Log(gameObject.name+"可以移动,不再连接"); |
|
// GetComponent<LineamentEvent>().isConnectCar = false; |
|
// } |
|
|
|
//} |
|
|
|
public void CheckXFS() |
|
{ |
|
//for (int i = 0; i < RecordList.Count; i++) |
|
//{ |
|
// if (RecordList[i].gameObject.name.Contains("Cylinder")) |
|
// { |
|
// Checkxfs = true; |
|
// } |
|
//} |
|
//if (Checkxfs) |
|
//{ |
|
// for (int i = 0; i < RecordList.Count; i++) |
|
// { |
|
// GameObject obj = RecordList[i] as GameObject; |
|
// if (obj.name.Contains("xiaofang")) |
|
// { |
|
// obj.GetComponent<RLineControl>().Checkxfs = true; |
|
// } |
|
// } |
|
//} |
|
} |
|
|
|
public void AddLineC(List<AX.TrackRecord.LineAttri> lineList) |
|
{ |
|
StartCoroutine(AddLineTo(lineList)); |
|
} |
|
|
|
private IEnumerator AddLineTo(List<AX.TrackRecord.LineAttri> lineList) |
|
{ |
|
yield return new WaitForSeconds(1f); |
|
for(int i = 0; i < lineList.Count; i++) |
|
{ |
|
var lineName = lineList[i].lineName; |
|
GameObject line = TransformHelper.FindChild(GameObject.Find("AllParent").transform, lineName).gameObject; |
|
LineList_GameObject.Add(line); |
|
GameObject begin = null, end = null; |
|
if(lineList[i].begin.Contains("XHS") || lineList[i].begin.Contains("xhs")) |
|
{ |
|
begin = GameObject.Find(lineList[i].begin); |
|
if (begin == null) |
|
{ |
|
var bt = TransformHelper.FindChild(GameObject.Find("SceneAll").transform, lineList[i].begin); |
|
if (bt != null) |
|
{ |
|
begin = bt.gameObject; |
|
} |
|
else |
|
{ |
|
Debug.Log("11"); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
var b = TransformHelper.FindChild(GameObject.Find("AllParent").transform, lineList[i].begin); |
|
if (b != null) |
|
{ |
|
begin = b.gameObject; |
|
} |
|
else |
|
{ |
|
Debug.Log("b"); |
|
} |
|
} |
|
if (lineList[i].end.Contains("XHS") || lineList[i].end.Contains("xhs")) |
|
{ |
|
end = GameObject.Find(lineList[i].end); |
|
if (end == null) |
|
{ |
|
var et = TransformHelper.FindChild(GameObject.Find("SceneAll").transform, lineList[i].end); |
|
if (et != null) |
|
{ |
|
end = et.gameObject; |
|
} |
|
else |
|
{ |
|
Debug.Log("22"); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
var e = TransformHelper.FindChild(GameObject.Find("AllParent").transform, lineList[i].end); |
|
if (e != null) |
|
{ |
|
end = e.gameObject; |
|
} |
|
else |
|
{ |
|
Debug.Log("e"); |
|
} |
|
} |
|
if(begin!=null && end != null) |
|
{ |
|
line.GetComponent<GuanXianIDScript>().GetTheMessage(begin, end); |
|
} |
|
|
|
} |
|
} |
|
|
|
public void GetLianJieOb(GameObject ob) |
|
{ //接受搭接的管线OBJ |
|
LinkGanXian = ob; |
|
LineList_GameObject.Add(LinkGanXian); |
|
GuanXianIDScript guaxianId = LinkGanXian.GetComponent<GuanXianIDScript>(); |
|
|
|
|
|
MessageDispatcher.SendMessage("SelectControl",(object)""); |
|
MessageDispatcher.SendMessage("ResettingButton"); |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
StartCoroutine(StartCoutine()); |
|
} |
|
LineamentEvent.gameobj = null; |
|
} |
|
public void GetLianJieOb_Layer(GameObject ob) |
|
{ //接受搭接的管线OBJ |
|
LinkGanXian = ob; |
|
LineList_GameObject.Add(LinkGanXian); |
|
GuanXianIDScript guaxianId = LinkGanXian.GetComponent<GuanXianIDScript>(); |
|
|
|
|
|
MessageDispatcher.SendMessage("SelectControl", (object)""); |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
StartCoroutine(StartCoutine()); |
|
} |
|
LineamentEvent.gameobj = null; |
|
} |
|
IEnumerator StartCoutine() |
|
{ |
|
yield return new WaitForSeconds(Time.deltaTime * 2); |
|
|
|
GameObject start = LinkGanXian.GetComponent<GuanXianIDScript>().GuanXianList[0]; |
|
GameObject end = LinkGanXian.GetComponent<GuanXianIDScript>().GuanXianList[1]; |
|
TrackRecordHelpClass.RecordAddLineToXFYEvent(LinkGanXian.name, gameObject.name, start.name, end.name); |
|
} |
|
public void GetStopShui(GameObject pline) |
|
{ |
|
for (int i = 0; i < LineList_GameObject.Count; i++) //遍历当前搭接消防员身上的管线,如果包含传来的管线,去除管线 |
|
{ |
|
GameObject Pline = LineList_GameObject[i] as GameObject; |
|
if (Pline.name.Equals(pline.name)) |
|
{ |
|
LineList_GameObject.Remove(Pline); |
|
} |
|
} |
|
if (this.gameObject.transform.Find("info/Function").gameObject.GetComponent<TextMesh>().text == "待命") //删除时候的调用,当前状态为待命,直接返回 |
|
{ |
|
return; |
|
} |
|
if (this.gameObject.name.Contains("xiaofangche")) |
|
{ |
|
if (LineList_GameObject.Count < 1)//2 |
|
{ //如果去除后的管线数为零,关闭喷水,当前状态为待命 |
|
if (hoseOfXFY&&hoseOfXFY.activeInHierarchy) |
|
{//如果管线存在,并且已经被激活 |
|
hoseOfXFY.SetActive(false); |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"水源不足停止出水"); |
|
enemy.InitFunction("待命"); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if (LineList_GameObject.Count == 0) |
|
{ //如果去除后的管线数为零,关闭喷水,当前状态为待命 |
|
if (hoseOfXFY) |
|
{ |
|
hoseOfXFY.SetActive(false); |
|
enemy.InitFunction("待命"); |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"没有连接水源停止出水"); |
|
Ani.SetBool("isInSitu", false); |
|
} |
|
} |
|
} |
|
|
|
//for (int j = 0; j < LineList_GameObject.Count; j++) //如果不为零,删除后满足条件继续灭火 |
|
//{ |
|
// GameObject link = LineList_GameObject[j] as GameObject; |
|
// string begin = link.GetComponent<GuanXianIDScript>().Begin.ToString(); |
|
// string end = link.GetComponent<GuanXianIDScript>().End.ToString(); |
|
// if (begin.IndexOf(TypeOfLink.xiaofangyuan.ToString()) >= 0 && end.IndexOf(TypeOfLink.xiaofangjing.ToString()) >= 0 || end.IndexOf(TypeOfLink.xiaofangshuan.ToString()) >= 0 || end.IndexOf(TypeOfLink.xiaofangche.ToString()) >= 0) |
|
// { |
|
// if (hoseOfXFY) |
|
// hoseOfXFY.SetActive(true); |
|
|
|
// return; |
|
// } |
|
// else if (end.IndexOf(TypeOfLink.xiaofangyuan.ToString()) >= 0 && begin.IndexOf(TypeOfLink.xiaofangjing.ToString()) >= 0 || begin.IndexOf(TypeOfLink.xiaofangshuan.ToString()) >= 0 || begin.IndexOf(TypeOfLink.xiaofangche.ToString()) >= 0) |
|
// { |
|
// if (hoseOfXFY) |
|
// hoseOfXFY.SetActive(true); |
|
|
|
// return; |
|
// } |
|
// else |
|
// { //以上没有满足,如果当前为灭火状态,改为待命状态 |
|
// if (hoseOfXFY) |
|
// { |
|
// if (hoseOfXFY.activeInHierarchy == true) |
|
// { |
|
// //enemy.InitFunction("待命"); |
|
// hoseOfXFY.SetActive(false); |
|
// } |
|
// } |
|
// } |
|
//} |
|
} |
|
}
|
|
|