62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TreeBud : MonoBehaviour
|
|
{
|
|
public List<Bud> disActiveBud = new List<Bud>();
|
|
public List<Bud> ActiveBud = new List<Bud>();
|
|
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<Animator>().Play("BudAppear");
|
|
|
|
disActiveBud[r].GetComponent<Bud>().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);
|
|
}
|
|
}
|
|
}
|