using System.Collections.Generic;
using UnityEngine;
namespace CinemaDirector
{
///
/// Plays through a list of given cutscenes one by one.
///
public class CutsceneQueue : MonoBehaviour
{
public List Cutscenes;
private int index = 0;
///
/// Play the first cutscene and waits for it to finish
///
void Start()
{
if (Cutscenes != null && Cutscenes.Count > 0)
{
Cutscenes[index].CutsceneFinished += CutsceneQueue_CutsceneFinished;
Cutscenes[index].Play();
}
}
///
/// On cutscene finish, play the next cutscene.
///
void CutsceneQueue_CutsceneFinished(object sender, CutsceneEventArgs e)
{
Cutscenes[index].CutsceneFinished -= CutsceneQueue_CutsceneFinished;
if (Cutscenes != null && index + 1 < Cutscenes.Count)
{
index++;
Cutscenes[index].Play();
Cutscenes[index].CutsceneFinished += CutsceneQueue_CutsceneFinished;
}
}
}
}