Fix hud issues and have rainbow play correctly

This commit is contained in:
Michal Pikulski
2025-11-09 22:40:58 +01:00
parent e9855faede
commit 6f515e954d
6 changed files with 938 additions and 123 deletions

View File

@@ -11,9 +11,8 @@ using UI;
public class AppSwitcher : UIPage
{
public TextAsset rainbowEstablish;
public TextAsset rainbowRemove;
public GameObject rainbow;
public GameObject rainbowIn;
public GameObject rainbowOut;
public GameObject gameLayoutContainer;
public GameObject exitButton;
public RectMask2D rectMask;
@@ -21,7 +20,8 @@ public class AppSwitcher : UIPage
[Header("Slide Animation Settings")]
public float slideDuration = 0.5f;
private SkottiePlayerV2 rainbowPlayer;
private SkottiePlayerV2 rainbowInPlayer;
private SkottiePlayerV2 rainbowOutPlayer;
private TweenBase slideInTween;
private TweenBase slideOutTween;
@@ -30,51 +30,56 @@ public class AppSwitcher : UIPage
base.OnManagedAwake();
PageName = "AppSwitcher";
rainbowPlayer = rainbow.GetComponentInChildren<SkottiePlayerV2>();
rainbowInPlayer = rainbowIn.GetComponent<SkottiePlayerV2>();
rainbowOutPlayer = rainbowOut.GetComponent<SkottiePlayerV2>();
if (rectMask == null)
{
rectMask = GetComponent<RectMask2D>();
}
// Initially hide both
rainbowIn.SetActive(true);
exitButton.SetActive(false);
}
protected override void DoTransitionIn(Action onComplete)
{
gameLayoutContainer.SetActive(true);
// Play establishing animations
rainbowPlayer.LoadAnimation(rainbowEstablish.text);
rainbowPlayer.PlayAnimation(false);
rainbowPlayer.loop = false;
// Show the exit button
exitButton.SetActive(true);
// Set input mode to UI
QuickAccess.Instance.PlayerController.InterruptMoveTo();
InputManager.Instance.SetInputMode(InputMode.UI);
gameLayoutContainer.SetActive(true);
// Hide rainbow out, show rainbow in
rainbowOut.SetActive(false);
// Play animation on rainbow in without resetting state
rainbowInPlayer.PlayAnimation(true);
// Slide in animation - tween padding.left from 1700 to 0
slideInTween = TweenPaddingLeft(1700f, 0f, Tween.EaseOutBack, () => onComplete?.Invoke());
slideInTween = TweenPaddingLeft(1700f, 0f, Tween.EaseOut, () =>
{
onComplete?.Invoke();
rainbowOut.SetActive(true);
exitButton.SetActive(true);
});
}
protected override void DoTransitionOut(Action onComplete)
{
rainbowPlayer.LoadAnimation(rainbowRemove.text);
rainbowPlayer.PlayAnimation(true);
rainbowPlayer.loop = false;
rainbowIn.SetActive(false);
// Set input mode to game and ui
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
// Play animation on rainbow out with resetting state
rainbowOutPlayer.PlayAnimation(true);
// Hide the exit button
exitButton.SetActive(false);
// Slide out animation - tween padding.left from 0 to 1700
slideOutTween = TweenPaddingLeft(0f, 1700f, Tween.EaseInBack, () => {
slideOutTween = TweenPaddingLeft(0f, 1700f, Tween.EaseIn, () => {
gameLayoutContainer.SetActive(false);
PlayerHudManager.Instance.ShowAllHud();
rainbowIn.SetActive(true);
onComplete?.Invoke();
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
});
}

View File

@@ -190,23 +190,35 @@ namespace UI.Core
{
if (_pageStack.Count <= 0) return;
// Hide and pop current page
// Pop current page from stack
UIPage currentPage = _pageStack.Pop();
currentPage.TransitionOut();
// Show previous page if there is one
if (_pageStack.Count > 0)
// Subscribe to transition out completion event
Action onTransitionComplete = null;
onTransitionComplete = () =>
{
UIPage previousPage = _pageStack.Peek();
previousPage.TransitionIn();
OnPageChanged?.Invoke(previousPage);
Logging.Debug($"[UIPageController] Popped to previous page: {previousPage.PageName}");
}
else
{
OnPageChanged?.Invoke(null);
Logging.Debug("[UIPageController] Popped last page, no pages left in stack");
}
// Unsubscribe to prevent memory leaks
currentPage.OnTransitionOutCompleted -= onTransitionComplete;
// Fire OnPageChanged AFTER transition completes
if (_pageStack.Count > 0)
{
UIPage previousPage = _pageStack.Peek();
previousPage.TransitionIn();
OnPageChanged?.Invoke(previousPage);
Logging.Debug($"[UIPageController] Popped to previous page: {previousPage.PageName}");
}
else
{
OnPageChanged?.Invoke(null);
Logging.Debug("[UIPageController] Popped last page, no pages left in stack");
}
};
currentPage.OnTransitionOutCompleted += onTransitionComplete;
// Start the transition out animation
currentPage.TransitionOut();
}
/// <summary>

View File

@@ -32,7 +32,7 @@ namespace UI
[Header("HUD Elements")]
public GameObject eagleEye;
public GameObject ramaSjangButton;
[HideInInspector] public Image cinematicSprites;
[HideInInspector] public Image cinematicBackgroundSprites;
@@ -157,42 +157,17 @@ namespace UI
switch (sceneName)
{
case "AppleHillsOverworld":
UpdateUIMode(UIMode.Overworld);
currentUIMode = UIMode.Overworld;
break;
case "Quarry":
UpdateUIMode(UIMode.Puzzle);
currentUIMode = 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;
// Hide eagle eye
eagleEye.SetActive(false);
break;
case UIMode.Puzzle:
// Update currentUIMode var
currentUIMode = UIMode.Puzzle;
// show eagle eye
eagleEye.SetActive(true);
break;
case UIMode.Minigame:
// Update currentUIMode var
currentUIMode = UIMode.Minigame;
// Hide birds eye
eagleEye.SetActive(false);
break;
}
ShowAllHud();
}
/// <summary>
@@ -245,14 +220,47 @@ namespace UI
return;
}
// Set visibility for all HUD children
foreach (Transform child in hudButtonsContainer)
{
child.gameObject.SetActive(visible);
}
ApplyUIModeOverrides(visible);
Logging.Debug($"[PlayerHudManager] {(visible ? "Shown" : "Hidden")} all HUD elements");
}
/// <summary>
/// Applies UI mode-specific visibility rules (e.g., hiding eagleEye in certain modes)
/// </summary>
private void ApplyUIModeOverrides(bool visible)
{
switch (currentUIMode)
{
case UIMode.Overworld:
if (visible)
{
eagleEye.SetActive(false);
}
break;
case UIMode.Puzzle:
if (visible)
{
ramaSjangButton.SetActive(false);
}
break;
case UIMode.Minigame:
if (visible)
{
eagleEye.SetActive(false);
}
break;
case UIMode.HideAll:
break;
}
}
/// <summary>
/// Automatically manages HUD visibility based on page stack state
/// </summary>