贺州人民医院电子沙盘
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.
 
 
 
 

627 lines
23 KiB

using AX.InputSystem;
using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;
public enum FireManSkills
{
None = 0,
LayWaterHose = 1 << 1,
LayLifeSavingFlarePath = 1 << 2,
SprayWater = 1 << 3,
SprayFoam = 1 << 4,
ForcibleEntry = 1 << 5,
DischargeSmoke = 1 << 6,
Lighting = 1 << 7,
PackUpLine = 1 << 8,
TagSearchRoom = 1 << 9,
EquipSelect = 1 << 10,
Save = 1 << 11,
AskPeople = 1 << 12,
ClearDangerous = 1 << 13,
ClearSundries = 1 << 14,
Decontamination = 1 << 15
}
public class FireManMessage : MonoBehaviour
{
public FireManSkills workType;//记录是喷水还是照明等
public FireManSkills EnabledSkills;
//public ParticleEnum waterType;//记录喷水方式
private GameObject shuiqiang;
private GameObject wuchiju;
private GameObject zhaomingdeng;
private GameObject panyanji;
private Bag bag;
private XiaoFangYuanDrawLine drawline;
private long GameObjID;
private bool flag;//是否连接水源
void Awake()
{
wuchiju = TransformHelper.FindChild(transform, "WuChiJu").gameObject;
zhaomingdeng = TransformHelper.FindChild(transform, "ZhaoMingDeng").gameObject;
panyanji = TransformHelper.FindChild(transform, "PaiYanJi").gameObject;
MessageDispatcher.AddListener("WaterSourceChanged", WaterSourceChanged);
MessageDispatcher.AddListener("WaterSeparaterChange", WaterseparadChange);
MessageDispatcher.AddListener("LayWaterHose", LayWaterHose);
MessageDispatcher.AddListener("LayLifeSavingFlarePath", LayLifeSavingFlarePath);
MessageDispatcher.AddListener("ForcibleEntry", ForcibleEntry);
MessageDispatcher.AddListener("DischargeSmoke", DischargeSmoke);
MessageDispatcher.AddListener("Lighting", Lightingfunc);
MessageDispatcher.AddListener("Save", Save);
MessageDispatcher.AddListener("PackUpLine", PackUpLine);
MessageDispatcher.AddListener("TagSearchRoom", TagSearchRoom);
MessageDispatcher.AddListener("EquipSelect", EquipSelectfunc);
MessageDispatcher.AddListener("SprayWater", SprayWater);
MessageDispatcher.AddListener("SprayFoam", SprayFoam);
// MessageDispatcher.AddListener("BagChaneg", BagChange);
}
void OnDestroy()
{
MessageDispatcher.RemoveListener("WaterSourceChanged", WaterSourceChanged);
MessageDispatcher.RemoveListener("WaterSeparaterChange", WaterseparadChange);
MessageDispatcher.RemoveListener("LayWaterHose", LayWaterHose);
MessageDispatcher.RemoveListener("LayLifeSavingFlarePath", LayLifeSavingFlarePath);
MessageDispatcher.RemoveListener("ForcibleEntry", ForcibleEntry);
MessageDispatcher.RemoveListener("DischargeSmoke", DischargeSmoke);
MessageDispatcher.RemoveListener("Lighting", Lightingfunc);
MessageDispatcher.RemoveListener("Save", Save);
MessageDispatcher.RemoveListener("PackUpLine", PackUpLine);
MessageDispatcher.RemoveListener("TagSearchRoom", TagSearchRoom);
MessageDispatcher.RemoveListener("EquipSelect", EquipSelectfunc);
MessageDispatcher.RemoveListener("SprayWater", SprayWater);
MessageDispatcher.RemoveListener("SprayFoam", SprayFoam);
//MessageDispatcher.RemoveListener("BagChaneg", BagChange);
}
private void WaterseparadChange(IMessage obj)
{
if (GetComponent<WaterReceiver>())
{
Waterseparadata waterdata = (Waterseparadata)obj.Data;
if (waterdata.receiveId == GameObjID)
{
flag = waterdata.IsContent;
int type = (int)waterdata.watertype;
if (type==0)
{
flag = false;
if (workType == FireManSkills.SprayWater || workType == FireManSkills.Decontamination)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
}
}
if (type == 1)//普通水
{
if (flag)
{
EnabledSkills |= FireManSkills.SprayWater;
EnabledSkills |= FireManSkills.Decontamination;
}
else
{
if (workType == FireManSkills.SprayWater || workType == FireManSkills.Decontamination)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
}
}
}
if (type == 2)//泡沫
{
if (flag)
EnabledSkills |= FireManSkills.SprayFoam;
else
{
workType = FireManSkills.None;
if ((EnabledSkills & FireManSkills.SprayFoam) != 0)
{
EnabledSkills &= ~FireManSkills.SprayFoam;
}
MessageDispatcher.SendMessage(GetComponent<CloneGameObjInfo>().gameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
}
if (type == 3)//有水也有泡沫
{
if (flag)
{
EnabledSkills |= FireManSkills.SprayWater;
EnabledSkills |= FireManSkills.Decontamination;
EnabledSkills |= FireManSkills.SprayFoam;
}
else
{
if (workType == FireManSkills.SprayWater || workType == FireManSkills.Decontamination || workType == FireManSkills.SprayFoam)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
EnabledSkills &= ~FireManSkills.SprayFoam;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
if ((EnabledSkills & FireManSkills.SprayFoam) != 0)
{
EnabledSkills &= ~FireManSkills.SprayFoam;
}
}
}
}
SprayChangeMove(flag);
if (!RecordEvent.IsReplay())
{
if (this != null && FireManSkillsPanel.GetInstance != null && FireManSkillsPanel.GetInstance.gameObject.activeSelf)
MessageDispatcher.SendMessage("FiremanSkillsPanelDraw", gameObject);
}
}
}
}
private void Start()
{
GameObjID = GetComponent<CloneGameObjInfo>().gameObjID;
bag = GetComponent<Bag>();
drawline = GetComponent<XiaoFangYuanDrawLine>();
}
/// <summary>
/// 背包装备更改导致技能是否可用(破拆.照明.排烟)
/// </summary>
/// <param name="obj"></param>
private void EquipSelectfunc(IMessage obj)
{
EquipSelect.GetInstance.gameObject.SetActive(true);
BagPanel.GetInstance.gameObject.SetActive(true);
}
private void TagSearchRoom(IMessage obj)
{
if (SelectedObjs.selectedCharacters.Count > 0 && gameObject == SelectedObjs.selectedCharacters[0])
{
var arg = new CloneCmdArgs();
arg.cloneObjType = CloneObjType.MarkSearchRoom;
arg.hitPos = transform.position;
arg.gameObjID = GameObjID;
MessageDispatcher.SendMessage(EntitiesManager.Instance.CreateObjID(), "CLONE_COMMAND", arg);
}
}
private void PackUpLine(IMessage obj)
{
if (SelectedObjs.selectedCharacters.Count > 0 && gameObject == SelectedObjs.selectedCharacters[0])
{
drawline.destoryLine();
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
if (GetComponent<WaterReceiver>())
{
if (GetComponent<WaterReceiver>().waterlinelist.Count > 0)
{
GetComponent<WaterReceiver>().waterlinelist.Clear();
}
}
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
if ((EnabledSkills & FireManSkills.SprayFoam) != 0)
{
EnabledSkills &= ~FireManSkills.SprayFoam;
}
MessageDispatcher.SendMessage("FiremanSkillsPanelDraw", gameObject);
}
}
private void Save(IMessage obj)
{
}
private void Lightingfunc(IMessage obj)
{
var gameObjID = (long)obj.Sender;
if (GameObjID == gameObjID)
{
Lighting((bool)obj.Data);
}
}
private void DischargeSmoke(IMessage obj)
{
var gameObjID = (long)obj.Sender;
if (GameObjID == gameObjID)
{
DischargeSmoke((bool)obj.Data);
}
}
private void ForcibleEntry(IMessage obj)
{
var gameObjID = (long)obj.Sender;
if (GameObjID == gameObjID)
{
Debug.Log(obj.Type.ToString());
ForcibleEntry((bool)obj.Data);
}
}
private void LayLifeSavingFlarePath(IMessage obj)
{
if (GameObjID == (long)obj.Sender)
{
bool value = (bool)obj.Data;
if (value)
drawline.setLine();
else
{
drawline.EndDraw();
}
}
}
private void SprayWater(IMessage obj)
{
if (GameObjID == (long)obj.Sender)
{
bool value = (bool)obj.Data;
if (value)
{
drawline.setLine();
if (GetComponent<Bag>().GetEquipNum("消防高压水带") >= 1)
{
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
}
}
else
{
drawline.EndDraw();
if (flag)
{
//if (GetComponent<Bag>().GetEquipNum("消防高压水带") < 1)
{
GetComponent<NavMeshAgent>().enabled = false;
GetComponent<AgentController>().enabled = false;
}
}
}
}
}
private void SprayFoam(IMessage obj)
{
if (GameObjID == (long)obj.Sender)
{
bool value = (bool)obj.Data;
if (value)
{
drawline.setLine();
if (GetComponent<Bag>().GetEquipNum("消防高压水带") >= 1)
{
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
}
}
else
{
drawline.EndDraw();
if (flag)
{
//if (GetComponent<Bag>().GetEquipNum("消防高压水带") < 1)
{
GetComponent<NavMeshAgent>().enabled = false;
GetComponent<AgentController>().enabled = false;
}
}
}
}
}
private void LayWaterHose(IMessage obj)
{
if (GameObjID == (long)obj.Sender)
{
bool value = (bool)obj.Data;
if (value)
{
drawline.setLine();
if (GetComponent<Bag>().GetEquipNum("消防高压水带") >= 1)
{
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
}
}
else
{
drawline.EndDraw();
if (flag)
{
//if (GetComponent<Bag>().GetEquipNum("消防高压水带") < 1)
{
GetComponent<NavMeshAgent>().enabled = false;
GetComponent<AgentController>().enabled = false;
}
}
}
}
}
// Update is called once per frame
void Update()
{
}
private void WaterSourceChanged(IMessage obj)
{
var waterdata = (WaterConnectionData)obj.Data;
var gameObjId = waterdata.receiverID;
// var Id = GetComponent<BaseGameObjInfo>().GameObjID;
if (gameObjId == GameObjID)
{
flag = waterdata.connected;
int type = (int)waterdata.type;
if (type == 0)
{
flag = false;
if (workType == FireManSkills.SprayWater || workType == FireManSkills.Decontamination)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
}
}
if (type == 1)//普通水
{
if (flag)
{
EnabledSkills |= FireManSkills.SprayWater;
EnabledSkills |= FireManSkills.Decontamination;
}
else
{
if (workType == FireManSkills.SprayWater||workType==FireManSkills.Decontamination)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
}
}
}
if (type == 2)//泡沫
{
if (flag)
EnabledSkills |= FireManSkills.SprayFoam;
else
{
workType = FireManSkills.None;
if ((EnabledSkills & FireManSkills.SprayFoam) != 0)
{
EnabledSkills &= ~FireManSkills.SprayFoam;
}
MessageDispatcher.SendMessage(GetComponent<CloneGameObjInfo>().gameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
}
if (type == 3)//有水也有泡沫
{
if (flag)
{
EnabledSkills |= FireManSkills.SprayWater;
EnabledSkills |= FireManSkills.Decontamination;
EnabledSkills |= FireManSkills.SprayFoam;
}
else
{
if (workType == FireManSkills.SprayWater || workType == FireManSkills.Decontamination|| workType == FireManSkills.SprayFoam)
{
workType = FireManSkills.None;
EnabledSkills &= ~FireManSkills.SprayWater;
EnabledSkills &= ~FireManSkills.Decontamination;
EnabledSkills &= ~FireManSkills.SprayFoam;
MessageDispatcher.SendMessage(GameObjID, "WaterSwitch", flag);
GetComponent<XiaoFangYuanDrawLine>().EndDraw();
}
else
{
if ((EnabledSkills & FireManSkills.SprayWater) != 0)
{
EnabledSkills &= ~FireManSkills.SprayWater;
}
if ((EnabledSkills & FireManSkills.Decontamination) != 0)
{
EnabledSkills &= ~FireManSkills.Decontamination;
}
if ((EnabledSkills & FireManSkills.SprayFoam) != 0)
{
EnabledSkills &= ~FireManSkills.SprayFoam;
}
}
}
}
SprayChangeMove(flag);
if (!RecordEvent.IsReplay())
{
if (this!=null&&FireManSkillsPanel.GetInstance!=null&&FireManSkillsPanel.GetInstance.gameObject.activeSelf)
MessageDispatcher.SendMessage("FiremanSkillsPanelDraw", gameObject);
}
}
}
public void ForcibleEntry(bool active)
{
if (wuchiju)
wuchiju.SetActive(active);
}
public void DischargeSmoke(bool active)
{
if (panyanji)
panyanji.SetActive(active);
}
public void Lighting(bool active)
{
if (zhaomingdeng)
zhaomingdeng.SetActive(active);
}
//设置消防员技能在动作上的表现
public void workTypeChanged()
{
//铺设水带
}
public void SetEnableSkill(bool add)
{
if (add)
{//添加装备
if (bag.GetEquipFromBag("无齿锯") != null)
{
EnabledSkills |= FireManSkills.ForcibleEntry;
}
if (bag.GetEquipFromBag("手提式防爆强光照明灯") != null)
{
EnabledSkills |= FireManSkills.Lighting;
}
if (bag.GetEquipFromBag("移动式排烟机") != null)
{
EnabledSkills |= FireManSkills.DischargeSmoke;
}
}
else
{//移除装备
if (bag.GetEquipFromBag("无齿锯") == null)
{
EnabledSkills &= ~FireManSkills.ForcibleEntry;
}
if (bag.GetEquipFromBag("手提式防爆强光照明灯") == null)
{
EnabledSkills &= ~FireManSkills.Lighting;
}
if (bag.GetEquipFromBag("移动式排烟机") == null)
{
EnabledSkills &= ~FireManSkills.DischargeSmoke;
}
}
}
void SprayChangeMove(bool connect)
{
if (connect)
{
if (GetComponent<Bag>().GetEquipNum("消防高压水带") < 1)
{
GetComponent<NavMeshAgent>().enabled = !connect;
GetComponent<AgentController>().enabled = !connect;
}
if (workType != FireManSkills.SprayWater ||
workType != FireManSkills.SprayFoam ||
workType != FireManSkills.Decontamination||
workType!= FireManSkills.LayWaterHose)
{
GetComponent<NavMeshAgent>().enabled = !connect;
GetComponent<AgentController>().enabled = !connect;
}
}
else
{
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
}
}
public void BagChange(bool add)
{
if (bag.GetEquipNum("消防高压水带") >= 1)
{
GetComponent<NavMeshAgent>().enabled = true;
GetComponent<AgentController>().enabled = true;
}
}
}