using System.Collections; using System.Collections.Generic; using UnityEngine; public class TreeBud : MonoBehaviour { public List disActiveBud = new List(); public List ActiveBud = new List(); public int total_Progress; public int speed; [Header("Buff用")] public bool TreeBudActive = false; public float timeSub = 0; public int WoodProduceBuff = 1; public int budUpperLimit = 5; public bool buff_7_active = false; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (TreeBudActive) { StartCoroutine(BudAppear_IE()); TreeBudActive = false; } } public void BudAppear() { if(disActiveBud.Count > 0 && ActiveBud.Count< budUpperLimit) { int r = Random.Range(0, disActiveBud.Count); disActiveBud[r].GetComponent().Play("BudAppear"); disActiveBud[r].GetComponent().isActive = true; ActiveBud.Add(disActiveBud[r]); disActiveBud.RemoveAt(r); } } private IEnumerator BudAppear_IE() { int x = 0; BudAppear(); while (true) { if (x >= total_Progress/speed-timeSub) { BudAppear(); x = 0; } x++; yield return new WaitForSeconds(1f); } } }