海淀天下城电子沙盘单机版
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.
 
 
 
 

118 lines
4.0 KiB

using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/// <summary>
/// 伤员被困人员响应双击事件
/// </summary>
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<YingJiuData>(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<FireManMessage> FireManList = new List<FireManMessage>();//保存就近消防员
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<FireManMessage>());
}
}
if (GetComponent<CloneGameObjInfo>().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);
}
}
}
}
}
}