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.
64 lines
1.8 KiB
64 lines
1.8 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
[RequireComponent(typeof(CloneBase))] |
|
public abstract class ReplayBase : MonoBehaviour |
|
{ |
|
|
|
protected CloneBase cloneBase; |
|
// Use this for initialization |
|
public virtual void Start() |
|
{ |
|
cloneBase = GetComponent<CloneBase>(); |
|
MessageDispatcher.AddListener("ClearObject", Clear); |
|
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameClone); |
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventClone); |
|
} |
|
public virtual void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("ClearObject", Clear); |
|
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameClone); |
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventClone); |
|
} |
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
|
|
public void ReplayFrameClone(IMessage obj) |
|
{ |
|
var item = (ObjectData)obj.Data; |
|
if (item.cloneObjType == cloneBase.cloneObjType) |
|
{ |
|
if (cloneBase.clonePrefab != null) |
|
{ |
|
CloneObject(item.json); |
|
} |
|
} |
|
} |
|
public abstract void CloneObject(string json); |
|
private void ReplayEventClone(IMessage obj) |
|
{ |
|
var item = (EventData)obj.Data; |
|
if (item.cloneObjType == cloneBase.cloneObjType && item.eventType == RecordEventType.Clone) |
|
{ |
|
CloneObject(item.json); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 清空父对象下所有物体 |
|
/// </summary> |
|
/// <param name="obj"></param> |
|
public virtual void Clear(IMessage obj) |
|
{ |
|
foreach (Transform child in transform) |
|
{ |
|
EntitiesManager.Instance.DeleteObj(child.gameObject); |
|
} |
|
} |
|
}
|
|
|