using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; /// /// 伤员被困人员响应双击事件 /// public class WoundedControl : ObjDoubleClick { public bool isfage = false; public bool HaveFinish = false; public string AreaName; public void Start() { MessageDispatcher.AddListener("ReplayEvent", ReplayEventYingJiu); } private void OnDestroy() { MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventYingJiu); } private void ReplayEventYingJiu(IMessage obj) { var eventData = (EventData)obj.Data; if (eventData.eventType == RecordEventType.YingJiu) { YingJiuData data = JsonUtility.FromJson(eventData.json); if (data.name == gameObject.name) { AreaName = data.areaname; YingJiuPanel.GetActiveInstance.YingJiu(gameObject, data.areaname); YingJiuPanel.GetActiveInstance.SureBtn_Click(); } } } public override void ClickFunc() { base.ClickFunc(); if (!isfage && !HaveFinish) { bool Has = false; List FireManList = new List();//保存就近消防员 foreach (Transform child in GameObject.Find("P_AllParent/P_People/P_FireMan").transform) { float distance = Vector3.Distance(child.transform.position, this.gameObject.transform.position); if (distance < 4f) { FireManList.Add(child.GetComponent()); } } if (GetComponent().gameObjType == CloneObjType.Wounded)//伤员需要两名以上消防员靠近 { int count = 0; if (FireManList.Count == 0) { ResourceLoadWindow.Instance.LoadTextHintWindow("请消防员靠近伤员营救", 1f); } else if (FireManList.Count == 1) { ResourceLoadWindow.Instance.LoadTextHintWindow("至少两名消防员靠近伤员营救", 1f); } else { foreach (var item in FireManList) { if (item.workType == FireManSkills.Save) { count++; } if (count >= 2) { Has = true; break; } } if (!Has) { ResourceLoadWindow.Instance.LoadTextHintWindow("请消防员选中营救技能", 1f); } else { YingJiuPanel.GetActiveInstance.YingJiu(gameObject); } } } else { if(FireManList.Count==0) { ResourceLoadWindow.Instance.LoadTextHintWindow("请消防员靠近被困人员营救", 1f); } else { foreach (var item in FireManList) { if(item.workType == FireManSkills.Save) { Has = true; break; } } if (!Has) { ResourceLoadWindow.Instance.LoadTextHintWindow("请消防员选中营救技能", 1f); } else { YingJiuPanel.GetActiveInstance.YingJiu(gameObject); } } } } } }