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(); } void Update() { if (oil.nodeValue >= oil.nodeYMax && !ranYouIsStart) { ranYouIsStart = true; RanYouControl(); } //if (GetComponent().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()) ranyou.gameObject.AddComponent(); ranyou.GetComponent().oilSpred = true; } [SerializeField] private float flowSpeed = 2; int i = 0;//火焰的索引 public GameObject[] fireflow; public GameObject fireDiffusion; /// /// 开启火的流淌 /// /// 火特效 /// 延迟执行 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()) fireObj.AddComponent(); FireFlow fire = fireObj.GetComponent(); fire.flowSpeed = flowSpeed;//设置火焰蔓延速度 fire.fireFlow = true;//开始蔓延 if (i < fireflow.Length)//开启全部火焰 StartCoroutine(FireFlow(fireflow[i++], i / (Time.deltaTime * fire.flowSpeed * 10))); } }