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.
99 lines
4.3 KiB
99 lines
4.3 KiB
4 years ago
|
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 override void Execute(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
var data = ((CloneCmdArgs)obj.Data);
|
||
|
if (data.cloneObjType == cloneObjType)
|
||
|
{
|
||
|
var hitPoint = data.hitPos;
|
||
|
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.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;
|
||
|
//NetworkManager.Default.SendAsync(CurrentUserInfo.mySelf.Id,"CLONE_SINGLE_DISASTER_SYNC", clonesync);
|
||
|
NetworkManager.Default.SendAsync("CLONE_SINGLE_DISASTER_SYNC", clonesync);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|