|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using AX.MessageSystem;
|
|
|
|
using UnityEngine;
|
|
|
|
using AX.InputSystem;
|
|
|
|
using AX.NetworkSystem;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///克隆单一物体
|
|
|
|
/// </summary>
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
public class CloneSingleDisasterObj : CloneBase
|
|
|
|
{
|
|
|
|
|
|
|
|
//public string PrefabsPath;
|
|
|
|
[SerializeField]
|
|
|
|
[Tooltip("距离地面距离")]
|
|
|
|
protected float Height = 0;
|
|
|
|
//public ForcibleType ForcibleType = ForcibleType.None;
|
|
|
|
public override void Execute(IMessage obj)
|
|
|
|
{
|
|
|
|
var gameObjID = (long)obj.Sender;
|
|
|
|
var data = ((CloneCmdArgs)obj.Data);
|
|
|
|
if (data.cloneObjType == cloneObjType)
|
|
|
|
{
|
|
|
|
var hitPoint = data.hitPos;
|
|
|
|
if (data.ForcibleType!=ForcibleType.None)
|
|
|
|
{
|
|
|
|
switch (data.ForcibleType)
|
|
|
|
{
|
|
|
|
case ForcibleType.None:
|
|
|
|
break;
|
|
|
|
case ForcibleType.ForcibleDoor:
|
|
|
|
clonePrefab = Resources.Load("ClonePrefabs/DisasterPrefabs/ForcibleEntryPoint") as GameObject;
|
|
|
|
Height = 0f;
|
|
|
|
break;
|
|
|
|
case ForcibleType.RoolingDoor:
|
|
|
|
clonePrefab = Resources.Load("ClonePrefabs/DisasterPrefabs/RoolingDoor") as GameObject;
|
|
|
|
Height = 0.1f;
|
|
|
|
break;
|
|
|
|
case ForcibleType.FactoryDoor:
|
|
|
|
clonePrefab = Resources.Load("ClonePrefabs/DisasterPrefabs/FactoryDoor") as GameObject;
|
|
|
|
Height = 0.2f;
|
|
|
|
break;
|
|
|
|
case ForcibleType.FirePassDoor:
|
|
|
|
clonePrefab = Resources.Load("ClonePrefabs/DisasterPrefabs/FirePassDoor") as GameObject;
|
|
|
|
Height = 0.1f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Vector3 clonedObjPos = new Vector3(hitPoint.x, hitPoint.y + Height, hitPoint.z);
|
|
|
|
var clonedObj = EntitiesManager.Instance.CreateObj(clonePrefab, clonedObjPos, transform, gameObjID);
|
|
|
|
|
|
|
|
clonedObj.name = CloneObjNameTool.Instance().GetCloneObjectName(cloneObjType);
|
|
|
|
|
|
|
|
SelectedObjs.gameObjs.Add(clonedObj);
|
|
|
|
|
|
|
|
//设置克隆物体所在楼层等基本属性,属性从点击的对象上获取
|
|
|
|
var hitObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID);
|
|
|
|
|
|
|
|
|
|
|
|
CloneGameObjInfo hitObjInfo = hitObj.GetComponent<CloneGameObjInfo>();
|
|
|
|
CloneGameObjInfo cloneObjInfo = clonedObj.GetComponent<CloneGameObjInfo>();
|
|
|
|
cloneObjInfo.gameObjType = cloneObjType;
|
|
|
|
cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
cloneObjInfo.buildNum = hitObjInfo.buildNum;
|
|
|
|
cloneObjInfo.floorNum = hitObjInfo.floorNum;
|
|
|
|
cloneObjInfo.interlayerNum = hitObjInfo.interlayerNum;
|
|
|
|
|
|
|
|
// 添加轻伤员
|
|
|
|
if (cloneObjType == CloneObjType.trappedPerson)
|
|
|
|
{
|
|
|
|
ReportDataMgr.AddTrappedPerson(clonedObj);
|
|
|
|
}
|
|
|
|
// 添加重伤员
|
|
|
|
if (cloneObjType == CloneObjType.wounded)
|
|
|
|
{
|
|
|
|
ReportDataMgr.AddWoundedPerson(clonedObj);
|
|
|
|
}
|
|
|
|
if (data.cloneObjType == CloneObjType.Leak1)
|
|
|
|
{
|
|
|
|
clonedObj.GetComponent<Leak1Controller>().OilTankId = hitObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
clonedObj.GetComponent<Leak1Controller>().Initialize(hitPoint, hitObj.GetComponent<OilTankMessage>());
|
|
|
|
}
|
|
|
|
if (data.cloneObjType == CloneObjType.Leak2)
|
|
|
|
{
|
|
|
|
clonedObj.GetComponent<Leak2Controller>().OilTankId = hitObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
clonedObj.GetComponent<Leak2Controller>().Initialize(hitPoint, hitObj.GetComponent<OilTankMessage>());
|
|
|
|
}
|
|
|
|
if (data.cloneObjType == CloneObjType.LiquidLevel)
|
|
|
|
{
|
|
|
|
clonedObj.GetComponent<FireLiquidLevelCtrl>().TargetNormalID = hitObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
}
|
|
|
|
if (data.cloneObjType == CloneObjType.ambulance
|
|
|
|
|| data.cloneObjType == CloneObjType.PoliceCar
|
|
|
|
|| data.cloneObjType == CloneObjType.PowerRepairVehicles
|
|
|
|
|| data.cloneObjType == CloneObjType.GasEmergencyCar
|
|
|
|
|| data.cloneObjType == CloneObjType.WaterSupplyRepairCar
|
|
|
|
|| data.cloneObjType == CloneObjType.Digger
|
|
|
|
|| data.cloneObjType == CloneObjType.Crane
|
|
|
|
|| data.cloneObjType == CloneObjType.TransportVehicle)
|
|
|
|
{
|
|
|
|
var namesp = clonedObj.name.Split('-');
|
|
|
|
string showName = data.cloneObjType.ToString() + "-" + namesp[namesp.Length - 1];
|
|
|
|
TheHeadName.GetInstance.CreateName(clonedObj.GetComponent<CloneGameObjInfo>().gameObjID, showName, cloneObjType.ToString(), 20, Vector3.up * 5);
|
|
|
|
}
|
|
|
|
//如果演练开始后增加火灾情,通知更改火堆信息
|
|
|
|
if (GameSettings.othersSettings.isStartDrill)
|
|
|
|
{
|
|
|
|
if (data.cloneObjType == CloneObjType.fireNormal)
|
|
|
|
{
|
|
|
|
MessageDispatcher.SendMessage("FireNormalNumChasnge", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if (data.cloneObjType==CloneObjType.WaterCannon)
|
|
|
|
//{
|
|
|
|
// MessageDispatcher.SendMessage("CreatWaterCannonNum");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//灾情库模式不同步
|
|
|
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
|
|
|
{
|
|
|
|
//克隆同步
|
|
|
|
CloneDisasterSyncData clonesync = new CloneDisasterSyncData();
|
|
|
|
clonesync.ClonePosition = clonedObjPos;
|
|
|
|
clonesync.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
//clonesync.parentUID =GetComponent<UIdSystem>().Id;
|
|
|
|
clonesync.name = clonedObj.name;
|
|
|
|
//clonesync.PrefabsPath = PrefabsPath + cloneObjType.ToString();
|
|
|
|
clonesync.floorNum = hitObjInfo.floorNum;
|
|
|
|
clonesync.buildNum = hitObjInfo.buildNum;
|
|
|
|
clonesync.interlayerNum = hitObjInfo.interlayerNum;
|
|
|
|
clonesync.gameObjID = clonedObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
clonesync.gameObjType = clonedObj.GetComponent<BaseGameObjInfo>().gameObjType;
|
|
|
|
clonesync.UserID = clonedObj.GetComponent<BaseGameObjInfo>().UserID;
|
|
|
|
clonesync.HitObjID = hitObjInfo.gameObjID;
|
|
|
|
clonesync.ForcibleType = data.ForcibleType;
|
|
|
|
//NetworkManager.Default.SendAsync(CurrentUserInfo.mySelf.Id,"CLONE_SINGLE_DISASTER_SYNC", clonesync);
|
|
|
|
NetworkManager.Default.SendAsync("CLONE_SINGLE_DISASTER_SYNC", clonesync);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|