广西桂平帝恒管道燃气投资有限公司多角色网上演练
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.
 
 
 
 
 

252 lines
9.9 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AX.MessageSystem;
using System;
using AX.NetworkSystem;
public class ObjDelete : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnEnable()
{
MessageDispatcher.AddListener("DELETE_COMMAND", ObjDeleted);
//MessageDispatcher.AddListener("DELETE_ALL_COMMAND", DeletedAllObj);
}
void OnDisable()
{
MessageDispatcher.RemoveListener("DELETE_COMMAND", ObjDeleted);
//MessageDispatcher.RemoveListener("DELETE_ALL_COMMAND", DeletedAllObj);
}
void OnDestroy()
{
MessageDispatcher.RemoveListener("DELETE_COMMAND", ObjDeleted);
//MessageDispatcher.RemoveListener("DELETE_ALL_COMMAND", DeletedAllObj);
}
private void ObjDeleted(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject)
{
if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.fireNormal)
{
if (gameObject.GetComponent<FireSpreadCtrl>())
{
if (gameObject.GetComponent<FireSpreadCtrl>().fireAttribute.spreadWay != SpreadWay.None)
{
LoadPromptWin.Instance.LoadTextPromptWindow("开始蔓延的火不能删除!", 1f);
return;
}
}
//if (GameSettings.othersSettings.isStartDrill)
//{
// LoadPromptWin.Instance.LoadTextPromptWindow("开始演练后不能删除!", 1f);
// return;
//}
//如果演练开始手动删除灾情,通知修改火堆信息
if (GameSettings.othersSettings.IsStartDrill)
{
if (gameObject.GetComponent<FireSpreadCtrl>())
{
MessageDispatcher.SendMessage("FireNormalNumChasnge", false);
}
}
DeleteObj();
}
else if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.OrdinaryHose)
{
GameObject start = gameObject.GetComponent<ParentLinesMessage>().StartHitGameObj;
GameObject end = gameObject.GetComponent<ParentLinesMessage>().EndHitGameObj;
if(end!=null)
{//可能先把连接物体删除然后导致结尾物体为空
if (CheckWorkType(end, start) == false)
{
LoadPromptWin.Instance.LoadTextPromptWindow("不能删除该管线", 1f);
return;
}
}
//MessageDispatcher.SendMessage("DelectWaterHose");
var arg = new HoseConnectOrDelectData();
arg.StartId = start.GetComponent<BaseGameObjInfo>().gameObjID;
if(end!=null)
{
arg.EndId = end.GetComponent<BaseGameObjInfo>().gameObjID;
}
arg.HoseId = gameObject.GetComponent<BaseGameObjInfo>().gameObjID;
arg.Isconnect = false;
MessageDispatcher.SendMessage("HOSE_CONNECT_OR_DELECT", arg);
DeleteObj();
}
else if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.WaterCannon)
{
if (gameObject.GetComponent<WaterConnonController>().Skill != WaterCannonSkill.None)
{
LoadPromptWin.Instance.LoadTextPromptWindow("不能删除该水炮", 1f);
return;
}
//删除可回收工具,当前UI隐藏以及工具回收
MessageDispatcher.SendMessage("DelectExpendTool", gameObject);
DeleteObj();
}
else if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.SnowCannon)
{
if (gameObject.GetComponent<SnowConnonController>().Skill != SnowCannonSkill.None)
{
LoadPromptWin.Instance.LoadTextPromptWindow("不能删除该暴风雪炮", 1f);
return;
}
//删除可回收工具,当前UI隐藏以及工具回收
MessageDispatcher.SendMessage("DelectExpendTool", gameObject);
DeleteObj();
}
else if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.FirefightingRobot)
{
if (gameObject.GetComponent<FireRobotController>().WorkType == FireRobotSkill. ||
gameObject.GetComponent<FireRobotController>().WorkType == FireRobotSkill. ||
gameObject.GetComponent<FireRobotController>().WorkType == FireRobotSkill.)
{
LoadPromptWin.Instance.LoadTextPromptWindow("不能删除该灭火机器人", 1f);
return;
}
if(gameObject.GetComponent<FireRobotLayWaterHose>().GetSelfConsumedLength()>0)
{
LoadPromptWin.Instance.LoadTextPromptWindow("请先收起管线", 1f);
return;
}
//删除可回收工具,当前UI隐藏以及工具回收
MessageDispatcher.SendMessage("DelectExpendTool", gameObject);
DeleteObj();
}
else if (GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.WaterCurtainHose)
{
//删除可回收工具,当前UI隐藏以及工具回收
MessageDispatcher.SendMessage("DelectExpendTool", gameObject);
//删除绑定的水源车上的水幕水带
WaterCarBindCurtainHose waterCarBindCurtainHose = new WaterCarBindCurtainHose();
waterCarBindCurtainHose.WaterSourceObjId = GetComponent<WaterCurtainHoseSkillCtrl>().waterSourceGameObjId;
waterCarBindCurtainHose.WaterCurtainHose = gameObject;
waterCarBindCurtainHose.isConnect = false;
MessageDispatcher.SendMessage("WATERCAR_DESTORY_CURTAINHOSE", waterCarBindCurtainHose);
DeleteObj();
}
else
{
DeleteObj();
}
}
//选中消防人员删除处理
if (SelectedObjs.selectedCharacters.Contains(gameObject))
{
//var msg = GetComponent<FireManMessage>();
//if (msg && msg.group != null)
//{
// ResourceLoadWindow.Instance.LoadTextHintWindow("已经编组,不能删除", 1f);
//}
//else
//{
// if (msg) //如果是消防人员,就删除铺设的管线
// {
// gameObject.GetComponent<LayWaterHoseToggle>().Pack();
// gameObject.GetComponent<LayWaterHoseToggle>().DeleteParent();
// gameObject.GetComponent<LayFlarePath>().Pack();
// gameObject.GetComponent<LayFlarePath>().DeleteParent();
// }
// DeleteObj();
//}
}
}
//接收到删除所有物体命令时的处理脚本
private void DeletedAllObj(IMessage msg)
{
DeleteObj();
}
private void DeleteObj()
{
//删除同步命令
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
{
BaseNetworkSyncDate arg = new BaseNetworkSyncDate();
arg.SendUserID = CurrentUserInfo.mySelf.Id;
arg.gameObjID = gameObject.GetComponent<BaseGameObjInfo>().gameObjID;
NetworkManager.Default.SendAsync("OBJ_DELECT_SYNC", arg);
}
EntitiesManager.Instance.DeleteObj(gameObject);
//MessageDispatcher.SendMessage("DELE_HEAD_NAME", (object)gameObject.name);//删除对应的UI名称显示
}
private bool CheckWorkType(GameObject endobj, GameObject startobj)
{
bool can = true;
//如果是消防员,并且在出水
if (endobj.GetComponent<FireManControl>() && endobj.GetComponent<FireManControl>().workType == FireManSkills.SprayWater)
{
can = false;
}
else if (endobj.GetComponent<FireManControl>() && endobj.GetComponent<FireManControl>().workType == FireManSkills.LayWaterHose)
{
can = false;
}
///车在喷水
else if (endobj.GetComponent<TruckBindWaterSource>())
{
if ((endobj.GetComponent<TruckMessage>().NowSkill == TruckSkills. ||
endobj.GetComponent<TruckMessage>().NowSkill == TruckSkills.) ||
(endobj.GetComponent<WaterSource>() && endobj.GetComponent<WaterSource>().TotalFlow > 0/*&&startobj.GetComponent<WaterSource>().HasWaterSelfAndLine*/))
{
can = false;
}
}
//移动水泡喷水
else if (endobj.GetComponent<WaterConnonController>() &&
(
endobj.GetComponent<WaterConnonController>().Flow > 0
))
{
can = false;
}
else if (endobj.GetComponent<SnowConnonController>() &&
(
endobj.GetComponent<SnowConnonController>().Flow > 0
))
{
can = false;
}
else if (endobj.GetComponent<FireRobotController>())
{
//Transform P_FireRobotFollowHose = GameObject.Find("P_AllParent/P_Tools/P_FireRobotFollowHose").transform;
//if (P_FireRobotFollowHose.Find(endobj.name).childCount > 0)
//{
// can = false;
//}
if (endobj.GetComponent<FireRobotLayWaterHose>().GetSelfConsumedLength()>0.2f)
{
can = false;
}
if (endobj.GetComponent<FireRobotController>().Flow > 0)
{
can = false;
}
}
return can;
}
}