using System; using System.Collections; using System.Collections.Generic; using AX.MessageSystem; using UnityEngine; using AX.InputSystem; using AX.NetworkSystem; /// /// 蔓延出来的火的克隆 /// [DisallowMultipleComponent] public class CloneSpreadedFire : MonoBehaviour { public GameObject clonePrefab;//绑定的预制体 public CloneObjType cloneObjType;//克隆类型 public virtual void OnEnable() { MessageDispatcher.AddListener("CLONE_SPREADEDFIRE_COMMAND", Execute); } public virtual void OnDisable() { MessageDispatcher.RemoveListener("CLONE_SPREADEDFIRE_COMMAND", Execute); } public virtual void OnDestroy() { MessageDispatcher.RemoveListener("CLONE_SPREADEDFIRE_COMMAND", Execute); } [SerializeField] [Tooltip("距离地面距离")] protected float Height = 0; public void Execute(IMessage obj) { var gameObjID = (long)obj.Sender; var data = ((CloneSpreadFireCmdArgs)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); //设置克隆物体所在楼层属性,属性从点击的对象上获取 CloneGameObjInfo cloneObjInfo = clonedObj.GetComponent(); cloneObjInfo.gameObjType = cloneObjType; cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id; cloneObjInfo.buildNum = data.parentFireBuildNum; cloneObjInfo.floorNum = data.parentFireFloorNum; cloneObjInfo.interlayerNum = data.parentFireInterlayerNum; clonedObj.GetComponent().fireGameObjID = data.parentFireGameObjID; //蔓延火同步,灾情库模式不同步 if (GameSettings.othersSettings.mode!=Mode.DisasterManagement) { CloneDisasterSyncData clonesync = new CloneDisasterSyncData(); clonesync.ClonePosition = clonedObjPos; clonesync.SendUserID = CurrentUserInfo.mySelf.Id; clonesync.name = clonedObj.name; clonesync.floorNum = data.parentFireFloorNum; clonesync.buildNum = data.parentFireBuildNum; clonesync.interlayerNum = data.parentFireInterlayerNum; clonesync.gameObjID = clonedObj.GetComponent().gameObjID; clonesync.gameObjType = clonedObj.GetComponent().gameObjType; clonesync.UserID = clonedObj.GetComponent().UserID; NetworkManager.Default.SendAsync("CLONE_SINGLE_DISASTER_SYNC", clonesync); } } } }