Update HUD updates, moving scattered prefabs into a central HUD manager (#53)

Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: #53
This commit is contained in:
2025-11-09 21:41:39 +00:00
parent 0c9a388433
commit 3f548c3ed4
10 changed files with 1588 additions and 495 deletions

View File

@@ -31,9 +31,8 @@ namespace UI
public GameObject CinematicBackground;
[Header("HUD Elements")]
public GameObject appSwitcher;
public GameObject eagleEye;
public GameObject ramaSjangButton;
[HideInInspector] public Image cinematicSprites;
[HideInInspector] public Image cinematicBackgroundSprites;
@@ -64,12 +63,6 @@ namespace UI
UnityEngine.Debug.LogError("[PlayerHudManager] UIPageController not found on same GameObject!");
}
// Get AppSwitcher component reference
if (appSwitcher != null)
{
_appSwitcherComponent = appSwitcher.GetComponent<AppSwitcher>();
}
InitializeReferences();
}
@@ -164,53 +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;
// 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);
ShowAllHud();
}
/// <summary>
@@ -263,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>