上海东方渔人码头电子沙盘单机版
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.
 
 
 
 

67 lines
2.0 KiB

using UnityEngine;
using System.Collections;
public class OilFlowManage : MonoBehaviour
{
private OilReveal oil;
[SerializeField]
private float FlowLateTime = 20;
void Start()
{
oil = this.transform.Find("Oil").GetComponent<OilReveal>();
}
void Update()
{
if (oil.nodeValue >= oil.nodeYMax && !ranYouIsStart)
{
ranYouIsStart = true;
RanYouControl();
}
//if (GetComponent<Leak1Controller>().CatchFire)
//{
// if (i < fireflow.Length)
// StartCoroutine(FireFlow(fireflow[i++], FlowLateTime));
//}
}
void DelaySet()
{
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + 3);
}
private bool ranYouIsStart;
private void RanYouControl()
{
var ranyou = transform.Find("BottomOil");
if (!ranyou.GetComponent<OilSpread>())
ranyou.gameObject.AddComponent<OilSpread>();
ranyou.GetComponent<OilSpread>().oilSpred = true;
}
[SerializeField]
private float flowSpeed = 2;
int i = 0;//火焰的索引
public GameObject[] fireflow;
public GameObject fireDiffusion;
/// <summary>
/// 开启火的流淌
/// </summary>
/// <param name="fireObj">火特效</param>
/// <param name="lateTime">延迟执行</param>
private IEnumerator FireFlow(GameObject fireObj, float lateTime)
{
yield return new WaitForSeconds(lateTime);
if (fireDiffusion)
fireDiffusion.SetActive(true);
if (fireObj)
fireObj.SetActive(true);
if (!fireObj.GetComponent<FireFlow>())
fireObj.AddComponent<FireFlow>();
FireFlow fire = fireObj.GetComponent<FireFlow>();
fire.flowSpeed = flowSpeed;//设置火焰蔓延速度
fire.fireFlow = true;//开始蔓延
if (i < fireflow.Length)//开启全部火焰
StartCoroutine(FireFlow(fireflow[i++], i / (Time.deltaTime * fire.flowSpeed * 10)));
}
}