using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class CanvasManager : MonoBehaviour { #region Singleton public static CanvasManager singleton; private void Awake() { if (singleton == null) { singleton = this; } else if (singleton != this) { Destroy(gameObject); } } #endregion [SerializeField] private float fadeDuration = 1f; public GameObject leftArrow; public GameObject rightArrow; public GameObject goBackArrow; public RawImage videoPlayerBackground; public GameObject videoSkipButton; public OptionsMenu optionsMenu; public GameObject titleScreen; public GameObject gameUiParent; public GameObject endingScreen; public LoadingScreen loadingScreen; public Fader fader; public ObjectZoomPanel objectZoomPanel; public WarningPanel warningPanel; public bool CanPlay => !titleScreen.activeSelf && !warningPanel.gameObject.activeSelf; void Start() { videoPlayerBackground.raycastTarget = false; gameUiParent.SetActive(false); titleScreen.SetActive(true); endingScreen.SetActive(false); loadingScreen.Show(0); warningPanel.gameObject.SetActive(false); } public void PressPlay() { GameManager.singleton.soundManager.PlayClickSound(); GameManager.singleton.OnPressPlay(); } public void StartGame() { titleScreen.SetActive(false); gameUiParent.SetActive(true); videoSkipButton.SetActive(false); videoPlayerBackground.raycastTarget = false; videoPlayerBackground.color = new Color(1, 1, 1, 0); } public void MoveLeft() { CameraManager.singleton.MoveLeft(); } public void MoveRight() { CameraManager.singleton.MoveRight(); } public void HideArrows() { leftArrow.SetActive(false); rightArrow.SetActive(false); } public void ShowArrows(bool enable = true) { leftArrow.SetActive(enable); rightArrow.SetActive(enable); gameUiParent.SetActive(enable); } public void EnterSubScene() { HideArrows(); goBackArrow.SetActive(true); } public void PlayVideo() { HideArrows(); goBackArrow.SetActive(false); videoPlayerBackground.raycastTarget = true; videoPlayerBackground.color = new Color(1, 1, 1, 1); } public void DisplaySkipButton() { videoSkipButton.SetActive(true); } public void SkipVideo() { CameraManager.singleton.StopVideo(); StopVideoUI(); } public void StopVideoUI() { videoPlayerBackground.raycastTarget = false; videoPlayerBackground.color = new Color(1, 1, 1, 0); videoSkipButton.SetActive(false); goBackArrow.SetActive(true); CameraManager.singleton.UpdateArrows(); } public void GoBackToMainScene() { GameManager.singleton.soundManager.PlayClickSound(); if (CameraManager.singleton.CurrentSubScene == null && !objectZoomPanel.gameObject.activeSelf) { GameManager.singleton.RestartGameWithWarning(); } else if (objectZoomPanel.gameObject.activeSelf) { objectZoomPanel.gameObject.SetActive(false); } else { CameraManager.singleton.MoveToMainScene(); } } public void DisplayEnding() { endingScreen.SetActive(true); } public void GoToEnding() { GameManager.singleton.soundManager.PlayClickSound(); CameraManager.singleton.GoToEnding(); endingScreen.SetActive(false); } public void Warning(string name, Action onYes, Action onNo = null) { warningPanel.OpenWarning(name, onYes, onNo); } }