85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
|
|
using Bootstrap;
|
||
|
|
using Cinematics;
|
||
|
|
using UnityEngine;
|
||
|
|
using Core;
|
||
|
|
using System;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using UnityEngine.Playables;
|
||
|
|
|
||
|
|
public class PlayerHudManager : MonoBehaviour
|
||
|
|
{
|
||
|
|
private AppSwitcher _appSwitcher;
|
||
|
|
public GameObject landscapeObject;
|
||
|
|
public GameObject portraitObject;
|
||
|
|
public GameObject cinematicsParentObject;
|
||
|
|
public GameObject CinematicBackground;
|
||
|
|
|
||
|
|
[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 void Awake()
|
||
|
|
{
|
||
|
|
if (Instance != null)
|
||
|
|
{
|
||
|
|
Destroy(this);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
_instance = this;
|
||
|
|
|
||
|
|
// Register for post-boot initialization
|
||
|
|
BootCompletionService.RegisterInitAction(InitializePostBoot);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void InitializeReferences()
|
||
|
|
{
|
||
|
|
cinematicSprites = currentCinematicPlayer.GetComponent<Image>();
|
||
|
|
cinematicBackgroundSprites = CinematicBackground.GetComponent<Image>();
|
||
|
|
playableDirector = cinematicsParentObject.GetComponent<PlayableDirector>();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void InitializePostBoot()
|
||
|
|
{
|
||
|
|
// Initialize any dependencies that require other services to be ready
|
||
|
|
// For example, subscribe to SceneManagerService events if needed
|
||
|
|
|
||
|
|
|
||
|
|
Logging.Debug("[PlayerHudManager] Post-boot initialization complete");
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnEnable()
|
||
|
|
{
|
||
|
|
// Subscribe to application quit event to ensure cleanup
|
||
|
|
Application.quitting += OnApplicationQuit;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnApplicationQuit()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetPortraitMode(bool portraitModeEnable)
|
||
|
|
{
|
||
|
|
if (portraitModeEnable)
|
||
|
|
{
|
||
|
|
currentCinematicPlayer = portraitObject;
|
||
|
|
InitializeReferences();
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
currentCinematicPlayer = landscapeObject;
|
||
|
|
InitializeReferences();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|