155 lines
4.1 KiB
C#
155 lines
4.1 KiB
C#
using Bootstrap;
|
|
using Cinematics;
|
|
using UnityEngine;
|
|
using Core;
|
|
using System;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Playables;
|
|
using Core.Lifecycle;
|
|
using JetBrains.Annotations;
|
|
|
|
public class PlayerHudManager : ManagedBehaviour
|
|
{
|
|
public enum UIMode { Overworld, Puzzle, Minigame, HideAll };
|
|
|
|
public UIMode currentUIMode;
|
|
private AppSwitcher _appSwitcher;
|
|
public GameObject landscapeObject;
|
|
public GameObject portraitObject;
|
|
public GameObject cinematicsParentObject;
|
|
public GameObject CinematicBackground;
|
|
public GameObject appSwitcher;
|
|
public GameObject eagleEye;
|
|
|
|
|
|
[HideInInspector] public Image cinematicSprites;
|
|
[HideInInspector] public Image cinematicBackgroundSprites;
|
|
|
|
[HideInInspector] public GameObject currentCinematicPlayer;
|
|
|
|
[HideInInspector] public PlayableDirector playableDirector;
|
|
|
|
|
|
|
|
private static PlayerHudManager _instance;
|
|
|
|
|
|
public static PlayerHudManager Instance => _instance;
|
|
private new void Awake()
|
|
{
|
|
base.Awake();
|
|
if (Instance != null)
|
|
{
|
|
Destroy(this);
|
|
return;
|
|
}
|
|
|
|
_instance = this;
|
|
|
|
InitializeReferences();
|
|
|
|
|
|
}
|
|
|
|
protected override void OnManagedAwake()
|
|
{
|
|
if (SceneManagerService.Instance != null)
|
|
{
|
|
SceneManagerService.Instance.SceneLoadCompleted += NewSceneLoaded;
|
|
}
|
|
if (SceneManagerService.Instance.CurrentGameplayScene == "AppleHillsOverworld")
|
|
{
|
|
NewSceneLoaded("AppleHillsOverworld");
|
|
}
|
|
if (SceneManagerService.Instance.CurrentGameplayScene == "StartingScene")
|
|
{
|
|
// TODO: Hide all UI until cinematics have played
|
|
NewSceneLoaded("AppleHillsOverworld");
|
|
}
|
|
|
|
}
|
|
|
|
private void InitializeReferences()
|
|
{
|
|
currentCinematicPlayer = landscapeObject;
|
|
playableDirector = cinematicsParentObject.GetComponent<PlayableDirector>();
|
|
cinematicSprites = currentCinematicPlayer.GetComponent<Image>();
|
|
cinematicBackgroundSprites = CinematicBackground.GetComponent<Image>();
|
|
}
|
|
|
|
private void UpateCinematicReferences(GameObject newCinematicPlayer)
|
|
{
|
|
currentCinematicPlayer = newCinematicPlayer;
|
|
cinematicSprites = currentCinematicPlayer.GetComponent<Image>();
|
|
}
|
|
|
|
public void SetPortraitMode(bool portraitModeEnable)
|
|
{
|
|
if (portraitModeEnable)
|
|
{
|
|
UpateCinematicReferences(portraitObject);
|
|
|
|
}
|
|
else
|
|
{
|
|
UpateCinematicReferences(landscapeObject);
|
|
}
|
|
}
|
|
|
|
public void NewSceneLoaded(string sceneName)
|
|
{
|
|
switch (sceneName)
|
|
{
|
|
case "AppleHillsOverworld":
|
|
UpdateUIMode(UIMode.Overworld);
|
|
break;
|
|
case "Quarry":
|
|
UpdateUIMode(UIMode.Puzzle);
|
|
break;
|
|
case "DivingForPictures":
|
|
UpdateUIMode(UIMode.Minigame);
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void UpdateUIMode(UIMode mode)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case UIMode.Overworld:
|
|
// Update currentUIMode var
|
|
currentUIMode = UIMode.Overworld;
|
|
// Show app switcher
|
|
appSwitcher.SetActive(true);
|
|
// Hide eagle eye
|
|
eagleEye.SetActive(false);
|
|
break;
|
|
case UIMode.Puzzle:
|
|
// Update currentUIMode var
|
|
currentUIMode = UIMode.Puzzle;
|
|
// Hide app switcher
|
|
appSwitcher.SetActive(false);
|
|
// show eagle eye
|
|
eagleEye.SetActive(true);
|
|
break;
|
|
case UIMode.Minigame:
|
|
// Update currentUIMode var
|
|
currentUIMode = UIMode.Minigame;
|
|
// Hide app switcher
|
|
appSwitcher.SetActive(false);
|
|
// Hide birds eye
|
|
eagleEye.SetActive(false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void ToggleAppSwitcher(bool boo)
|
|
{
|
|
appSwitcher.SetActive(boo);
|
|
}
|
|
|
|
|
|
}
|