mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-12-01 01:18:00 +01:00
40 lines
No EOL
1.2 KiB
C#
40 lines
No EOL
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace CinemaDirector
|
|
{
|
|
/// <summary>
|
|
/// Plays through a list of given cutscenes one by one.
|
|
/// </summary>
|
|
public class CutsceneQueue : MonoBehaviour
|
|
{
|
|
public List<Cutscene> Cutscenes;
|
|
private int index = 0;
|
|
|
|
/// <summary>
|
|
/// Play the first cutscene and waits for it to finish
|
|
/// </summary>
|
|
void Start()
|
|
{
|
|
if (Cutscenes != null && Cutscenes.Count > 0)
|
|
{
|
|
Cutscenes[index].CutsceneFinished += CutsceneQueue_CutsceneFinished;
|
|
Cutscenes[index].Play();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// On cutscene finish, play the next cutscene.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
} |