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.
77 lines
2.8 KiB
77 lines
2.8 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CloneWaterCannon : CloneSingleObj
|
||
|
{
|
||
|
public override void Awake()
|
||
|
{
|
||
|
cloneObjType = CloneObjType.WaterCannon;
|
||
|
ResourcesName = "Prefab/Tool/WaterCannon";
|
||
|
base.Awake();
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 添加初始状态记录
|
||
|
/// </summary>
|
||
|
/// <param name="list"></param>
|
||
|
public override void AddRecordFrame(List<ObjectData> list)
|
||
|
{
|
||
|
foreach (Transform child in transform)
|
||
|
{
|
||
|
var data = new RecordWaterCannon();
|
||
|
SetWaterCannonData(data, child);
|
||
|
string json = JsonUtility.ToJson(data);
|
||
|
var objectJson = new ObjectData();
|
||
|
objectJson.cloneObjType = cloneObjType;
|
||
|
objectJson.json = json;
|
||
|
list.Add(objectJson);
|
||
|
}
|
||
|
}
|
||
|
public void SetWaterCannonData(RecordWaterCannon data, Transform obj)
|
||
|
{
|
||
|
var msg = obj.GetComponent<CloneGameObjInfo>();
|
||
|
data.gameObjType = msg.gameObjType;
|
||
|
data.objectName = obj.gameObject.name;
|
||
|
data.hasSupplier = obj.GetComponent<WaterReceiver>().hasSupplier;
|
||
|
data.IsAutoSwing = obj.GetComponent<WaterCannonAttribute>().IsAutoSwing;
|
||
|
if (obj.GetComponent<ObjDrag>())
|
||
|
{
|
||
|
data.dragable = obj.GetComponent<ObjDrag>().enabled;
|
||
|
}
|
||
|
data.buildNum = msg.buildNum;
|
||
|
data.floorNum = msg.floorNum;
|
||
|
data.interlayerNum = msg.interlayerNum;
|
||
|
data.myTransform.setMyPosition(obj.localPosition);
|
||
|
data.myTransform.setMyRotation(obj.localRotation);
|
||
|
data.myTransform.setMyScale(obj.localScale);
|
||
|
data.rotateRotation = obj.Find("Rotate").localEulerAngles;
|
||
|
data.headRotation = obj.Find("Rotate/Head").localEulerAngles;
|
||
|
data.waterScale = obj.GetComponent<WaterCannon>().GetWaterScale();
|
||
|
data.isActive = obj.gameObject.activeSelf;
|
||
|
if (obj.GetComponent<ObjSelectCtrl>())
|
||
|
{
|
||
|
data.IsSelect = obj.GetComponent<ObjSelectCtrl>().selected;
|
||
|
}
|
||
|
data.task = obj.GetComponent<ToolAttribute>().task;
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 添加记录(克隆)
|
||
|
/// </summary>
|
||
|
public override void AddRecordEventClone(Transform obj)
|
||
|
{
|
||
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
|
||
|
{
|
||
|
var eventData = new EventData();
|
||
|
eventData.time = RecordManager.Instance.RecordTimer;
|
||
|
eventData.cloneObjType = cloneObjType;
|
||
|
eventData.eventType = RecordEventType.Clone;
|
||
|
var data = new RecordWaterCannon();
|
||
|
SetWaterCannonData(data, obj);
|
||
|
string json = JsonUtility.ToJson(data);
|
||
|
eventData.json = json;
|
||
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
||
|
}
|
||
|
}
|
||
|
}
|