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().gameObjID,clonedObj.name,cloneObjType.ToString(), 20, Vector3.up * 5); //设置克隆物体所在楼层等基本属性,属性从点击的对象上获取 var hitObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID); CloneGameObjInfo hitObjInfo = hitObj.GetComponent(); CloneGameObjInfo cloneObjInfo = clonedObj.GetComponent(); cloneObjInfo.gameObjType = cloneObjType; cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id; cloneObjInfo.buildNum = hitObjInfo.buildNum; cloneObjInfo.floorNum = hitObjInfo.floorNum; cloneObjInfo.interlayerNum = hitObjInfo.interlayerNum; //clonedObj.GetComponent().MyCarMessage = new FireCarEngine() //{ // Id = (int)clonedObj.GetComponent().gameObjID, // Type = (int)cloneObjType //}; clonedObj.GetComponent().MyCarMessage = data.fireCarEngine; //添加到集结区可以监测的车辆列表 GameObject g = EntitiesManager.Instance.GetEntityByID(data.gameObjID); if (g.GetComponent()) { g.GetComponent().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); } } }