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

public class Timeline : MonoBehaviour
{
    [Serializable]
    public class TimelineEvent
    {
        public float waitSeconds;
        public UnityEvent unityEvent;
    }

    [SerializeField]
    private List<TimelineEvent> _events;
    
    private void Start()
    {
        StartCoroutine(PlayTimeline());
    }
    
    private IEnumerator PlayTimeline()
    {
        foreach (var timelineEvent in _events)
        {
            yield return new WaitForSeconds(timelineEvent.waitSeconds);
            timelineEvent.unityEvent.Invoke();
        }
    }
}
