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.
53 lines
2.3 KiB
53 lines
2.3 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ReplayWaterCannon : ReplaySimpleObject |
|
{ |
|
/// <summary> |
|
/// 回放克隆 |
|
/// </summary> |
|
/// <param name="json"></param> |
|
public override void CloneObject(string json) |
|
{ |
|
var jsonData = JsonUtility.FromJson<RecordWaterCannon>(json); |
|
var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, jsonData.myTransform.getMyPosition(), transform, long.Parse(jsonData.objectName)); |
|
clonedObj.name = jsonData.objectName;//名字即ID |
|
SetWaterCannon(clonedObj, jsonData); |
|
SetCloneGameObject(clonedObj, json); |
|
if (clonedObj.GetComponent<ObjSelectCtrl>()) |
|
{ |
|
clonedObj.GetComponent<ObjSelectCtrl>().SetSelect(json); |
|
} |
|
if (clonedObj.GetComponent<ObjDrag>()) |
|
{ |
|
clonedObj.GetComponent<ObjDrag>().enabled = jsonData.dragable; |
|
} |
|
} |
|
/// <summary> |
|
/// 设置基本属性 |
|
/// </summary> |
|
/// <param name="clonedObj"></param> |
|
/// <param name="jsonData"></param> |
|
public void SetWaterCannon(GameObject clonedObj, RecordWaterCannon jsonData) |
|
{ |
|
clonedObj.name = jsonData.objectName; |
|
clonedObj.transform.localRotation = jsonData.myTransform.getMyRotation(); |
|
clonedObj.transform.localPosition = jsonData.myTransform.getMyPosition(); |
|
clonedObj.transform.localScale = jsonData.myTransform.getMyScale(); |
|
SelectedObjs.gameObjs.Add(clonedObj); |
|
|
|
CloneGameObjInfo objMsg = clonedObj.GetComponent<CloneGameObjInfo>(); |
|
objMsg.gameObjType = jsonData.gameObjType; |
|
objMsg.buildNum = jsonData.buildNum; |
|
objMsg.floorNum = jsonData.floorNum; |
|
objMsg.interlayerNum = jsonData.interlayerNum; |
|
clonedObj.transform.Find("Rotate").localEulerAngles = jsonData.rotateRotation; |
|
clonedObj.transform.Find("Rotate/Head").localEulerAngles = jsonData.headRotation; |
|
clonedObj.GetComponent<WaterReceiver>().hasSupplier = jsonData.hasSupplier; |
|
clonedObj.SetActive(jsonData.isActive); |
|
clonedObj.GetComponent<ToolAttribute>().ReplayTask(jsonData.task); |
|
clonedObj.GetComponent<WaterCannonAttribute>().IsAutoSwing = jsonData.IsAutoSwing; |
|
clonedObj.GetComponent<WaterCannon>().SetWaterScale(jsonData.waterScale); |
|
} |
|
}
|
|
|