rabidus-test/Assets/CutsceneController.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2023-07-28 11:48:57 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
public class CutsceneController : MonoBehaviour
{
private ShipMoveSides _shipMoveSides;
private PreviewModule _previewModule;
[Header("Cutscene Settings")]
[SerializeField]
public PlayableDirector _cutscene;
[SerializeField]
private float _cutsceneAfterDelay = 1.4f;
private void Awake()
{
_shipMoveSides = FindObjectOfType<ShipPathFollower>().GetComponent<ShipMoveSides>();
2023-07-28 11:48:57 +03:00
_previewModule = FindObjectOfType<PreviewModule>();
}
public void ShowCutscene()
{
StartCoroutine(CutsceneCoroutine());
}
private IEnumerator CutsceneCoroutine()
{
_shipMoveSides.ToggleInput(false);
_previewModule.TogglePanel(true);
_cutscene.Play();
yield return new WaitForSeconds((float)_cutscene.duration + _cutsceneAfterDelay);
_shipMoveSides.ToggleInput(true);
_previewModule.TogglePanel(false);
}
}