Merge branch 'ui-overhaul'
This commit is contained in:
@@ -102,10 +102,12 @@ namespace Bootstrap
|
||||
if (CinematicsManager.Instance != null)
|
||||
{
|
||||
LogDebugMessage("Attempting to play intro cinematic");
|
||||
|
||||
|
||||
// Use LoadAndPlayCinematic to play the intro sequence
|
||||
CinematicsManager.Instance.LoadAndPlayCinematic("IntroSequence");
|
||||
|
||||
CinematicsManager.Instance.LoadAndPlayCinematic("IntroSequence", false);
|
||||
CinematicsManager.Instance.ChangeCinematicBackgroundColour(new Color(0f, 0f, 0f, 1f));
|
||||
//PlayerHudManager.Instance.ResizeCinematicPlayer();
|
||||
|
||||
// Immediately unload the StartingScene - no need to wait for cinematic to finish
|
||||
// since CinematicsManager is bootstrapped and won't be unloaded
|
||||
UnloadStartingScene();
|
||||
|
||||
@@ -81,28 +81,30 @@ namespace Cinematics
|
||||
// Initialize PlayableDirector if not set
|
||||
if (playableDirector == null)
|
||||
{
|
||||
playableDirector = GetComponent<PlayableDirector>();
|
||||
playableDirector = PlayerHudManager.Instance.playableDirector;
|
||||
|
||||
// If still null, try to add the component
|
||||
if (playableDirector == null)
|
||||
{
|
||||
playableDirector = gameObject.AddComponent<PlayableDirector>();
|
||||
Debug.Log("[CinematicsManager] Added missing PlayableDirector component");
|
||||
Debug.Log("[CinematicsManager] Could not find Playable Director on the PlayerHudManager");
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize _cinematicSprites if not set
|
||||
if (_cinematicSprites == null)
|
||||
{
|
||||
// First try to find in children
|
||||
_cinematicSprites = GetComponentInChildren<Image>(true);
|
||||
// First try to find in children in the PlayerHud
|
||||
_cinematicSprites = PlayerHudManager.Instance.cinematicSprites;
|
||||
|
||||
// If still null, create a new UI Image for cinematics
|
||||
// If still null, return error
|
||||
if (_cinematicSprites == null)
|
||||
{
|
||||
Debug.LogWarning("[CinematicsManager] No Image found for cinematics display. Cinematics may not display correctly.");
|
||||
}
|
||||
}
|
||||
|
||||
cinematicSpritesGameObject = PlayerHudManager.Instance.currentCinematicPlayer;
|
||||
cinematicBackground = PlayerHudManager.Instance.CinematicBackground;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,6 +120,7 @@ namespace Cinematics
|
||||
_cinematicSprites.enabled = true;
|
||||
cinematicSpritesGameObject.SetActive(true);
|
||||
}
|
||||
cinematicBackground.SetActive(true);
|
||||
|
||||
playableDirector.stopped += OnPlayableDirectorStopped;
|
||||
playableDirector.Play(assetToPlay);
|
||||
@@ -142,7 +145,7 @@ namespace Cinematics
|
||||
/// <summary>
|
||||
/// Loads a playable from an asset path and plays it as a cinematic
|
||||
/// </summary>
|
||||
public PlayableDirector LoadAndPlayCinematic(string key)
|
||||
public PlayableDirector LoadAndPlayCinematic(string key, bool playPortraitMode)
|
||||
{
|
||||
// Load the asset via addressables
|
||||
var handle = Addressables.LoadAssetAsync<PlayableAsset>(key);
|
||||
@@ -153,6 +156,7 @@ namespace Cinematics
|
||||
|
||||
Logging.Debug($"[CinematicsManager] Loaded addressable cinematic: {key}");
|
||||
|
||||
PlayerHudManager.Instance.SetPortraitMode(playPortraitMode);
|
||||
return PlayCinematic(result);
|
||||
}
|
||||
|
||||
@@ -198,7 +202,7 @@ namespace Cinematics
|
||||
|
||||
public void ShowCinematicBackground(bool shouldBeActive)
|
||||
{
|
||||
cinematicBackground.SetActive(shouldBeActive);
|
||||
cinematicBackground.SetActive(shouldBeActive);
|
||||
}
|
||||
|
||||
public void ShowGameOverScreen()
|
||||
@@ -218,5 +222,12 @@ namespace Cinematics
|
||||
Logging.Warning("[CinematicsManager] DivingGameOverScreen reference is not set!");
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeCinematicBackgroundColour(Color clr)
|
||||
{
|
||||
PlayerHudManager.Instance.cinematicBackgroundSprites.color = clr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using UI.Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Playables;
|
||||
using Svg;
|
||||
|
||||
namespace Minigames.DivingForPictures
|
||||
{
|
||||
@@ -627,8 +628,9 @@ namespace Minigames.DivingForPictures
|
||||
{
|
||||
//Instead of surfacingTimeline, play the outro cinematic
|
||||
deathAudioPlayer.Stop();
|
||||
CinematicsManager.Instance.LoadAndPlayCinematic("SurfacingCinematic");
|
||||
CinematicsManager.Instance.ShowCinematicBackground(true);
|
||||
CinematicsManager.Instance.LoadAndPlayCinematic("SurfacingCinematic",true);
|
||||
CinematicsManager.Instance.ChangeCinematicBackgroundColour(new Color(0.5058824f, 0.7803922f, 0.8862746f, 1f));
|
||||
//PlayerHudManager.Instance.ResizeCinematicPlayer();
|
||||
//surfacingTimeline.Play();
|
||||
//Logging.Debug("[DivingGameManager] Last tile left the screen, playing timeline");
|
||||
|
||||
|
||||
84
Assets/Scripts/UI/PlayerHudManager.cs
Normal file
84
Assets/Scripts/UI/PlayerHudManager.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/PlayerHudManager.cs.meta
Normal file
2
Assets/Scripts/UI/PlayerHudManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f97ef53b4012e4149b61bbd63c298b6f
|
||||
Reference in New Issue
Block a user