Cinematics and UI overhaul

This commit is contained in:
2025-11-07 16:47:10 +01:00
parent dfa42b2296
commit de2966fb1e
14 changed files with 1615 additions and 232 deletions

View File

@@ -79,10 +79,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();

View File

@@ -80,28 +80,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>
@@ -117,6 +119,7 @@ namespace Cinematics
_cinematicSprites.enabled = true;
cinematicSpritesGameObject.SetActive(true);
}
cinematicBackground.SetActive(true);
playableDirector.stopped += OnPlayableDirectorStopped;
playableDirector.Play(assetToPlay);
@@ -141,7 +144,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);
@@ -152,6 +155,7 @@ namespace Cinematics
Logging.Debug($"[CinematicsManager] Loaded addressable cinematic: {key}");
PlayerHudManager.Instance.SetPortraitMode(playPortraitMode);
return PlayCinematic(result);
}
@@ -197,7 +201,7 @@ namespace Cinematics
public void ShowCinematicBackground(bool shouldBeActive)
{
cinematicBackground.SetActive(shouldBeActive);
cinematicBackground.SetActive(shouldBeActive);
}
public void ShowGameOverScreen()
@@ -217,5 +221,12 @@ namespace Cinematics
Logging.Warning("[CinematicsManager] DivingGameOverScreen reference is not set!");
}
}
public void ChangeCinematicBackgroundColour(Color clr)
{
PlayerHudManager.Instance.cinematicBackgroundSprites.color = clr;
}
}
}

View File

@@ -14,6 +14,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");

View 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();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f97ef53b4012e4149b61bbd63c298b6f