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.
74 lines
3.0 KiB
74 lines
3.0 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using AX.MessageSystem; |
|
using UnityEngine; |
|
using AX.InputSystem; |
|
using AX.NetworkSystem; |
|
|
|
public class CloneCar : CloneBase |
|
{ |
|
[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); |
|
TheHeadName.GetInstance.CreateName(clonedObj.GetComponent<CloneGameObjInfo>().gameObjID,clonedObj.name,cloneObjType.ToString(), 20, Vector3.up * 5); |
|
|
|
//设置克隆物体所在楼层等基本属性,属性从点击的对象上获取 |
|
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; |
|
|
|
//clonedObj.GetComponent<TruckMessage>().MyCarMessage = new FireCarEngine() |
|
//{ |
|
// Id = (int)clonedObj.GetComponent<BaseGameObjInfo>().gameObjID, |
|
// Type = (int)cloneObjType |
|
//}; |
|
clonedObj.GetComponent<TruckMessage>().MyCarMessage = data.fireCarEngine; |
|
|
|
//添加到集结区可以监测的车辆列表 |
|
GameObject g = EntitiesManager.Instance.GetEntityByID(data.gameObjID); |
|
if (g.GetComponent<CarMoveOutController>()) |
|
{ |
|
g.GetComponent<CarMoveOutController>().Cars.Add(clonedObj); |
|
} |
|
//同步克隆车辆 |
|
CloneSyncCarData cloneData = new CloneSyncCarData() |
|
{ |
|
BuildNum = cloneObjInfo.buildNum, |
|
CarMessage = data.fireCarEngine, |
|
CloneID = cloneObjInfo.GameObjID, |
|
CloneName = clonedObj.name, |
|
ClonePosition = clonedObjPos, |
|
CloneType = cloneObjType, |
|
FloorNum = cloneObjInfo.floorNum, |
|
InterLayerNum = cloneObjInfo.interlayerNum, |
|
UserID = cloneObjInfo.UserID |
|
}; |
|
NetworkManager.Default.SendAsync("CLONE_CAR_SYNC", cloneData); |
|
|
|
// 添加到报告 |
|
ReportDataMgr.AddTruckObj(clonedObj); |
|
} |
|
|
|
} |
|
}
|
|
|