using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class MyWaveGroupList
{
    public GameObject wave;
    public float delay;
}


public class MyWaveGroupController : MonoBehaviour
{
    public MyWaveGroupList[] waveGroupList;

    private void Awake()
    {
        //ĬϷ
        //Ȼʱ˾ͺ飬debug
        for (int i = 0; i < transform.childCount; i++)
        {
            transform.GetChild(i).gameObject.SetActive(false);
        }
    }

    //Э̴
    void Start()
    {
        for (int i = 0; i < waveGroupList.Length; i++)
        {
            StartCoroutine(CreateMyWaveGroup(waveGroupList[i].delay, waveGroupList[i].wave));
            //Debug.Log(waveGroupList[i].delay);
        }
    }
    //˾
    private void Update()
    {
        if (transform.childCount == 0)
        {
            Destroy(gameObject);
        }
    }
    //Э̴
    IEnumerator CreateMyWaveGroup(float delay, GameObject Wave)
    {
        if (delay != 0)
        {
            yield return new WaitForSeconds(delay);
        }
        Wave.SetActive(true);
    }
}
