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.
78 lines
3.0 KiB
78 lines
3.0 KiB
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 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<CloneGameObjInfo>(); |
|
cloneObjInfo.gameObjType = cloneObjType; |
|
cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id; |
|
cloneObjInfo.buildNum = data.parentFireBuildNum; |
|
cloneObjInfo.floorNum = data.parentFireFloorNum; |
|
cloneObjInfo.interlayerNum = data.parentFireInterlayerNum; |
|
clonedObj.GetComponent<SpreadedFireCtrl>().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<BaseGameObjInfo>().gameObjID; |
|
clonesync.gameObjType = clonedObj.GetComponent<BaseGameObjInfo>().gameObjType; |
|
clonesync.UserID = clonedObj.GetComponent<BaseGameObjInfo>().UserID; |
|
NetworkManager.Default.SendAsync("CLONE_SINGLE_DISASTER_SYNC", clonesync); |
|
} |
|
|
|
} |
|
} |
|
}
|
|
|