曹衍涛
4 years ago
16 changed files with 507 additions and 67 deletions
Binary file not shown.
Binary file not shown.
@ -1,8 +1,85 @@
|
||||
using System.Collections; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
|
||||
[Serializable] |
||||
public class SpreadFireCreatData //蔓延出来的火的创建 |
||||
{ |
||||
public long sourceId; |
||||
public string name; |
||||
public Vector3 position;//位置 |
||||
public Vector3 eulerAngles;//旋转 |
||||
public Vector3 scale;//缩放 |
||||
|
||||
public string buildNum;//楼号 |
||||
public int floorNum;//层号 |
||||
public int interlayerNum;//夹层号,0表示不是夹层,1表示第一个夹层 |
||||
public int Layer; |
||||
|
||||
} |
||||
[Serializable] |
||||
public class SpreadFireDestoryData//蔓延出来的火的删除 |
||||
{ |
||||
public long sourceId; |
||||
public string name; |
||||
} |
||||
public class SpreadFire : CloneGameObjInfo |
||||
{ |
||||
public long SourceId; |
||||
public void AddRecordDataCreat(GameObject sourceObj) |
||||
{ |
||||
SourceId = sourceObj.GetComponent<CloneGameObjInfo>().gameObjID; |
||||
GetComponent<CloneGameObjInfo>().buildNum = sourceObj.GetComponent<CloneGameObjInfo>().buildNum;//楼号 |
||||
GetComponent<CloneGameObjInfo>().floorNum = sourceObj.GetComponent<CloneGameObjInfo>().floorNum;//层号 |
||||
GetComponent<CloneGameObjInfo>().interlayerNum = sourceObj.GetComponent<CloneGameObjInfo>().interlayerNum;//夹层号,0表示不是夹层,1表示第一个夹层 |
||||
GetComponent<CloneGameObjInfo>().Layer = sourceObj.GetComponent<CloneGameObjInfo>().Layer; |
||||
|
||||
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
||||
{ |
||||
SpreadFireCreatData data = new SpreadFireCreatData(); |
||||
data.name = gameObject.name; |
||||
data.sourceId = SourceId; |
||||
data.position = transform.localPosition; |
||||
data.eulerAngles = transform.localRotation.eulerAngles; |
||||
data.scale = transform.localScale; |
||||
data.buildNum = sourceObj.GetComponent<CloneGameObjInfo>().buildNum;//楼号 |
||||
data.floorNum = sourceObj.GetComponent<CloneGameObjInfo>().floorNum;//层号 |
||||
data.interlayerNum = sourceObj.GetComponent<CloneGameObjInfo>().interlayerNum;//夹层号,0表示不是夹层,1表示第一个夹层 |
||||
data.Layer = sourceObj.GetComponent<CloneGameObjInfo>().Layer; |
||||
|
||||
var eventData = new EventData(); |
||||
eventData.time = RecordManager.Instance.RecordTimer; |
||||
eventData.cloneObjType = CloneObjType.None; |
||||
eventData.eventType = RecordEventType.SpreadFireCreat; |
||||
eventData.json = Newtonsoft.Json.JsonConvert.SerializeObject(data); |
||||
|
||||
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
||||
} |
||||
//if (sourceObj.layer == LayerMask.NameToLayer("Hidden"))//蔓延出来的火如果主火隐藏 |
||||
//{ |
||||
// gameObject.layer = LayerMask.NameToLayer("Hidden"); |
||||
// foreach (Transform child in transform) |
||||
// { |
||||
// child.gameObject.layer = LayerMask.NameToLayer("Hidden"); |
||||
// } |
||||
//} |
||||
} |
||||
public void AddRecordDataDestroy() |
||||
{ |
||||
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
||||
{ |
||||
SpreadFireDestoryData data = new SpreadFireDestoryData(); |
||||
data.name = gameObject.name; |
||||
data.sourceId = SourceId; |
||||
var eventData = new EventData(); |
||||
eventData.time = RecordManager.Instance.RecordTimer; |
||||
eventData.cloneObjType = CloneObjType.None; |
||||
eventData.eventType = RecordEventType.SpreadFireDestory; |
||||
eventData.json = Newtonsoft.Json.JsonConvert.SerializeObject(data); |
||||
|
||||
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,135 @@
|
||||
using AX.MessageSystem; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
[Serializable] |
||||
public class SpreadFireData |
||||
{ |
||||
public long sourceId; |
||||
public string name; |
||||
public Vector3 position;//位置 |
||||
public Vector3 eulerAngles;//旋转 |
||||
public Vector3 scale;//缩放 |
||||
|
||||
public string buildNum;//楼号 |
||||
public int floorNum;//层号 |
||||
public int interlayerNum;//夹层号,0表示不是夹层,1表示第一个夹层 |
||||
public int Layer; |
||||
public string UserId; |
||||
} |
||||
[Serializable] |
||||
public class SpreadFireRecordData//蔓延出来的火的帧数据 |
||||
{ |
||||
public List<SpreadFireData> spreadFiredataList = new List<SpreadFireData>(); |
||||
} |
||||
public class SpreadFireManager : MonoBehaviour |
||||
{ |
||||
public static SpreadFireManager Instance; |
||||
public GameObject firePrefab; |
||||
private void Awake() |
||||
{ |
||||
Instance = this; |
||||
} |
||||
void Start() |
||||
{ |
||||
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameData); |
||||
MessageDispatcher.AddListener("ReplayEvent", ReplayEventData); |
||||
} |
||||
|
||||
public SpreadFireRecordData GetFrameData() |
||||
{ |
||||
SpreadFireRecordData recordData = new SpreadFireRecordData(); |
||||
foreach (Transform item in transform) |
||||
{ |
||||
SpreadFireData data = new SpreadFireData(); |
||||
data.name = item.name; |
||||
data.sourceId = item.GetComponent<SpreadFire>().SourceId; |
||||
data.position = item.localPosition; |
||||
data.eulerAngles = item.localRotation.eulerAngles; |
||||
data.scale = item.localScale; |
||||
data.buildNum = item.GetComponent<CloneGameObjInfo>().buildNum;//楼号 |
||||
data.floorNum = item.GetComponent<CloneGameObjInfo>().floorNum;//层号 |
||||
data.interlayerNum = item.GetComponent<CloneGameObjInfo>().interlayerNum;//夹层号,0表示不是夹层,1表示第一个夹层 |
||||
data.Layer = item.GetComponent<CloneGameObjInfo>().Layer; |
||||
recordData.spreadFiredataList.Add(data); |
||||
} |
||||
return recordData; |
||||
} |
||||
|
||||
private void ReplayFrameData(IMessage obj) |
||||
{ |
||||
var baseData = (ObjectData)obj.Data; |
||||
if (baseData.cloneObjType == CloneObjType.SpreadFireFrame) |
||||
{ |
||||
ClearObject(); |
||||
SpreadFireRecordData data = Newtonsoft.Json.JsonConvert.DeserializeObject<SpreadFireRecordData>(baseData.json); |
||||
if (data.spreadFiredataList.Count > 0) |
||||
{ |
||||
foreach (var item in data.spreadFiredataList) |
||||
{ |
||||
GameObject spreadfire = Instantiate(firePrefab, transform); |
||||
spreadfire.name = item.name; |
||||
spreadfire.transform.localPosition = item.position; |
||||
spreadfire.transform.localRotation = Quaternion.Euler |
||||
(item.eulerAngles.x, item.eulerAngles.y, item.eulerAngles.z) * Quaternion.identity; |
||||
spreadfire.transform.localScale = item.scale; |
||||
spreadfire.GetComponent<SpreadFire>().SourceId = item.sourceId; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().buildNum = item.buildNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().floorNum = item.floorNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().interlayerNum = item.interlayerNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().Layer = item.Layer; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void ClearObject() |
||||
{ |
||||
foreach (Transform item in transform) |
||||
{ |
||||
Destroy(item.gameObject); |
||||
} |
||||
} |
||||
|
||||
private void ReplayEventData(IMessage obj) |
||||
{ |
||||
var baseEventData = (EventData)obj.Data; |
||||
if (baseEventData.eventType == RecordEventType.SpreadFireCreat) |
||||
{ |
||||
SpreadFireCreatData data = Newtonsoft.Json.JsonConvert.DeserializeObject<SpreadFireCreatData>(baseEventData.json); |
||||
GameObject spreadfire = Instantiate(firePrefab, transform); |
||||
spreadfire.name = data.name; |
||||
spreadfire.transform.localPosition = data.position; |
||||
spreadfire.transform.localRotation = Quaternion.Euler |
||||
(data.eulerAngles.x, data.eulerAngles.y, data.eulerAngles.z) * Quaternion.identity; |
||||
spreadfire.transform.localScale = data.scale; |
||||
spreadfire.GetComponent<SpreadFire>().SourceId = data.sourceId; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().buildNum = data.buildNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().floorNum = data.floorNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().interlayerNum = data.interlayerNum; |
||||
spreadfire.GetComponent<CloneGameObjInfo>().Layer = data.Layer; |
||||
} |
||||
else if (baseEventData.eventType == RecordEventType.SpreadFireDestory) |
||||
{ |
||||
foreach (Transform item in transform) |
||||
{ |
||||
if (item.GetComponent<SpreadFire>()) |
||||
{ |
||||
SpreadFireDestoryData data = (SpreadFireDestoryData)obj.Data; |
||||
if (item.GetComponent<SpreadFire>().SourceId == data.sourceId) |
||||
{ |
||||
Destroy(item.gameObject); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void OnDestroy() |
||||
{ |
||||
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventData); |
||||
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameData); |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4e6684051a4af9c4c98aaf06d09e77d9 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Loading…
Reference in new issue