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.
148 lines
6.1 KiB
148 lines
6.1 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ReplayFireBase : ReplaySimpleObject
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 回放克隆
|
||
|
/// </summary>
|
||
|
/// <param name="json"></param>
|
||
|
public override void CloneObject(string json)
|
||
|
{
|
||
|
var jsonData = JsonUtility.FromJson<FireSpreadData>(json);
|
||
|
var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, jsonData.myTransform.getMyPosition(), transform, long.Parse(jsonData.objectName));
|
||
|
clonedObj.name = jsonData.objectName;//名字即ID
|
||
|
SetBaseGameObject(clonedObj, jsonData);
|
||
|
SetCloneGameObject(clonedObj, json);
|
||
|
SetSpreadFire(clonedObj, jsonData);
|
||
|
SetFireTemperatureRadiation(clonedObj, jsonData);
|
||
|
}
|
||
|
|
||
|
private void SetFireTemperatureRadiation(GameObject clonedObj, FireSpreadData data)
|
||
|
{
|
||
|
if (clonedObj.name == data.name)
|
||
|
{
|
||
|
FireControl ctrl = clonedObj.GetComponent<FireControl>();
|
||
|
ctrl.MyData.temperature = data.temperature;
|
||
|
ctrl.MyData.radiation = data.radiation;
|
||
|
ctrl.MyData.rsw = data.rsw;
|
||
|
ctrl.MyData.pos = data.pos;
|
||
|
ctrl.SetTemperatureText();
|
||
|
ctrl.SetRadiationText();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SetSpreadFire(GameObject clonedObj, FireSpreadData data)
|
||
|
{
|
||
|
if (clonedObj.name == data.name)
|
||
|
{
|
||
|
FireSpreadCtrl ctrl = clonedObj.GetComponent<FireSpreadCtrl>();
|
||
|
ctrl.straightSpread = data.straightSpread;
|
||
|
ctrl.areaSpread = data.areaSpread;
|
||
|
ctrl.aroundSpread = data.aroundSpread;
|
||
|
ctrl.startTime = data.startTime;
|
||
|
ctrl.spreadSpeed = data.spreadSpeed;
|
||
|
ctrl.repeatRate = data.repeatRate;
|
||
|
ctrl.spreadFirePositions = data.spreadFirePositions;
|
||
|
//ctrl.spdFirePositions = data.spdFirePositions;
|
||
|
if (data.spdFirePositions.Count > 0)
|
||
|
{
|
||
|
ctrl.spdFirePositions.Clear();
|
||
|
foreach (var item in data.spdFirePositions)
|
||
|
{
|
||
|
ctrl.spdFirePositions.Add(item.postions);
|
||
|
}
|
||
|
}
|
||
|
ctrl.isSpreading = data.isSpreading;
|
||
|
ctrl.index = data.index;
|
||
|
if (data.hasSpreadPos.Count > 0)
|
||
|
{
|
||
|
if (ctrl.fire == null)
|
||
|
{
|
||
|
ctrl.fire = Resources.Load<GameObject>("Prefab/Diaster/FireSpread");
|
||
|
}
|
||
|
if (data.hasSpreadPos.Count > 0)
|
||
|
{
|
||
|
int index = 1;
|
||
|
foreach (var pos in data.hasSpreadPos)
|
||
|
{
|
||
|
GameObject spreadFire = Instantiate(ctrl.fire, pos, Quaternion.identity,
|
||
|
GameObject.Find("P_AllParent").transform.Find("P_Disaster/P_SpreadFire")) as GameObject;
|
||
|
var spreadedFire = spreadFire.GetComponent<SpreadFire>();
|
||
|
spreadedFire.SourceId = ctrl.GetComponent<CloneGameObjInfo>().GameObjID;
|
||
|
if (data.straightSpread)
|
||
|
spreadFire.name = "straightSpread" + (index - 1);
|
||
|
else if (data.areaSpread)
|
||
|
spreadFire.name = "areaSpread" + (index - 1);
|
||
|
else
|
||
|
spreadFire.name = "aroundSpread" + (index - 1);
|
||
|
index++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (data.isSpreading && ReplaySetting.PlayStatus != PlayStatus.isReplay)
|
||
|
{
|
||
|
StartCoroutine(ctrl.WaitForStart(data.startTime));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//public override void SetProperties(ObjectData objectData)
|
||
|
//{
|
||
|
// base.SetProperties(objectData);
|
||
|
// if (objectData.cloneObjType == CloneObjType.SpreadFire)
|
||
|
// {
|
||
|
// FireSpreadData data = JsonUtility.FromJson<FireSpreadData>(objectData.json);
|
||
|
// foreach (Transform item in transform)
|
||
|
// {
|
||
|
// if (item.name == data.name)
|
||
|
// {
|
||
|
// FireSpreadCtrl ctrl = item.GetComponent<FireSpreadCtrl>();
|
||
|
// ctrl.straightSpread = data.straightSpread;
|
||
|
// ctrl.areaSpread = data.areaSpread;
|
||
|
// ctrl.areaSpread = data.aroundSpread;
|
||
|
// ctrl.startTime = data.startTime;
|
||
|
// ctrl.spreadSpeed = data.spreadSpeed;
|
||
|
// ctrl.repeatRate = data.repeatRate;
|
||
|
// ctrl.spreadFirePositions = data.spreadFirePositions;
|
||
|
// ctrl.spdFirePositions = data.spdFirePositions;
|
||
|
// ctrl.isSpreading = data.isSpreading;
|
||
|
// ctrl.index = data.index;
|
||
|
// if (data.hasSpreadPos.Count > 0)
|
||
|
// {
|
||
|
// if (ctrl.fire == null)
|
||
|
// {
|
||
|
// ctrl.fire = Resources.Load<GameObject>("Prefab/Diaster/FireSpread");
|
||
|
// }
|
||
|
// foreach (var pos in data.hasSpreadPos)
|
||
|
// {
|
||
|
// GameObject spreadFire = Instantiate(ctrl.fire, pos, Quaternion.identity,
|
||
|
// GameObject.Find("P_AllParent").transform.Find("P_Disaster/P_SpreadFire")) as GameObject;
|
||
|
// var spreadedFire = spreadFire.GetComponent<SpreadFire>();
|
||
|
// spreadedFire.SourceId = ctrl.GetComponent<CloneGameObjInfo>().GameObjID;
|
||
|
// }
|
||
|
// }
|
||
|
// if (data.isSpreading)
|
||
|
// {
|
||
|
// StartCoroutine(ctrl.WaitForStart(data.startTime));
|
||
|
// }
|
||
|
// break;
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
public override void Clear(IMessage obj)
|
||
|
{
|
||
|
base.Clear(obj);
|
||
|
Transform pfire = GameObject.Find("P_AllParent").transform.Find("P_Disaster/P_SpreadFire");
|
||
|
if (pfire.childCount > 0)
|
||
|
foreach (Transform child in pfire)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
}
|
||
|
}
|