Files

2368 lines
107 KiB
C#

using System;
using System.Collections.Generic;
using GazeLab.Combat;
using GazeLab.Core;
using GazeLab.Data;
using GazeLab.Entities;
using GazeLab.InputSystem;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace GazeLab.UI
{
public sealed class GazeLabHUD : MonoBehaviour
{
public static GazeLabHUD Instance { get; private set; }
[Header("UI Sprite Theme References (From DoneUI / DoneUI3)")]
public Sprite panelContainerSprite;
public Sprite buttonBlueSprite;
public Sprite buttonGreenSprite;
public Sprite buttonOrangeSprite;
public Sprite roundSlotCyanSprite;
public Sprite roundSlotGoldSprite;
public Sprite reticleSprite;
public Sprite aimRingSprite;
public Sprite scrapIconSprite;
public Sprite goldIconSprite;
public Sprite uraniumIconSprite;
public Sprite levelUpIconSprite;
public Sprite metaTreeIconSprite;
public Sprite settingsIconSprite;
[Header("Circular Node Containers (From DoneCircularContainer)")]
[Tooltip("Small container sprite for regular stat upgrades.")]
public Sprite containerSmallSprite;
[Tooltip("Silver container sprite for rare unlocks (weapons, abilities).")]
public Sprite containerSilverSprite;
[Tooltip("Gold container sprite for station evolutions.")]
public Sprite containerGoldSprite;
public GazeLabUIThemeSO uiTheme;
[Header("Sci-Fi Energy Bar Shader")]
[Tooltip("Animated wave shader for station hull, shield, and boss bars (Assets/GazeLab/Shaders/SciFiEnergyBar.shader).")]
public Shader sciFiEnergyBarShader;
public Canvas rootCanvas;
public RectTransform canvasRect;
public Font defaultFont;
// Top Minimal Wave Bar
private Text waveStatusText;
// Boss Bar
private GameObject bossBarRoot;
private Text bossNameText;
private Image bossHpFillImage;
private SciFiEnergyBar bossEnergyBar;
// Bottom-Left Status Deck
private Text stationTitleText;
private Image hullFillImage;
private SciFiEnergyBar hullEnergyBar;
private Text hullValueText;
private Image shieldFillImage;
private SciFiEnergyBar shieldEnergyBar;
private Text shieldValueText;
private Text scrapCountText;
private Text goldCountText;
private Text uraniumCountText;
// Cached HUD values to prevent per-frame string allocations
private int lastStationLevel = -1;
private int lastCurHull = -1;
private int lastMaxHull = -1;
private int lastCurShield = -1;
private int lastMaxShield = -1;
private int lastBossHp = -1;
private int lastBossChains = -1;
// Split Circular Ability Slots
private readonly List<Button> abilityButtons = new List<Button>();
private readonly List<Image> abilityIcons = new List<Image>();
private readonly List<Image> abilityCooldownRings = new List<Image>();
private readonly List<Image> abilityBackgroundImages = new List<Image>();
private readonly List<Text> abilitySlotLabels = new List<Text>();
private readonly List<Text> abilityCooldownTexts = new List<Text>();
// Bottom-Right Compact Deck (LevelUp Icon + Meta Mastery Icon + Settings Icon)
private Button levelUpButton;
private Image levelUpIconImage;
private Outline levelUpGlowOutline;
private Text levelUpLabelText;
private Button metaTreeButton;
private Image metaTreeIconImage;
private Outline metaTreeGlowOutline;
private Text metaTreeLabelText;
private Button settingsIconButton;
// Gameplay Combat FX Layer (Confines damage numbers and floating combat text to the game layer beneath HUD & modals)
private RectTransform gameplayCombatFxLayer;
// Reticle UI
private RectTransform reticleRoot;
private Image reticleMainImage;
private Image reticleDwellRingImage;
private Text reticleTargetLabel;
// Modular Tech Tree & Hardpoint Loadout View
private TechTreeModalView techTreeModalView;
public TechTreeModalView TechTreeModal => techTreeModalView;
// Modular Meta-Progression Tree View
private MetaTreeModalView metaTreeModalView;
public MetaTreeModalView MetaTreeModal => metaTreeModalView;
// Dedicated Settings & Pause Modal (Accessed with ESC or Settings Icon)
private GameObject settingsModalRoot;
private Text settingsControlModeBtnText;
private Text settingsSuppressTipsText;
private Text settingsAudioToggleText;
// Pause Tooltip Modal (with OK button + Suppress Checkbox)
private GameObject tooltipModalRoot;
private Text tooltipHeaderText;
private Text tooltipSubTitleText;
private Text tooltipBodyText;
private Image tooltipIllustrationImage;
private Text tooltipSuppressToggleText;
private readonly Queue<TutorialTooltipDefinition> pendingTooltips = new Queue<TutorialTooltipDefinition>();
private bool isShowingTooltipModal;
private float timeScaleBeforeTooltip = 1f;
// Game Over Overlay
private GameObject gameOverRoot;
private Text gameOverStatsText;
// Center In-Game Wave Clear Prompt
private GameObject centerWaveClearPromptRoot;
private Text centerWaveClearTitleText;
private Button centerWaveClearButton;
private Text centerWaveClearButtonLabel;
private bool isCenterWavePromptRequested;
public bool IsCenterWavePromptRequested => isCenterWavePromptRequested;
public void SetCenterWavePromptRequested(bool requested) => isCenterWavePromptRequested = requested;
private static Sprite fallbackWhiteSprite;
public void EnsureContainerSprites()
{
if (containerSmallSprite != null && containerSilverSprite != null && containerGoldSprite != null)
return;
#if UNITY_EDITOR
var assets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("Assets/GazeLab/Props/UI/DoneCircularContainer.png");
if (assets != null)
{
for (int i = 0; i < assets.Length; i++)
{
if (assets[i] is Sprite sp)
{
if (containerSmallSprite == null && (sp.name == "UI_Container_Circular_small_Silver1" || sp.name == "UI_Container_Circular_Small_Silver2"))
containerSmallSprite = sp;
else if (containerSilverSprite == null && (sp.name == "UI_Container_Circular_Big_Silver1" || sp.name == "UI_Container_Circular_Big_Silver2"))
containerSilverSprite = sp;
else if (containerGoldSprite == null && (sp.name == "UI_Container_Circular_Elite_Gold1" || sp.name == "UI_Container_Circular_Elite_Gold2"))
containerGoldSprite = sp;
}
}
}
if (containerSmallSprite != null && containerSilverSprite != null && containerGoldSprite != null)
return;
#endif
Sprite[] all = Resources.FindObjectsOfTypeAll<Sprite>();
if (all == null) return;
for (int i = 0; i < all.Length; i++)
{
Sprite s = all[i];
if (s == null) continue;
if (containerSmallSprite == null && (s.name == "UI_Container_Circular_small_Silver1" || s.name == "UI_Container_Circular_Small_Silver2"))
containerSmallSprite = s;
else if (containerSilverSprite == null && (s.name == "UI_Container_Circular_Big_Silver1" || s.name == "UI_Container_Circular_Big_Silver2"))
containerSilverSprite = s;
else if (containerGoldSprite == null && (s.name == "UI_Container_Circular_Elite_Gold1" || s.name == "UI_Container_Circular_Elite_Gold2"))
containerGoldSprite = s;
}
}
public void EnsureMetaTreeIconSprite()
{
if (metaTreeIconSprite != null) return;
#if UNITY_EDITOR
var assets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("Assets/GazeLab/Props/UI/DoneUI3.png");
if (assets != null)
{
for (int i = 0; i < assets.Length; i++)
{
if (assets[i] is Sprite sp && (sp.name == "UI_Button_Achievements" || sp.name == "UI_Icon_Star_Metallic_Small" || sp.name == "UI_Icon_Boost"))
{
metaTreeIconSprite = sp;
return;
}
}
}
#endif
Sprite[] all = Resources.FindObjectsOfTypeAll<Sprite>();
if (all != null)
{
for (int i = 0; i < all.Length; i++)
{
Sprite s = all[i];
if (s != null && (s.name == "UI_Button_Achievements" || s.name == "UI_Icon_Star_Metallic_Small" || s.name == "UI_Icon_Boost"))
{
metaTreeIconSprite = s;
return;
}
}
}
if (metaTreeIconSprite == null)
{
metaTreeIconSprite = roundSlotGoldSprite != null ? roundSlotGoldSprite : buttonBlueSprite;
}
}
public Sprite GetNodeContainerSprite(UpgradeTreeNodeSO node, out Vector2 socketSize)
{
if (containerSmallSprite == null || containerSilverSprite == null || containerGoldSprite == null)
{
EnsureContainerSprites();
}
if (node == null)
{
socketSize = new Vector2(48f, 48f);
return containerSmallSprite != null ? containerSmallSprite : (roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite);
}
if (node.customContainerSprite != null)
{
bool isGold = node.containerStyle == TechNodeContainerStyle.Gold || node.category == TechNodeCategory.StationEvolution;
bool isSilver = node.containerStyle == TechNodeContainerStyle.Silver || node.category == TechNodeCategory.WeaponUnlock || node.category == TechNodeCategory.AbilityUnlock || node.isMajorNode;
socketSize = isGold ? new Vector2(68f, 68f) : (isSilver ? new Vector2(58f, 58f) : new Vector2(48f, 48f));
return node.customContainerSprite;
}
TechNodeContainerStyle style = node.containerStyle;
if (style == TechNodeContainerStyle.Automatic)
{
if (node.category == TechNodeCategory.StationEvolution)
style = TechNodeContainerStyle.Gold;
else if (node.category == TechNodeCategory.WeaponUnlock || node.category == TechNodeCategory.AbilityUnlock || node.isMajorNode)
style = TechNodeContainerStyle.Silver;
else
style = TechNodeContainerStyle.Small;
}
switch (style)
{
case TechNodeContainerStyle.Gold:
socketSize = new Vector2(68f, 68f);
if (containerGoldSprite != null) return containerGoldSprite;
if (uiTheme != null && uiTheme.containerGoldSprite != null) return uiTheme.containerGoldSprite;
return roundSlotGoldSprite != null ? roundSlotGoldSprite : roundSlotCyanSprite;
case TechNodeContainerStyle.Silver:
socketSize = new Vector2(58f, 58f);
if (containerSilverSprite != null) return containerSilverSprite;
if (uiTheme != null && uiTheme.containerSilverSprite != null) return uiTheme.containerSilverSprite;
return roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
case TechNodeContainerStyle.Small:
default:
socketSize = new Vector2(48f, 48f);
if (containerSmallSprite != null) return containerSmallSprite;
if (uiTheme != null && uiTheme.containerSmallSprite != null) return uiTheme.containerSmallSprite;
return roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
}
}
public Sprite GetMetaNodeContainerSprite(MetaUpgradeNodeSO node, out Vector2 socketSize)
{
if (containerSmallSprite == null || containerSilverSprite == null || containerGoldSprite == null)
{
EnsureContainerSprites();
}
if (node == null)
{
socketSize = new Vector2(48f, 48f);
return containerSmallSprite != null ? containerSmallSprite : (roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite);
}
TechNodeContainerStyle style = node.containerStyle;
if (style == TechNodeContainerStyle.Automatic)
{
if (node.treeTier >= 4 || (node.maxRank == 1 && node.pointCostPerRank >= 2))
style = TechNodeContainerStyle.Gold;
else if (node.treeTier == 3 || node.maxRank <= 2)
style = TechNodeContainerStyle.Silver;
else
style = TechNodeContainerStyle.Small;
}
switch (style)
{
case TechNodeContainerStyle.Gold:
socketSize = new Vector2(68f, 68f);
if (node.customContainerSprite != null && node.customContainerSprite.name.Contains("Gold"))
return node.customContainerSprite;
if (containerGoldSprite != null) return containerGoldSprite;
if (uiTheme != null && uiTheme.containerGoldSprite != null) return uiTheme.containerGoldSprite;
return roundSlotGoldSprite != null ? roundSlotGoldSprite : roundSlotCyanSprite;
case TechNodeContainerStyle.Silver:
socketSize = new Vector2(58f, 58f);
if (node.customContainerSprite != null && node.customContainerSprite.name.Contains("Silver"))
return node.customContainerSprite;
if (containerSilverSprite != null) return containerSilverSprite;
if (uiTheme != null && uiTheme.containerSilverSprite != null) return uiTheme.containerSilverSprite;
return roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
case TechNodeContainerStyle.Small:
default:
socketSize = new Vector2(48f, 48f);
if (node.customContainerSprite != null && node.customContainerSprite.name.ToLower().Contains("small"))
return node.customContainerSprite;
if (containerSmallSprite != null) return containerSmallSprite;
if (uiTheme != null && uiTheme.containerSmallSprite != null) return uiTheme.containerSmallSprite;
return roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
}
}
public void EnsureDefaultFont()
{
if (defaultFont == null)
{
defaultFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
}
if (defaultFont == null)
{
Font[] allFonts = Resources.FindObjectsOfTypeAll<Font>();
if (allFonts != null && allFonts.Length > 0)
{
defaultFont = allFonts[0];
}
}
}
public void EnsureEnergyBarShader()
{
if (sciFiEnergyBarShader != null) return;
#if UNITY_EDITOR
sciFiEnergyBarShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/GazeLab/Shaders/SciFiEnergyBar.shader");
if (sciFiEnergyBarShader != null) return;
#endif
sciFiEnergyBarShader = Shader.Find("GazeLab/UI/SciFiEnergyBar");
}
private void Awake()
{
Instance = this;
EnsureDefaultFont();
EnsureContainerSprites();
EnsureEnergyBarShader();
EnsureEventSystem();
Transform existingCanvas = transform.Find("GazeLab_MainCanvas");
if (existingCanvas != null)
{
BindExistingUI(existingCanvas.gameObject);
}
else
{
BuildCompleteUI();
}
EnforceLayerHierarchy();
}
private void OnEnable()
{
DamageableEntity.OnSpawnFloatingText += HandleSpawnFloatingText;
}
private void OnDisable()
{
DamageableEntity.OnSpawnFloatingText -= HandleSpawnFloatingText;
}
private void Start()
{
if (GazeLabGameManager.Instance != null)
{
GazeLabGameManager.Instance.OnGameStateChanged += HandleGameStateChanged;
GazeLabGameManager.Instance.OnResourcesChanged += HandleResourcesChanged;
GazeLabGameManager.Instance.OnWaveStarted += HandleWaveStarted;
GazeLabGameManager.Instance.OnWaveCompleted += HandleWaveCompleted;
GazeLabGameManager.Instance.OnShowTutorialTooltip += EnqueueTooltipModal;
GazeLabGameManager.Instance.OnTechTreeChanged += RefreshTechTreeUI;
HandleResourcesChanged(
GazeLabGameManager.Instance.scrapBank,
GazeLabGameManager.Instance.goldBank,
GazeLabGameManager.Instance.uraniumBank);
}
if (SpaceStationController.Instance != null)
{
SpaceStationController.Instance.OnLoadoutChanged += RefreshTechTreeUI;
}
if (InputModeManager.Instance != null)
{
InputModeManager.Instance.OnControlModeChanged += HandleControlModeChanged;
HandleControlModeChanged(InputModeManager.Instance.ControlMode);
}
EnforceLayerHierarchy();
}
private void OnDestroy()
{
if (GazeLabGameManager.Instance != null)
{
GazeLabGameManager.Instance.OnGameStateChanged -= HandleGameStateChanged;
GazeLabGameManager.Instance.OnResourcesChanged -= HandleResourcesChanged;
GazeLabGameManager.Instance.OnWaveStarted -= HandleWaveStarted;
GazeLabGameManager.Instance.OnWaveCompleted -= HandleWaveCompleted;
GazeLabGameManager.Instance.OnShowTutorialTooltip -= EnqueueTooltipModal;
GazeLabGameManager.Instance.OnTechTreeChanged -= RefreshTechTreeUI;
}
if (SpaceStationController.Instance != null)
{
SpaceStationController.Instance.OnLoadoutChanged -= RefreshTechTreeUI;
}
if (InputModeManager.Instance != null)
{
InputModeManager.Instance.OnControlModeChanged -= HandleControlModeChanged;
}
}
private void EnsureEventSystem()
{
if (FindObjectOfType<EventSystem>() != null) return;
new GameObject("EventSystem", typeof(EventSystem), typeof(StandaloneInputModule));
}
public void BuildCompleteUI()
{
EnsureDefaultFont();
if (canvasRect != null) return;
Transform existing = transform.Find("GazeLab_MainCanvas");
if (existing != null)
{
BindExistingUI(existing.gameObject);
return;
}
GameObject canvasGo = new GameObject("GazeLab_MainCanvas", typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster));
canvasGo.transform.SetParent(transform, false);
rootCanvas = canvasGo.GetComponent<Canvas>();
rootCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
rootCanvas.sortingOrder = 50;
CanvasScaler scaler = canvasGo.GetComponent<CanvasScaler>();
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
scaler.referenceResolution = new Vector2(1920f, 1080f);
scaler.matchWidthOrHeight = 0.5f;
canvasRect = canvasGo.GetComponent<RectTransform>();
// 1. Top Minimalist Wave Status & Boss Bar
BuildTopMinimalWaveBadge();
BuildBossHealthBar();
// 2. Bottom Flanks: Status Deck on Left, Split Ability Rings around center, Compact LevelUp & Settings on Right
BuildBottomLeftStatusDeck();
BuildSplitAbilityDock();
BuildBottomRightDeck();
// 3. Aiming Reticle (Topmost sibling)
BuildReticleOverlay();
// 4. Overlays & Modals
techTreeModalView = new TechTreeModalView(this, defaultFont, uiTheme);
techTreeModalView.Build(canvasRect);
metaTreeModalView = new MetaTreeModalView(this, defaultFont, uiTheme);
metaTreeModalView.Build(canvasRect);
BuildSettingsModal();
BuildTooltipModalPopup();
BuildGameOverOverlay();
BuildCenterWaveClearPrompt();
EnforceLayerHierarchy();
}
private static Transform FindInModal(Transform modal, string relativePath)
{
if (modal == null) return null;
return modal.Find($"CardPanel/{relativePath}") ?? modal.Find(relativePath);
}
public void BindExistingUI(GameObject canvasGo)
{
EnsureDefaultFont();
rootCanvas = canvasGo.GetComponent<Canvas>();
canvasRect = canvasGo.GetComponent<RectTransform>();
Transform topBadge = canvasRect.Find("TopWaveBadge");
if (topBadge != null)
{
waveStatusText = topBadge.Find("WaveText")?.GetComponent<Text>();
}
Transform bossBar = canvasRect.Find("BossHealthBar");
if (bossBar != null)
{
bossBarRoot = bossBar.gameObject;
bossHpFillImage = bossBar.Find("BossHpFill_Bg/BossHpFill_Fill")?.GetComponent<Image>()
?? bossBar.Find("BossHpFill/BossHpFill_Fill")?.GetComponent<Image>();
bossNameText = bossBar.Find("BossName")?.GetComponent<Text>();
if (bossHpFillImage != null)
{
bossEnergyBar = bossHpFillImage.GetComponent<SciFiEnergyBar>() ?? bossHpFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) bossEnergyBar.energyBarShader = sciFiEnergyBarShader;
bossEnergyBar.ConfigureAsBoss();
}
}
Transform leftDeck = canvasRect.Find("BottomLeftStatusDeck");
if (leftDeck != null)
{
stationTitleText = leftDeck.Find("StationTitle")?.GetComponent<Text>();
hullFillImage = leftDeck.Find("HullBar_Bg/HullBar_Fill")?.GetComponent<Image>()
?? leftDeck.Find("HullBar/HullBar_Fill")?.GetComponent<Image>();
hullValueText = leftDeck.Find("HullVal")?.GetComponent<Text>();
shieldFillImage = leftDeck.Find("ShieldBar_Bg/ShieldBar_Fill")?.GetComponent<Image>()
?? leftDeck.Find("ShieldBar/ShieldBar_Fill")?.GetComponent<Image>();
shieldValueText = leftDeck.Find("ShieldVal")?.GetComponent<Text>();
if (hullFillImage != null)
{
hullEnergyBar = hullFillImage.GetComponent<SciFiEnergyBar>() ?? hullFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) hullEnergyBar.energyBarShader = sciFiEnergyBarShader;
hullEnergyBar.ConfigureAsHull();
}
if (shieldFillImage != null)
{
shieldEnergyBar = shieldFillImage.GetComponent<SciFiEnergyBar>() ?? shieldFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) shieldEnergyBar.energyBarShader = sciFiEnergyBarShader;
shieldEnergyBar.ConfigureAsShield();
}
scrapCountText = leftDeck.Find("ScrapBadge/ResCount")?.GetComponent<Text>();
goldCountText = leftDeck.Find("GoldBadge/ResCount")?.GetComponent<Text>();
uraniumCountText = leftDeck.Find("UraniumBadge/ResCount")?.GetComponent<Text>();
}
abilityButtons.Clear();
abilityIcons.Clear();
abilityCooldownRings.Clear();
abilityBackgroundImages.Clear();
abilitySlotLabels.Clear();
abilityCooldownTexts.Clear();
KeyCode[] hotkeys = { KeyCode.Alpha1, KeyCode.Alpha2, KeyCode.Alpha3, KeyCode.Alpha4 };
for (int i = 0; i < 4; i++)
{
Transform slot = canvasRect.Find($"AbilityRingSlot_{i}");
if (slot == null) continue;
int slotIdx = i;
Button btn = slot.GetComponent<Button>();
Image bgImg = slot.GetComponent<Image>();
Image iconImg = slot.Find("AbilityIcon")?.GetComponent<Image>();
Image cdRing = slot.Find("CooldownOverlay")?.GetComponent<Image>();
Text slotLbl = slot.Find("HotkeyLabel")?.GetComponent<Text>();
Text cdTxt = slot.Find("CooldownText")?.GetComponent<Text>();
DwellButton dwell = slot.GetComponent<DwellButton>();
if (dwell != null)
{
dwell.Bind(() =>
{
if (SpaceStationController.Instance != null)
SpaceStationController.Instance.TryActivateAbility(slotIdx);
}, 0.72f, hotkeys[i]);
}
if (btn != null) abilityButtons.Add(btn);
if (iconImg != null) abilityIcons.Add(iconImg);
if (cdRing != null) abilityCooldownRings.Add(cdRing);
if (bgImg != null) abilityBackgroundImages.Add(bgImg);
if (slotLbl != null) abilitySlotLabels.Add(slotLbl);
if (cdTxt != null) abilityCooldownTexts.Add(cdTxt);
}
Transform lvlBtn = canvasRect.Find("LevelUpTechBtn");
if (lvlBtn != null)
{
levelUpButton = lvlBtn.GetComponent<Button>();
levelUpIconImage = lvlBtn.GetComponent<Image>();
levelUpGlowOutline = lvlBtn.GetComponent<Outline>();
levelUpLabelText = lvlBtn.Find("TechLabel")?.GetComponent<Text>();
lvlBtn.GetComponent<DwellButton>()?.Bind(ToggleTechTreeOverlay, 0.85f, KeyCode.U);
}
Transform metaBtn = canvasRect.Find("MetaTreeBtn");
if (metaBtn == null)
{
metaBtn = EnsureMetaTreeButtonInCanvas(canvasRect);
}
if (metaBtn != null)
{
metaTreeButton = metaBtn.GetComponent<Button>();
metaTreeIconImage = metaBtn.GetComponent<Image>();
metaTreeGlowOutline = metaBtn.GetComponent<Outline>();
metaTreeLabelText = metaBtn.Find("MetaLabel")?.GetComponent<Text>();
metaBtn.GetComponent<DwellButton>()?.Bind(ToggleMetaTreeOverlay, 0.85f, KeyCode.M);
}
Transform setBtn = canvasRect.Find("SettingsBtn");
if (setBtn != null)
{
settingsIconButton = setBtn.GetComponent<Button>();
setBtn.GetComponent<DwellButton>()?.Bind(ToggleSettingsModal, 0.90f, KeyCode.None);
}
Transform ret = canvasRect.Find("GazeReticle");
if (ret != null)
{
reticleRoot = ret.GetComponent<RectTransform>();
reticleMainImage = ret.Find("ReticleGraphic")?.GetComponent<Image>();
reticleDwellRingImage = ret.Find("ReticleDwellRing")?.GetComponent<Image>();
reticleTargetLabel = ret.Find("ReticleTargetInfo")?.GetComponent<Text>();
}
Transform settingsModal = canvasRect.Find("SettingsPauseModal");
if (settingsModal != null)
{
settingsModalRoot = settingsModal.gameObject;
settingsControlModeBtnText = FindInModal(settingsModal, "ControlModeBtn/BtnLabel")?.GetComponent<Text>();
settingsAudioToggleText = FindInModal(settingsModal, "AudioToggleBtn/BtnLabel")?.GetComponent<Text>();
settingsSuppressTipsText = FindInModal(settingsModal, "SuppressTipsBtn/BtnLabel")?.GetComponent<Text>();
FindInModal(settingsModal, "ControlModeBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
if (InputModeManager.Instance != null) InputModeManager.Instance.CycleControlMode();
UpdateSettingsUI();
}, 0.90f);
FindInModal(settingsModal, "AudioToggleBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
if (SpaceAudioController.Instance != null) SpaceAudioController.Instance.ToggleMute();
UpdateSettingsUI();
}, 0.90f);
FindInModal(settingsModal, "SuppressTipsBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
ToggleSuppressTutorialTooltips();
UpdateSettingsUI();
}, 0.90f);
FindInModal(settingsModal, "ResumeBtn")?.GetComponent<DwellButton>()?.Bind(ToggleSettingsModal, 0.90f);
FindInModal(settingsModal, "RestartBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
settingsModalRoot.SetActive(false);
if (GazeLabGameManager.Instance != null) GazeLabGameManager.Instance.StartNewGameSession();
}, 0.90f);
}
Transform tipModal = canvasRect.Find("TooltipModalPopup");
if (tipModal != null)
{
tooltipModalRoot = tipModal.gameObject;
tooltipHeaderText = FindInModal(tipModal, "TipHeader")?.GetComponent<Text>()
?? FindInModal(tipModal, "TipTitle")?.GetComponent<Text>();
tooltipSubTitleText = FindInModal(tipModal, "TipSub")?.GetComponent<Text>()
?? FindInModal(tipModal, "TipSubTitle")?.GetComponent<Text>()
?? FindInModal(tipModal, "TipSubHeader")?.GetComponent<Text>();
tooltipIllustrationImage = FindInModal(tipModal, "TipIllustration")?.GetComponent<Image>();
tooltipBodyText = FindInModal(tipModal, "TipBody")?.GetComponent<Text>();
tooltipSuppressToggleText = FindInModal(tipModal, "SuppressCheckboxBtn/BtnLabel")?.GetComponent<Text>();
FindInModal(tipModal, "SuppressCheckboxBtn")?.GetComponent<DwellButton>()?.Bind(ToggleSuppressTutorialTooltips, 0.90f);
FindInModal(tipModal, "DismissTipBtn")?.GetComponent<DwellButton>()?.Bind(DismissCurrentTooltipModal, 0.90f, KeyCode.Space);
}
Transform overModal = canvasRect.Find("GameOverModal");
if (overModal != null)
{
gameOverRoot = overModal.gameObject;
gameOverStatsText = FindInModal(overModal, "GameOverStats")?.GetComponent<Text>();
FindInModal(overModal, "OpenMetaTreeBtn")?.GetComponent<DwellButton>()?.Bind(ToggleMetaTreeOverlay, 0.90f, KeyCode.M);
FindInModal(overModal, "RetrySessionBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
gameOverRoot.SetActive(false);
if (GazeLabGameManager.Instance != null) GazeLabGameManager.Instance.StartNewGameSession();
}, 0.90f, KeyCode.Space);
}
techTreeModalView = new TechTreeModalView(this, defaultFont, uiTheme);
Transform existingTechModal = canvasRect.Find("TechTreeModal");
if (existingTechModal != null)
{
techTreeModalView.BindExisting(existingTechModal.gameObject);
}
else
{
techTreeModalView.Build(canvasRect);
}
metaTreeModalView = new MetaTreeModalView(this, defaultFont, uiTheme);
Transform existingMetaModal = canvasRect.Find("MetaTreeModal");
if (existingMetaModal != null)
{
metaTreeModalView.BindExisting(existingMetaModal.gameObject);
}
else
{
metaTreeModalView.Build(canvasRect);
}
Transform centerPrompt = canvasRect.Find("CenterWaveClearPrompt");
if (centerPrompt != null)
{
centerWaveClearPromptRoot = centerPrompt.gameObject;
centerWaveClearTitleText = centerPrompt.Find("Title")?.GetComponent<Text>();
centerWaveClearButton = centerPrompt.Find("LaunchNextWaveCenterBtn")?.GetComponent<Button>();
centerWaveClearButtonLabel = centerPrompt.Find("LaunchNextWaveCenterBtn/BtnLabel")?.GetComponent<Text>();
centerPrompt.Find("LaunchNextWaveCenterBtn")?.GetComponent<DwellButton>()?.Bind(() =>
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.StartNextWaveFromShop();
}, 0.90f, KeyCode.Space);
centerWaveClearPromptRoot.SetActive(false);
}
else
{
BuildCenterWaveClearPrompt();
}
EnforceLayerHierarchy();
}
private void BuildTopMinimalWaveBadge()
{
RectTransform badge = CreatePanel(canvasRect, "TopWaveBadge",
new Vector2(0.012f, 0.945f), new Vector2(0.24f, 0.988f),
Vector2.zero, Vector2.zero, new Color(0.02f, 0.05f, 0.11f, 0.58f));
waveStatusText = CreateText(badge, "WaveText", "WAVE 1: SECTOR RECON", 15, TextAnchor.MiddleLeft,
new Vector2(0.05f, 0f), new Vector2(0.96f, 1f), new Color(0.45f, 0.94f, 1f));
}
private void BuildBossHealthBar()
{
RectTransform bossPanel = CreatePanel(canvasRect, "BossHealthBar",
new Vector2(0.28f, 0.935f), new Vector2(0.72f, 0.988f),
Vector2.zero, Vector2.zero, new Color(0.14f, 0.03f, 0.05f, 0.85f));
bossBarRoot = bossPanel.gameObject;
bossHpFillImage = CreateProgressBar(bossPanel, "BossHpFill",
new Vector2(0.015f, 0.14f), new Vector2(0.985f, 0.54f),
new Color(0.95f, 0.22f, 0.22f, 0.95f));
if (bossHpFillImage != null)
{
bossEnergyBar = bossHpFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) bossEnergyBar.energyBarShader = sciFiEnergyBarShader;
bossEnergyBar.ConfigureAsBoss();
}
bossNameText = CreateText(bossPanel, "BossName", "SECTOR DREADNOUGHT", 14, TextAnchor.UpperCenter,
new Vector2(0.02f, 0.54f), new Vector2(0.98f, 0.96f), new Color(1f, 0.82f, 0.45f));
bossBarRoot.SetActive(false);
}
private void BuildBottomLeftStatusDeck()
{
RectTransform leftDeck = CreatePanel(canvasRect, "BottomLeftStatusDeck",
new Vector2(0.012f, 0.015f), new Vector2(0.255f, 0.145f),
Vector2.zero, Vector2.zero, new Color(0.02f, 0.05f, 0.11f, 0.68f));
stationTitleText = CreateText(leftDeck, "StationTitle", "STATION LVL 1: TINY SATELLITE", 13, TextAnchor.MiddleLeft,
new Vector2(0.04f, 0.72f), new Vector2(0.96f, 0.96f), new Color(0.42f, 0.92f, 1f));
// Hull Bar
CreateText(leftDeck, "HullLbl", "HULL", 11, TextAnchor.MiddleLeft,
new Vector2(0.04f, 0.49f), new Vector2(0.22f, 0.71f), new Color(0.45f, 1f, 0.62f));
hullFillImage = CreateProgressBar(leftDeck, "HullBar",
new Vector2(0.22f, 0.52f), new Vector2(0.96f, 0.69f),
new Color(0.22f, 0.88f, 0.46f, 0.95f));
if (hullFillImage != null)
{
hullEnergyBar = hullFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) hullEnergyBar.energyBarShader = sciFiEnergyBarShader;
hullEnergyBar.ConfigureAsHull();
}
hullValueText = CreateText(leftDeck, "HullVal", "150/150", 11, TextAnchor.MiddleCenter,
new Vector2(0.22f, 0.49f), new Vector2(0.96f, 0.71f), Color.white);
// Shield Bar
CreateText(leftDeck, "ShieldLbl", "SHLD", 11, TextAnchor.MiddleLeft,
new Vector2(0.04f, 0.27f), new Vector2(0.22f, 0.49f), new Color(0.35f, 0.88f, 1f));
shieldFillImage = CreateProgressBar(leftDeck, "ShieldBar",
new Vector2(0.22f, 0.30f), new Vector2(0.96f, 0.47f),
new Color(0.20f, 0.78f, 1f, 0.95f));
if (shieldFillImage != null)
{
shieldEnergyBar = shieldFillImage.gameObject.AddComponent<SciFiEnergyBar>();
if (sciFiEnergyBarShader != null) shieldEnergyBar.energyBarShader = sciFiEnergyBarShader;
shieldEnergyBar.ConfigureAsShield();
}
shieldValueText = CreateText(leftDeck, "ShieldVal", "80/80", 11, TextAnchor.MiddleCenter,
new Vector2(0.22f, 0.27f), new Vector2(0.96f, 0.49f), Color.white);
// Compact Resource Row
CreateResourceBadge(leftDeck, "ScrapBadge", scrapIconSprite, new Vector2(0.04f, 0.03f), new Vector2(0.34f, 0.25f),
new Color(0.82f, 0.88f, 0.96f), out scrapCountText);
CreateResourceBadge(leftDeck, "GoldBadge", goldIconSprite, new Vector2(0.36f, 0.03f), new Vector2(0.66f, 0.25f),
new Color(1f, 0.85f, 0.28f), out goldCountText);
CreateResourceBadge(leftDeck, "UraniumBadge", uraniumIconSprite, new Vector2(0.68f, 0.03f), new Vector2(0.96f, 0.25f),
new Color(0.42f, 1f, 0.58f), out uraniumCountText);
}
private void BuildSplitAbilityDock()
{
abilityButtons.Clear();
abilityIcons.Clear();
abilityCooldownRings.Clear();
abilityBackgroundImages.Clear();
abilitySlotLabels.Clear();
abilityCooldownTexts.Clear();
float[] xAnchors = { 0.325f, 0.385f, 0.615f, 0.675f };
KeyCode[] hotkeys = { KeyCode.Alpha1, KeyCode.Alpha2, KeyCode.Alpha3, KeyCode.Alpha4 };
for (int i = 0; i < 4; i++)
{
int slotIdx = i;
float cx = xAnchors[i];
GameObject slotGo = new GameObject($"AbilityRingSlot_{i}", typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
slotGo.transform.SetParent(canvasRect, false);
RectTransform rt = slotGo.GetComponent<RectTransform>();
rt.anchorMin = new Vector2(cx, 0.068f);
rt.anchorMax = new Vector2(cx, 0.068f);
rt.pivot = new Vector2(0.5f, 0.5f);
rt.sizeDelta = new Vector2(66f, 66f);
Image bgImg = slotGo.GetComponent<Image>();
bgImg.sprite = roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
bgImg.color = new Color(0.12f, 0.24f, 0.38f, 0.85f);
Outline ol = slotGo.GetComponent<Outline>();
ol.effectColor = new Color(0.25f, 0.85f, 1f, 0.55f);
ol.effectDistance = new Vector2(1.5f, -1.5f);
Button btn = slotGo.GetComponent<Button>();
btn.targetGraphic = bgImg;
// Ability Icon inside circle
GameObject iconGo = new GameObject("AbilityIcon", typeof(RectTransform), typeof(Image));
iconGo.transform.SetParent(slotGo.transform, false);
RectTransform iRt = iconGo.GetComponent<RectTransform>();
iRt.anchorMin = new Vector2(0.18f, 0.18f);
iRt.anchorMax = new Vector2(0.82f, 0.82f);
iRt.offsetMin = Vector2.zero;
iRt.offsetMax = Vector2.zero;
Image iconImg = iconGo.GetComponent<Image>();
iconImg.preserveAspect = true;
iconImg.raycastTarget = false;
// Radial Cooldown Overlay
GameObject cdGo = new GameObject("CooldownOverlay", typeof(RectTransform), typeof(Image));
cdGo.transform.SetParent(slotGo.transform, false);
RectTransform cdRt = cdGo.GetComponent<RectTransform>();
cdRt.anchorMin = Vector2.zero;
cdRt.anchorMax = Vector2.one;
cdRt.offsetMin = Vector2.zero;
cdRt.offsetMax = Vector2.zero;
Image cdRing = cdGo.GetComponent<Image>();
cdRing.sprite = roundSlotCyanSprite != null ? roundSlotCyanSprite : CreateSolidWhiteSprite();
cdRing.type = Image.Type.Filled;
cdRing.fillMethod = Image.FillMethod.Radial360;
cdRing.fillOrigin = (int)Image.Origin360.Top;
cdRing.fillClockwise = false;
cdRing.fillAmount = 0f;
cdRing.color = new Color(0.05f, 0.12f, 0.22f, 0.78f);
cdRing.raycastTarget = false;
Text slotLbl = CreateText(slotGo.transform, "HotkeyLabel", $"[{i + 1}]", 11, TextAnchor.MiddleCenter,
new Vector2(-0.2f, -0.36f), new Vector2(1.2f, -0.02f), new Color(0.75f, 0.92f, 1f));
Text cdTxt = CreateText(slotGo.transform, "CooldownText", "", 13, TextAnchor.MiddleCenter,
new Vector2(0f, 0f), new Vector2(1f, 1f), Color.white);
DwellButton dwell = slotGo.GetComponent<DwellButton>();
dwell.Bind(() =>
{
if (SpaceStationController.Instance != null)
SpaceStationController.Instance.TryActivateAbility(slotIdx);
}, 0.72f, hotkeys[i]);
abilityButtons.Add(btn);
abilityIcons.Add(iconImg);
abilityCooldownRings.Add(cdRing);
abilityBackgroundImages.Add(bgImg);
abilitySlotLabels.Add(slotLbl);
abilityCooldownTexts.Add(cdTxt);
}
}
private void BuildBottomRightDeck()
{
// Meta Mastery Icon Button
EnsureMetaTreeButtonInCanvas(canvasRect);
// LevelUp / Tech Tree Icon Button
GameObject lvlGo = new GameObject("LevelUpTechBtn", typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
lvlGo.transform.SetParent(canvasRect, false);
RectTransform lvlRt = lvlGo.GetComponent<RectTransform>();
lvlRt.anchorMin = new Vector2(0.865f, 0.072f);
lvlRt.anchorMax = new Vector2(0.865f, 0.072f);
lvlRt.pivot = new Vector2(0.5f, 0.5f);
lvlRt.sizeDelta = new Vector2(74f, 74f);
lvlRt.localScale = new Vector3(0.8f, 0.8f, 1f);
levelUpIconImage = lvlGo.GetComponent<Image>();
levelUpIconImage.sprite = roundSlotGoldSprite != null ? roundSlotGoldSprite : buttonBlueSprite;
levelUpIconImage.color = new Color(0.22f, 0.52f, 0.82f, 0.95f);
levelUpGlowOutline = lvlGo.GetComponent<Outline>();
levelUpGlowOutline.effectColor = new Color(0.35f, 0.90f, 1f, 0.75f);
levelUpGlowOutline.effectDistance = new Vector2(2f, -2f);
if (levelUpIconSprite != null)
{
GameObject innerIcon = new GameObject("TechGlyph", typeof(RectTransform), typeof(Image));
innerIcon.transform.SetParent(lvlGo.transform, false);
RectTransform iRt = innerIcon.GetComponent<RectTransform>();
iRt.anchorMin = new Vector2(0.20f, 0.20f);
iRt.anchorMax = new Vector2(0.80f, 0.80f);
iRt.offsetMin = Vector2.zero;
iRt.offsetMax = Vector2.zero;
Image glyph = innerIcon.GetComponent<Image>();
glyph.sprite = levelUpIconSprite;
glyph.preserveAspect = true;
glyph.raycastTarget = false;
}
levelUpLabelText = CreateText(lvlGo.transform, "TechLabel", "TECH TREE [U]", 11, TextAnchor.MiddleCenter,
new Vector2(-0.45f, -0.36f), new Vector2(1.45f, -0.02f), new Color(1f, 0.88f, 0.35f));
levelUpButton = lvlGo.GetComponent<Button>();
lvlGo.GetComponent<DwellButton>().Bind(ToggleTechTreeOverlay, 0.85f, KeyCode.U);
// Settings Icon Button
GameObject setGo = new GameObject("SettingsBtn", typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
setGo.transform.SetParent(canvasRect, false);
RectTransform setRt = setGo.GetComponent<RectTransform>();
setRt.anchorMin = new Vector2(0.945f, 0.072f);
setRt.anchorMax = new Vector2(0.945f, 0.072f);
setRt.pivot = new Vector2(0.5f, 0.5f);
setRt.sizeDelta = new Vector2(62f, 62f);
Image setBg = setGo.GetComponent<Image>();
setBg.sprite = roundSlotCyanSprite != null ? roundSlotCyanSprite : buttonBlueSprite;
setBg.color = new Color(0.16f, 0.34f, 0.55f, 0.90f);
if (settingsIconSprite != null)
{
GameObject sIcon = new GameObject("GearGlyph", typeof(RectTransform), typeof(Image));
sIcon.transform.SetParent(setGo.transform, false);
RectTransform sRt = sIcon.GetComponent<RectTransform>();
sRt.anchorMin = new Vector2(0.22f, 0.22f);
sRt.anchorMax = new Vector2(0.78f, 0.78f);
sRt.offsetMin = Vector2.zero;
sRt.offsetMax = Vector2.zero;
Image gImg = sIcon.GetComponent<Image>();
gImg.sprite = settingsIconSprite;
gImg.preserveAspect = true;
gImg.raycastTarget = false;
}
CreateText(setGo.transform, "SetLabel", "MENU [ESC]", 10, TextAnchor.MiddleCenter,
new Vector2(-0.4f, -0.36f), new Vector2(1.4f, -0.02f), new Color(0.75f, 0.88f, 1f));
settingsIconButton = setGo.GetComponent<Button>();
setGo.GetComponent<DwellButton>().Bind(ToggleSettingsModal, 0.90f, KeyCode.None);
}
private Transform EnsureMetaTreeButtonInCanvas(RectTransform parent)
{
if (parent == null) return null;
Transform existing = parent.Find("MetaTreeBtn");
if (existing != null)
{
Transform lvl = parent.Find("LevelUpTechBtn");
if (lvl != null && existing.GetSiblingIndex() > lvl.GetSiblingIndex())
{
existing.SetSiblingIndex(lvl.GetSiblingIndex());
}
return existing;
}
GameObject metaGo = new GameObject("MetaTreeBtn", typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
metaGo.transform.SetParent(parent, false);
Transform lvlBtn = parent.Find("LevelUpTechBtn");
if (lvlBtn != null)
{
metaGo.transform.SetSiblingIndex(lvlBtn.GetSiblingIndex());
}
else
{
Transform setBtn = parent.Find("SettingsBtn");
if (setBtn != null)
{
metaGo.transform.SetSiblingIndex(setBtn.GetSiblingIndex());
}
}
RectTransform metaRt = metaGo.GetComponent<RectTransform>();
metaRt.anchorMin = new Vector2(0.785f, 0.072f);
metaRt.anchorMax = new Vector2(0.785f, 0.072f);
metaRt.pivot = new Vector2(0.5f, 0.5f);
metaRt.sizeDelta = new Vector2(74f, 74f);
metaRt.localScale = new Vector3(0.8f, 0.8f, 1f);
metaTreeIconImage = metaGo.GetComponent<Image>();
metaTreeIconImage.sprite = roundSlotGoldSprite != null ? roundSlotGoldSprite : buttonBlueSprite;
metaTreeIconImage.color = new Color(0.42f, 0.22f, 0.65f, 0.95f);
metaTreeGlowOutline = metaGo.GetComponent<Outline>();
metaTreeGlowOutline.effectColor = new Color(0.85f, 0.65f, 1f, 0.75f);
metaTreeGlowOutline.effectDistance = new Vector2(2f, -2f);
EnsureMetaTreeIconSprite();
if (metaTreeIconSprite != null)
{
GameObject innerIcon = new GameObject("MetaGlyph", typeof(RectTransform), typeof(Image));
innerIcon.transform.SetParent(metaGo.transform, false);
RectTransform iRt = innerIcon.GetComponent<RectTransform>();
iRt.anchorMin = new Vector2(0.20f, 0.20f);
iRt.anchorMax = new Vector2(0.80f, 0.80f);
iRt.offsetMin = Vector2.zero;
iRt.offsetMax = Vector2.zero;
Image glyph = innerIcon.GetComponent<Image>();
glyph.sprite = metaTreeIconSprite;
glyph.preserveAspect = true;
glyph.raycastTarget = false;
}
metaTreeLabelText = CreateText(metaGo.transform, "MetaLabel", "MASTERY [M]", 11, TextAnchor.MiddleCenter,
new Vector2(-0.45f, -0.36f), new Vector2(1.45f, -0.02f), new Color(1f, 0.88f, 0.35f));
metaTreeButton = metaGo.GetComponent<Button>();
metaGo.GetComponent<DwellButton>().Bind(ToggleMetaTreeOverlay, 0.85f, KeyCode.M);
return metaGo.transform;
}
private void BuildReticleOverlay()
{
GameObject retGo = new GameObject("GazeReticle", typeof(RectTransform));
retGo.transform.SetParent(canvasRect, false);
reticleRoot = retGo.GetComponent<RectTransform>();
reticleRoot.sizeDelta = new Vector2(72f, 72f);
GameObject mainRing = new GameObject("ReticleGraphic", typeof(RectTransform), typeof(Image));
mainRing.transform.SetParent(reticleRoot, false);
RectTransform mRt = mainRing.GetComponent<RectTransform>();
mRt.anchorMin = Vector2.zero;
mRt.anchorMax = Vector2.one;
mRt.offsetMin = Vector2.zero;
mRt.offsetMax = Vector2.zero;
reticleMainImage = mainRing.GetComponent<Image>();
reticleMainImage.sprite = reticleSprite != null ? reticleSprite : (roundSlotCyanSprite != null ? roundSlotCyanSprite : ShockwaveExplosionController.GetFallbackGlowSprite());
reticleMainImage.color = new Color(0.35f, 0.95f, 1f, 0.85f);
reticleMainImage.raycastTarget = false;
GameObject dwellRing = new GameObject("ReticleDwellRing", typeof(RectTransform), typeof(Image));
dwellRing.transform.SetParent(reticleRoot, false);
RectTransform dRt = dwellRing.GetComponent<RectTransform>();
dRt.anchorMin = new Vector2(-0.12f, -0.12f);
dRt.anchorMax = new Vector2(1.12f, 1.12f);
dRt.offsetMin = Vector2.zero;
dRt.offsetMax = Vector2.zero;
reticleDwellRingImage = dwellRing.GetComponent<Image>();
reticleDwellRingImage.sprite = aimRingSprite != null ? aimRingSprite : (roundSlotGoldSprite != null ? roundSlotGoldSprite : (roundSlotCyanSprite != null ? roundSlotCyanSprite : ShockwaveExplosionController.GetFallbackGlowSprite()));
reticleDwellRingImage.type = Image.Type.Filled;
reticleDwellRingImage.fillMethod = Image.FillMethod.Radial360;
reticleDwellRingImage.fillOrigin = (int)Image.Origin360.Top;
reticleDwellRingImage.fillAmount = 0f;
reticleDwellRingImage.color = new Color(1f, 0.85f, 0.25f, 0.95f);
reticleDwellRingImage.raycastTarget = false;
reticleTargetLabel = CreateText(reticleRoot, "ReticleTargetInfo", "", 12, TextAnchor.UpperCenter,
new Vector2(-1.4f, -0.75f), new Vector2(2.4f, -0.12f), new Color(1f, 0.92f, 0.55f));
}
private void BuildSettingsModal()
{
RectTransform root = CreatePanel(canvasRect, "SettingsPauseModal",
Vector2.zero, Vector2.one,
Vector2.zero, Vector2.zero, new Color(0.01f, 0.03f, 0.08f, 0.82f));
settingsModalRoot = root.gameObject;
RectTransform card = CreatePanel(root, "CardPanel",
new Vector2(0.28f, 0.20f), new Vector2(0.72f, 0.80f),
Vector2.zero, Vector2.zero, new Color(0.02f, 0.06f, 0.14f, 0.98f));
CreateText(card, "SettingsTitle", "COMMAND PAUSE & SETTINGS", 22, TextAnchor.MiddleCenter,
new Vector2(0.06f, 0.84f), new Vector2(0.94f, 0.95f), new Color(0.38f, 0.95f, 1f));
CreateActionButton(card, "ControlModeBtn", "AIM INPUT MODE: MOUSE",
new Vector2(0.12f, 0.66f), new Vector2(0.88f, 0.78f),
buttonBlueSprite, new Color(0.18f, 0.44f, 0.68f),
() =>
{
if (InputModeManager.Instance != null)
InputModeManager.Instance.CycleControlMode();
UpdateSettingsUI();
}, out settingsControlModeBtnText, 16);
CreateActionButton(card, "AudioToggleBtn", "AUDIO SFX & AMBIENCE: ON",
new Vector2(0.12f, 0.50f), new Vector2(0.88f, 0.62f),
buttonBlueSprite, new Color(0.18f, 0.44f, 0.68f),
() =>
{
if (SpaceAudioController.Instance != null)
SpaceAudioController.Instance.ToggleMute();
UpdateSettingsUI();
}, out settingsAudioToggleText, 16);
CreateActionButton(card, "SuppressTipsBtn", "TUTORIAL POPUP BRIEFINGS: ENABLED",
new Vector2(0.12f, 0.34f), new Vector2(0.88f, 0.46f),
buttonBlueSprite, new Color(0.18f, 0.44f, 0.68f),
() =>
{
ToggleSuppressTutorialTooltips();
UpdateSettingsUI();
}, out settingsSuppressTipsText, 15);
CreateActionButton(card, "ResumeBtn", "[ RESUME MISSION ]",
new Vector2(0.12f, 0.18f), new Vector2(0.48f, 0.29f),
buttonGreenSprite, new Color(0.16f, 0.68f, 0.38f),
ToggleSettingsModal, out _, 16);
CreateActionButton(card, "RestartBtn", "[ RESTART SESSION ]",
new Vector2(0.52f, 0.18f), new Vector2(0.88f, 0.29f),
buttonOrangeSprite, new Color(0.72f, 0.35f, 0.18f),
() =>
{
settingsModalRoot.SetActive(false);
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.StartNewGameSession();
}, out _, 16);
settingsModalRoot.SetActive(false);
}
public GameObject GetTopmostActiveModal()
{
if (gameOverRoot != null && gameOverRoot.activeSelf) return gameOverRoot;
if (tooltipModalRoot != null && tooltipModalRoot.activeSelf) return tooltipModalRoot;
if (settingsModalRoot != null && settingsModalRoot.activeSelf) return settingsModalRoot;
if (metaTreeModalView != null && metaTreeModalView.IsOpen) return metaTreeModalView.RootGameObject;
if (techTreeModalView != null && techTreeModalView.IsOpen) return techTreeModalView.RootGameObject;
return null;
}
public bool IsAnyModalOpen()
{
return GetTopmostActiveModal() != null;
}
public void ResetHUDForNewSession()
{
if (metaTreeModalView != null && metaTreeModalView.RootGameObject != null)
metaTreeModalView.RootGameObject.SetActive(false);
if (techTreeModalView != null && techTreeModalView.RootGameObject != null)
techTreeModalView.RootGameObject.SetActive(false);
if (settingsModalRoot != null) settingsModalRoot.SetActive(false);
if (tooltipModalRoot != null) tooltipModalRoot.SetActive(false);
if (gameOverRoot != null) gameOverRoot.SetActive(false);
if (bossBarRoot != null) bossBarRoot.SetActive(false);
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null) centerWaveClearPromptRoot.SetActive(false);
pendingTooltips.Clear();
isShowingTooltipModal = false;
lastStationLevel = -1;
lastCurHull = -1;
lastMaxHull = -1;
lastCurShield = -1;
lastMaxShield = -1;
if (hullEnergyBar != null) hullEnergyBar.SetFill(1f, instant: true);
if (shieldEnergyBar != null) shieldEnergyBar.SetFill(1f, instant: true);
if (bossEnergyBar != null) bossEnergyBar.SetFill(1f, instant: true);
DwellButton.ResetAllDwellState();
EnforceLayerHierarchy();
}
public void ToggleSettingsModal()
{
if (settingsModalRoot == null) return;
// Block opening settings if Game Over or Tutorial Briefing modal is visible
if (gameOverRoot != null && gameOverRoot.activeSelf) return;
if (tooltipModalRoot != null && tooltipModalRoot.activeSelf) return;
bool next = !settingsModalRoot.activeSelf;
settingsModalRoot.SetActive(next);
DwellButton.ResetAllDwellState();
if (next)
{
if (techTreeModalView != null && techTreeModalView.RootGameObject != null)
techTreeModalView.RootGameObject.SetActive(false);
if (metaTreeModalView != null && metaTreeModalView.RootGameObject != null)
metaTreeModalView.RootGameObject.SetActive(false);
settingsModalRoot.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.PauseGameSession(isShop: false);
else
Time.timeScale = 0f;
UpdateSettingsUI();
}
else
{
EnforceLayerHierarchy();
if (GazeLabGameManager.Instance != null)
{
if (!GazeLabGameManager.Instance.IsWaveActive && GazeLabGameManager.Instance.CurrentState != GameFlowState.GameOver && GazeLabGameManager.Instance.CurrentState != GameFlowState.TitleMenu)
{
GazeLabGameManager.Instance.SetState(GameFlowState.InterWaveShop);
}
else
{
GazeLabGameManager.Instance.ResumeGameSession();
}
}
else
Time.timeScale = 1f;
}
}
private void UpdateSettingsUI()
{
if (InputModeManager.Instance != null && settingsControlModeBtnText != null)
{
settingsControlModeBtnText.text = $"AIM INPUT MODE: {InputModeManager.Instance.ControlMode.ToString().ToUpper()} [TAB]";
}
if (SpaceAudioController.Instance != null && settingsAudioToggleText != null)
{
settingsAudioToggleText.text = SpaceAudioController.Instance.isMuted
? "AUDIO SFX & AMBIENCE: <color=#FF7777>MUTED</color>"
: "AUDIO SFX & AMBIENCE: <color=#55FF77>ACTIVE</color>";
}
if (settingsSuppressTipsText != null)
{
settingsSuppressTipsText.text = GazeLabGameManager.SuppressTutorialTooltips
? "TUTORIAL POPUP BRIEFINGS: <color=#FFAA55>SUPPRESSED</color>"
: "TUTORIAL POPUP BRIEFINGS: <color=#55FF77>ENABLED</color>";
}
}
private void BuildTooltipModalPopup()
{
RectTransform root = CreatePanel(canvasRect, "TooltipModalPopup",
Vector2.zero, Vector2.one,
Vector2.zero, Vector2.zero, new Color(0.01f, 0.03f, 0.08f, 0.85f));
tooltipModalRoot = root.gameObject;
RectTransform card = CreatePanel(root, "CardPanel",
new Vector2(0.24f, 0.20f), new Vector2(0.76f, 0.80f),
Vector2.zero, Vector2.zero, new Color(0.02f, 0.06f, 0.14f, 0.98f));
tooltipHeaderText = CreateText(card, "TipHeader", "TACTICAL BRIEFING", 22, TextAnchor.MiddleCenter,
new Vector2(0.06f, 0.84f), new Vector2(0.94f, 0.95f), new Color(0.38f, 0.95f, 1f));
tooltipSubTitleText = CreateText(card, "TipSub", "NEW THREAT DETECTED", 15, TextAnchor.MiddleCenter,
new Vector2(0.06f, 0.74f), new Vector2(0.94f, 0.83f), new Color(1f, 0.84f, 0.32f));
GameObject imgGo = new GameObject("TipIllustration", typeof(RectTransform), typeof(Image));
imgGo.transform.SetParent(card, false);
RectTransform iRt = imgGo.GetComponent<RectTransform>();
iRt.anchorMin = new Vector2(0.40f, 0.50f);
iRt.anchorMax = new Vector2(0.60f, 0.72f);
iRt.offsetMin = Vector2.zero;
iRt.offsetMax = Vector2.zero;
tooltipIllustrationImage = imgGo.GetComponent<Image>();
tooltipIllustrationImage.preserveAspect = true;
tooltipBodyText = CreateText(card, "TipBody", "", 15, TextAnchor.MiddleCenter,
new Vector2(0.08f, 0.26f), new Vector2(0.92f, 0.48f), Color.white);
CreateActionButton(card, "SuppressCheckboxBtn", "[ ] Don't show tutorial briefings again",
new Vector2(0.14f, 0.15f), new Vector2(0.86f, 0.23f),
buttonBlueSprite, new Color(0.12f, 0.24f, 0.38f),
ToggleSuppressTutorialTooltips, out tooltipSuppressToggleText, 13);
CreateActionButton(card, "DismissTipBtn", "[ ACKNOWLEDGE & CONTINUE (SPACE) ]",
new Vector2(0.22f, 0.03f), new Vector2(0.78f, 0.13f),
buttonGreenSprite, new Color(0.16f, 0.68f, 0.38f),
DismissCurrentTooltipModal, out _, 16, KeyCode.Space);
tooltipModalRoot.SetActive(false);
}
private void ToggleSuppressTutorialTooltips()
{
GazeLabGameManager.SuppressTutorialTooltips = !GazeLabGameManager.SuppressTutorialTooltips;
UpdateSuppressCheckboxVisual();
}
private void UpdateSuppressCheckboxVisual()
{
if (tooltipSuppressToggleText != null)
{
tooltipSuppressToggleText.text = GazeLabGameManager.SuppressTutorialTooltips
? "<color=#55FF77>[✓] Don't show tutorial briefings again</color>"
: "[ ] Don't show tutorial briefings again";
}
}
private void BuildGameOverOverlay()
{
RectTransform root = CreatePanel(canvasRect, "GameOverModal",
Vector2.zero, Vector2.one,
Vector2.zero, Vector2.zero, new Color(0.08f, 0.01f, 0.02f, 0.90f));
gameOverRoot = root.gameObject;
RectTransform card = CreatePanel(root, "CardPanel",
new Vector2(0.25f, 0.24f), new Vector2(0.75f, 0.76f),
Vector2.zero, Vector2.zero, new Color(0.12f, 0.02f, 0.04f, 0.98f));
CreateText(card, "GameOverTitle", "ORBITAL STATION DESTROYED", 26, TextAnchor.MiddleCenter,
new Vector2(0.06f, 0.74f), new Vector2(0.94f, 0.92f), new Color(1f, 0.35f, 0.35f));
CreateText(card, "GameOverSub", "ALL HARPOON AND DEFENSE SYSTEMS OFFLINE", 14, TextAnchor.MiddleCenter,
new Vector2(0.06f, 0.66f), new Vector2(0.94f, 0.74f), new Color(0.85f, 0.65f, 0.65f));
gameOverStatsText = CreateText(card, "GameOverStats", "FINAL SCORE: 0", 16, TextAnchor.MiddleCenter,
new Vector2(0.08f, 0.42f), new Vector2(0.92f, 0.68f), Color.white);
CreateActionButton(card, "OpenMetaTreeBtn", "[ OPEN MASTERY TREE (M) ]",
new Vector2(0.22f, 0.22f), new Vector2(0.78f, 0.36f),
buttonBlueSprite, new Color(0.18f, 0.48f, 0.85f),
ToggleMetaTreeOverlay, out _, 16, KeyCode.M);
CreateActionButton(card, "RetrySessionBtn", "[ LAUNCH NEW ORBITAL SESSION ]",
new Vector2(0.22f, 0.05f), new Vector2(0.78f, 0.19f),
buttonGreenSprite, new Color(0.16f, 0.68f, 0.38f),
() =>
{
gameOverRoot.SetActive(false);
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.StartNewGameSession();
}, out _, 18, KeyCode.Space);
gameOverRoot.SetActive(false);
}
private void BuildCenterWaveClearPrompt()
{
RectTransform root = CreatePanel(canvasRect, "CenterWaveClearPrompt",
new Vector2(0.30f, 0.42f), new Vector2(0.70f, 0.58f),
Vector2.zero, Vector2.zero, new Color(0.02f, 0.05f, 0.12f, 0.92f));
centerWaveClearPromptRoot = root.gameObject;
Outline ol = root.gameObject.AddComponent<Outline>();
ol.effectColor = new Color(0.25f, 0.85f, 1f, 0.65f);
ol.effectDistance = new Vector2(2f, -2f);
centerWaveClearTitleText = CreateText(root, "Title", "ORBITAL SECTOR CLEARED", 18, TextAnchor.MiddleCenter,
new Vector2(0.05f, 0.56f), new Vector2(0.95f, 0.94f), new Color(1f, 0.88f, 0.32f));
CreateActionButton(root, "LaunchNextWaveCenterBtn", "LAUNCH NEXT WAVE >>> [SPACE]",
new Vector2(0.12f, 0.12f), new Vector2(0.88f, 0.52f),
buttonGreenSprite, new Color(0.15f, 0.68f, 0.38f),
() =>
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.StartNextWaveFromShop();
},
out centerWaveClearButtonLabel, 16, KeyCode.Space);
Transform btnTrans = root.Find("LaunchNextWaveCenterBtn");
if (btnTrans != null) centerWaveClearButton = btnTrans.GetComponent<Button>();
centerWaveClearPromptRoot.SetActive(false);
}
public void EnqueueTooltipModal(TutorialTooltipDefinition tooltip)
{
if (tooltip == null || GazeLabGameManager.SuppressTutorialTooltips) return;
pendingTooltips.Enqueue(tooltip);
if (!isShowingTooltipModal)
{
PresentNextTooltipModal();
}
}
private void PresentNextTooltipModal()
{
if (pendingTooltips.Count == 0 || GazeLabGameManager.SuppressTutorialTooltips)
{
pendingTooltips.Clear();
isShowingTooltipModal = false;
return;
}
TutorialTooltipDefinition tip = pendingTooltips.Dequeue();
if (tip == null)
{
PresentNextTooltipModal();
return;
}
if (!isShowingTooltipModal)
{
timeScaleBeforeTooltip = Time.timeScale;
}
isShowingTooltipModal = true;
Time.timeScale = 0f;
DwellButton.ResetAllDwellState();
if (tooltipHeaderText != null)
tooltipHeaderText.text = string.IsNullOrEmpty(tip.headerTitle) ? "TACTICAL BRIEFING" : tip.headerTitle.ToUpper();
if (tooltipSubTitleText != null)
tooltipSubTitleText.text = string.IsNullOrEmpty(tip.subTitle) ? "" : tip.subTitle.ToUpper();
if (tooltipBodyText != null)
tooltipBodyText.text = tip.bodyText ?? "";
if (tooltipIllustrationImage != null)
{
if (tip.illustrationSprite != null)
{
tooltipIllustrationImage.gameObject.SetActive(true);
tooltipIllustrationImage.sprite = tip.illustrationSprite;
}
else
{
tooltipIllustrationImage.gameObject.SetActive(false);
}
}
UpdateSuppressCheckboxVisual();
if (tooltipModalRoot != null)
{
tooltipModalRoot.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
tooltipModalRoot.SetActive(true);
}
}
private void DismissCurrentTooltipModal()
{
if (tooltipModalRoot != null)
tooltipModalRoot.SetActive(false);
DwellButton.ResetAllDwellState();
if (pendingTooltips.Count > 0 && !GazeLabGameManager.SuppressTutorialTooltips)
{
PresentNextTooltipModal();
return;
}
pendingTooltips.Clear();
isShowingTooltipModal = false;
bool otherModalOpen = (techTreeModalView != null && techTreeModalView.IsOpen) ||
(settingsModalRoot != null && settingsModalRoot.activeSelf) ||
(gameOverRoot != null && gameOverRoot.activeSelf);
EnforceLayerHierarchy();
if (!otherModalOpen)
{
Time.timeScale = Mathf.Max(1f, timeScaleBeforeTooltip);
}
}
public void ToggleMetaTreeOverlay()
{
if (metaTreeModalView == null || metaTreeModalView.RootGameObject == null) return;
// Block Meta Tree if Tutorial Tooltip or Settings modal is active
if (tooltipModalRoot != null && tooltipModalRoot.activeSelf) return;
if (settingsModalRoot != null && settingsModalRoot.activeSelf) return;
GameObject rootGo = metaTreeModalView.RootGameObject;
bool nextState = !rootGo.activeSelf;
rootGo.SetActive(nextState);
if (EventSystem.current != null)
EventSystem.current.SetSelectedGameObject(null);
DwellButton.ResetAllDwellState();
if (nextState)
{
if (techTreeModalView != null && techTreeModalView.IsOpen)
techTreeModalView.RootGameObject.SetActive(false);
rootGo.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
if (GazeLabGameManager.Instance != null && GazeLabGameManager.Instance.CurrentState != GameFlowState.GameOver)
GazeLabGameManager.Instance.PauseGameSession(isShop: false);
metaTreeModalView.Refresh();
}
else
{
EnforceLayerHierarchy();
if (GazeLabGameManager.Instance != null && GazeLabGameManager.Instance.CurrentState != GameFlowState.GameOver)
{
if (!GazeLabGameManager.Instance.IsWaveActive && GazeLabGameManager.Instance.CurrentState != GameFlowState.TitleMenu)
{
GazeLabGameManager.Instance.SetState(GameFlowState.InterWaveShop);
}
else
{
GazeLabGameManager.Instance.ResumeGameSession();
}
}
}
}
public void OpenTechTree()
{
if (techTreeModalView == null || techTreeModalView.RootGameObject == null) return;
// Block Tech Tree if Game Over, Tutorial Tooltip, or Settings modal is active
if (gameOverRoot != null && gameOverRoot.activeSelf) return;
if (tooltipModalRoot != null && tooltipModalRoot.activeSelf) return;
if (settingsModalRoot != null && settingsModalRoot.activeSelf) return;
if (metaTreeModalView != null && metaTreeModalView.IsOpen)
metaTreeModalView.RootGameObject.SetActive(false);
GameObject rootGo = techTreeModalView.RootGameObject;
rootGo.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
rootGo.SetActive(true);
if (EventSystem.current != null)
EventSystem.current.SetSelectedGameObject(null);
DwellButton.ResetAllDwellState();
bool isActuallyShop = GazeLabGameManager.Instance != null && GazeLabGameManager.Instance.IsInterWave;
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.PauseGameSession(isShop: isActuallyShop);
else
Time.timeScale = 0f;
RefreshTechTreeUI();
}
public void CloseTechTree()
{
if (techTreeModalView == null || techTreeModalView.RootGameObject == null) return;
GameObject rootGo = techTreeModalView.RootGameObject;
rootGo.SetActive(false);
if (EventSystem.current != null)
EventSystem.current.SetSelectedGameObject(null);
DwellButton.ResetAllDwellState();
bool isBetweenWaves = GazeLabGameManager.Instance != null && GazeLabGameManager.Instance.IsInterWave;
if (isBetweenWaves)
{
isCenterWavePromptRequested = true;
}
else
{
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.ResumeGameSession();
else
Time.timeScale = 1f;
}
EnforceLayerHierarchy();
}
public void ToggleTechTreeOverlay()
{
if (techTreeModalView == null || techTreeModalView.RootGameObject == null) return;
if (techTreeModalView.IsOpen)
{
CloseTechTree();
}
else
{
OpenTechTree();
}
}
private void Update()
{
if (UnityEngine.Input.GetKeyDown(KeyCode.Escape))
{
if (gameOverRoot != null && gameOverRoot.activeSelf)
return; // Cannot dismiss Game Over modal via Escape
if (tooltipModalRoot != null && tooltipModalRoot.activeSelf)
DismissCurrentTooltipModal();
else if (metaTreeModalView != null && metaTreeModalView.IsOpen)
ToggleMetaTreeOverlay();
else if (techTreeModalView != null && techTreeModalView.IsOpen)
CloseTechTree();
else
ToggleSettingsModal();
}
if (UnityEngine.Input.GetKeyDown(KeyCode.M))
{
if (tooltipModalRoot == null || !tooltipModalRoot.activeSelf)
{
ToggleMetaTreeOverlay();
}
}
if (UnityEngine.Input.GetKeyDown(KeyCode.U))
{
if (tooltipModalRoot == null || !tooltipModalRoot.activeSelf)
{
ToggleTechTreeOverlay();
}
}
bool isBetweenWaves = GazeLabGameManager.Instance != null && GazeLabGameManager.Instance.IsInterWave;
// Only show the center wave prompt if between waves, explicitly requested (e.g. user exited Tech Tree via X),
// and the user is NOT inside any other UI/modal!
bool showCenterWavePrompt = isBetweenWaves && isCenterWavePromptRequested && !IsAnyModalOpen();
if (centerWaveClearPromptRoot != null)
{
if (centerWaveClearPromptRoot.activeSelf != showCenterWavePrompt)
{
centerWaveClearPromptRoot.SetActive(showCenterWavePrompt);
}
if (showCenterWavePrompt && centerWaveClearTitleText != null && GazeLabGameManager.Instance != null)
{
centerWaveClearTitleText.text = $"ORBITAL SECTOR {GazeLabGameManager.Instance.currentWaveNumber} CLEARED";
}
}
if (showCenterWavePrompt && UnityEngine.Input.GetKeyDown(KeyCode.Space))
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (GazeLabGameManager.Instance != null)
GazeLabGameManager.Instance.StartNextWaveFromShop();
}
UpdateTopHudAndBossBar();
UpdateBottomStatusDeck();
UpdateSplitAbilityDock();
UpdateReticle();
UpdateLevelUpBreadcrumbGlow();
}
private void LateUpdate()
{
if (reticleRoot != null)
{
reticleRoot.SetAsLastSibling();
}
}
private void UpdateTopHudAndBossBar()
{
GazeLabGameManager gm = GazeLabGameManager.Instance;
if (gm != null && gm.CurrentWaveBossLead != null && gm.CurrentWaveBossLead.ShipDamageable != null && gm.CurrentWaveBossLead.ShipDamageable.IsAlive)
{
if (bossBarRoot != null && !bossBarRoot.activeSelf) bossBarRoot.SetActive(true);
DamageableEntity bDmg = gm.CurrentWaveBossLead.ShipDamageable;
if (bossEnergyBar != null)
bossEnergyBar.SetFill(bDmg.HullRatio);
else if (bossHpFillImage != null)
bossHpFillImage.fillAmount = bDmg.HullRatio;
int curHp = Mathf.CeilToInt(bDmg.currentHull);
int chains = bDmg.activeHarpoonChains;
if (curHp != lastBossHp || chains != lastBossChains)
{
lastBossHp = curHp;
lastBossChains = chains;
if (bossNameText != null)
bossNameText.text = $"{bDmg.displayName.ToUpper()} [HP: {curHp} | CHAINS: {chains}/{bDmg.requiredHarpoonChains}]";
}
}
else if (bossBarRoot != null && bossBarRoot.activeSelf)
{
bossBarRoot.SetActive(false);
lastBossHp = -1;
}
}
private void UpdateBottomStatusDeck()
{
SpaceStationController st = SpaceStationController.Instance;
if (st != null && st.StationDamageable != null)
{
DamageableEntity dmg = st.StationDamageable;
if (st.currentLevel != lastStationLevel)
{
lastStationLevel = st.currentLevel;
if (stationTitleText != null)
{
string lvlTitle = st.CurrentLevelDef != null ? st.CurrentLevelDef.title.ToUpper() : "OUTPOST";
stationTitleText.text = $"STATION LVL {st.currentLevel}: {lvlTitle} ({st.CurrentWorldScale:0.00}x)";
}
}
if (hullEnergyBar != null)
hullEnergyBar.SetFill(dmg.HullRatio);
else if (hullFillImage != null)
hullFillImage.fillAmount = dmg.HullRatio;
int cHull = Mathf.CeilToInt(dmg.currentHull);
int mHull = Mathf.CeilToInt(dmg.maxHull);
if (cHull != lastCurHull || mHull != lastMaxHull)
{
lastCurHull = cHull;
lastMaxHull = mHull;
if (hullValueText != null)
hullValueText.text = $"{cHull}/{mHull}";
}
if (dmg.maxShield > 0.01f)
{
if (shieldFillImage != null)
{
if (!shieldFillImage.gameObject.activeSelf)
shieldFillImage.gameObject.SetActive(true);
if (shieldEnergyBar != null)
shieldEnergyBar.SetFill(dmg.ShieldRatio);
else
shieldFillImage.fillAmount = dmg.ShieldRatio;
}
int cSh = Mathf.CeilToInt(dmg.currentShield);
int mSh = Mathf.CeilToInt(dmg.maxShield);
if (cSh != lastCurShield || mSh != lastMaxShield)
{
lastCurShield = cSh;
lastMaxShield = mSh;
if (shieldValueText != null)
shieldValueText.text = $"{cSh}/{mSh}";
}
}
else
{
if (shieldEnergyBar != null)
shieldEnergyBar.SetFill(0f);
else if (shieldFillImage != null)
shieldFillImage.fillAmount = 0f;
if (lastMaxShield != 0)
{
lastMaxShield = 0;
if (shieldValueText != null)
shieldValueText.text = "NO SHIELD";
}
}
}
}
private void UpdateSplitAbilityDock()
{
SpaceStationController st = SpaceStationController.Instance;
if (st == null) return;
var slots = st.AbilitySlots;
for (int i = 0; i < abilityButtons.Count; i++)
{
if (i >= slots.Count || slots[i].definition == null)
{
if (i < abilityButtons.Count && abilityButtons[i] != null)
abilityButtons[i].interactable = false;
if (i < abilityBackgroundImages.Count && abilityBackgroundImages[i] != null)
abilityBackgroundImages[i].color = new Color(0.10f, 0.16f, 0.24f, 0.40f);
if (i < abilityIcons.Count && abilityIcons[i] != null)
abilityIcons[i].color = Color.clear;
if (i < abilityCooldownRings.Count && abilityCooldownRings[i] != null)
abilityCooldownRings[i].fillAmount = 0f;
if (i < abilityCooldownTexts.Count && abilityCooldownTexts[i] != null)
abilityCooldownTexts[i].text = "-";
continue;
}
StationAbilitySlotState s = slots[i];
if (i < abilityIcons.Count && abilityIcons[i] != null && abilityIcons[i].sprite == null)
{
if (s.definition.iconSprite != null)
abilityIcons[i].sprite = s.definition.iconSprite;
else
abilityIcons[i].sprite = roundSlotCyanSprite != null ? roundSlotCyanSprite : ShockwaveExplosionController.GetFallbackGlowSprite();
}
if (!s.isUnlocked)
{
if (i < abilityButtons.Count && abilityButtons[i] != null)
abilityButtons[i].interactable = false;
if (i < abilityBackgroundImages.Count && abilityBackgroundImages[i] != null)
abilityBackgroundImages[i].color = new Color(0.12f, 0.16f, 0.24f, 0.65f);
if (i < abilityIcons.Count && abilityIcons[i] != null)
abilityIcons[i].color = new Color(0.40f, 0.45f, 0.55f, 0.35f);
if (i < abilityCooldownRings.Count && abilityCooldownRings[i] != null)
{
abilityCooldownRings[i].color = new Color(0.20f, 0.26f, 0.38f, 0.50f);
abilityCooldownRings[i].fillAmount = 1f;
}
if (i < abilitySlotLabels.Count && abilitySlotLabels[i] != null)
abilitySlotLabels[i].text = $"[{i + 1}]";
if (i < abilityCooldownTexts.Count && abilityCooldownTexts[i] != null)
abilityCooldownTexts[i].text = "🔒";
}
else if (s.cooldownRemaining > 0.05f)
{
if (i < abilityButtons.Count && abilityButtons[i] != null)
abilityButtons[i].interactable = false;
if (i < abilityBackgroundImages.Count && abilityBackgroundImages[i] != null)
abilityBackgroundImages[i].color = new Color(0.14f, 0.28f, 0.45f, 0.85f);
if (i < abilityIcons.Count && abilityIcons[i] != null)
abilityIcons[i].color = new Color(0.65f, 0.70f, 0.75f, 0.65f);
float cdRatio = Mathf.Clamp01(s.cooldownRemaining / Mathf.Max(0.1f, s.definition.cooldownSeconds));
if (i < abilityCooldownRings.Count && abilityCooldownRings[i] != null)
{
abilityCooldownRings[i].color = new Color(0.25f, 0.85f, 1f, 0.85f);
abilityCooldownRings[i].fillAmount = cdRatio;
}
if (i < abilitySlotLabels.Count && abilitySlotLabels[i] != null)
abilitySlotLabels[i].text = $"[{i + 1}] T{s.currentTier}";
if (i < abilityCooldownTexts.Count && abilityCooldownTexts[i] != null)
abilityCooldownTexts[i].text = $"{s.cooldownRemaining:0.0}s";
}
else
{
if (i < abilityButtons.Count && abilityButtons[i] != null)
abilityButtons[i].interactable = true;
if (i < abilityBackgroundImages.Count && abilityBackgroundImages[i] != null)
abilityBackgroundImages[i].color = new Color(0.18f, 0.55f, 0.85f, 0.95f);
if (i < abilityIcons.Count && abilityIcons[i] != null)
abilityIcons[i].color = Color.white;
if (i < abilityCooldownRings.Count && abilityCooldownRings[i] != null)
abilityCooldownRings[i].fillAmount = 0f;
if (i < abilitySlotLabels.Count && abilitySlotLabels[i] != null)
abilitySlotLabels[i].text = $"[{i + 1}] T{s.currentTier}";
if (i < abilityCooldownTexts.Count && abilityCooldownTexts[i] != null)
abilityCooldownTexts[i].text = "";
}
}
}
private void UpdateLevelUpBreadcrumbGlow()
{
GazeLabGameManager gm = GazeLabGameManager.Instance;
if (gm == null) return;
bool hasAffordable = gm.HasAnyAffordableUpgrade();
if (levelUpGlowOutline != null)
{
if (hasAffordable)
{
float ping = Mathf.PingPong(Time.unscaledTime * 3f, 1f);
Color glow = Color.Lerp(new Color(0.25f, 0.85f, 1f, 0.8f), new Color(1f, 0.85f, 0.20f, 1f), ping);
levelUpGlowOutline.effectColor = glow;
levelUpGlowOutline.effectDistance = new Vector2(3f, -3f);
float scalePulse = 1f + 0.10f * Mathf.Sin(Time.unscaledTime * 5f);
levelUpButton.transform.localScale = Vector3.one * scalePulse;
}
else
{
levelUpGlowOutline.effectColor = new Color(0.25f, 0.78f, 1f, 0.35f);
levelUpGlowOutline.effectDistance = new Vector2(1.5f, -1.5f);
levelUpButton.transform.localScale = Vector3.one;
}
}
if (metaTreeGlowOutline != null && metaTreeButton != null)
{
bool hasMetaPoints = MetaProgressionManager.Instance != null && MetaProgressionManager.Instance.AvailablePoints > 0;
if (hasMetaPoints)
{
float ping = Mathf.PingPong(Time.unscaledTime * 3f, 1f);
Color glow = Color.Lerp(new Color(0.75f, 0.35f, 1f, 0.85f), new Color(1f, 0.85f, 0.20f, 1f), ping);
metaTreeGlowOutline.effectColor = glow;
metaTreeGlowOutline.effectDistance = new Vector2(3f, -3f);
float scalePulse = 0.8f * (1f + 0.08f * Mathf.Sin(Time.unscaledTime * 5f));
metaTreeButton.transform.localScale = new Vector3(scalePulse, scalePulse, 1f);
}
else
{
metaTreeGlowOutline.effectColor = new Color(0.65f, 0.35f, 0.95f, 0.35f);
metaTreeGlowOutline.effectDistance = new Vector2(1.5f, -1.5f);
metaTreeButton.transform.localScale = new Vector3(0.8f, 0.8f, 1f);
}
}
if (techTreeModalView != null && techTreeModalView.IsOpen)
{
techTreeModalView.UpdatePulseAnimations();
}
if (metaTreeModalView != null && metaTreeModalView.IsOpen)
{
metaTreeModalView.UpdatePulseAnimations();
}
}
private void UpdateReticle()
{
if (InputModeManager.Instance == null || reticleRoot == null) return;
if (!InputModeManager.Instance.TryGetScreenPosition(out Vector2 screenPos))
{
reticleRoot.gameObject.SetActive(false);
return;
}
reticleRoot.gameObject.SetActive(true);
reticleRoot.position = screenPos;
if (reticleMainImage != null)
reticleMainImage.transform.Rotate(0f, 0f, -45f * Time.unscaledDeltaTime);
SpaceStationController st = SpaceStationController.Instance;
if (DwellButton.IsAnyButtonHovered && DwellButton.ActiveHoveredButton != null && DwellButton.ActiveHoveredButton.IsInteractable)
{
float uiDwell = DwellButton.CurrentHoveredDwellProgress;
if (reticleDwellRingImage != null)
reticleDwellRingImage.fillAmount = uiDwell;
float scalePulse = Mathf.Lerp(1.15f, 0.88f, uiDwell);
if (reticleMainImage != null)
{
reticleMainImage.transform.localScale = Vector3.one * scalePulse;
reticleMainImage.color = new Color(0.25f, 0.95f, 0.95f, 0.95f);
}
if (reticleTargetLabel != null)
reticleTargetLabel.text = "SELECTING...";
}
else if (st != null && st.CurrentHoveredTarget != null && st.CurrentHoveredTarget.IsAlive)
{
DamageableEntity t = st.CurrentHoveredTarget;
if (reticleDwellRingImage != null)
reticleDwellRingImage.fillAmount = st.DwellProgress;
float scalePulse = Mathf.Lerp(1.18f, 0.86f, st.DwellProgress);
if (reticleMainImage != null)
{
reticleMainImage.transform.localScale = Vector3.one * scalePulse;
reticleMainImage.color = st.IsTargetLocked ? new Color(1f, 0.35f, 0.35f, 0.95f) : new Color(1f, 0.85f, 0.25f, 0.95f);
}
if (reticleTargetLabel != null)
reticleTargetLabel.text = $"{t.displayName}\nHP: {Mathf.CeilToInt(t.currentHull)} {(t.IsShielded ? $"| SHD: {Mathf.CeilToInt(t.currentShield)}" : "")}";
}
else
{
if (reticleDwellRingImage != null)
reticleDwellRingImage.fillAmount = 0f;
if (reticleMainImage != null)
{
reticleMainImage.transform.localScale = Vector3.one;
reticleMainImage.color = new Color(0.35f, 0.95f, 1f, 0.80f);
}
if (reticleTargetLabel != null)
reticleTargetLabel.text = "";
}
}
private void RefreshTechTreeUI()
{
if (techTreeModalView != null)
{
techTreeModalView.Refresh();
}
}
private void HandleGameStateChanged(GameFlowState state)
{
if (state == GameFlowState.InterWaveShop)
{
if (!isCenterWavePromptRequested)
{
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (techTreeModalView != null && techTreeModalView.RootGameObject != null)
{
techTreeModalView.RootGameObject.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
techTreeModalView.RootGameObject.SetActive(true);
techTreeModalView.Refresh();
}
}
}
else if (state == GameFlowState.WaveCombat)
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
}
else if (state == GameFlowState.GameOver)
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (techTreeModalView != null && techTreeModalView.RootGameObject != null)
techTreeModalView.RootGameObject.SetActive(false);
if (settingsModalRoot != null)
settingsModalRoot.SetActive(false);
GazeLabGameManager gm = GazeLabGameManager.Instance;
if (gameOverRoot != null && gm != null)
{
gameOverRoot.transform.SetSiblingIndex(canvasRect.childCount - 2);
if (reticleRoot != null) reticleRoot.SetAsLastSibling();
gameOverRoot.SetActive(true);
MetaProgressionManager meta = MetaProgressionManager.Instance;
int curPoints = meta != null ? meta.AvailablePoints : 0;
int totalPoints = meta != null ? meta.TotalEarnedPoints : 0;
gameOverStatsText.text = $"REACHED SECTOR WAVE {gm.currentWaveNumber}\nHIGHEST WAVE CLEARED: {gm.highestWaveCleared}\nFINAL SCORE: {gm.currentScore}\n\n<color=#FFD700>AVAILABLE MASTERY POINTS: {curPoints} (TOTAL: {totalPoints}/30)</color>";
}
}
}
private void HandleResourcesChanged(int scrap, int gold, int uranium)
{
if (scrapCountText != null) scrapCountText.text = scrap.ToString();
if (goldCountText != null) goldCountText.text = gold.ToString();
if (uraniumCountText != null) uraniumCountText.text = uranium.ToString();
if (techTreeModalView != null && techTreeModalView.IsOpen)
{
techTreeModalView.Refresh();
}
}
private void HandleWaveCompleted(int waveNum)
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
}
private void HandleWaveStarted(int waveNum, string title, bool isBoss)
{
isCenterWavePromptRequested = false;
if (centerWaveClearPromptRoot != null)
centerWaveClearPromptRoot.SetActive(false);
if (waveStatusText != null)
{
waveStatusText.text = isBoss
? $"<color=#FF6655>⚠ WAVE {waveNum} [BOSS]: {title.ToUpper()}</color>"
: $"WAVE {waveNum}: {title.ToUpper()}";
}
}
private void HandleControlModeChanged(AimControlMode mode)
{
UpdateSettingsUI();
}
public RectTransform EnsureGameplayCombatFxLayer()
{
if (gameplayCombatFxLayer != null) return gameplayCombatFxLayer;
if (canvasRect != null)
{
Transform existing = canvasRect.Find("GameplayCombatFxLayer");
if (existing != null)
{
gameplayCombatFxLayer = existing.GetComponent<RectTransform>();
}
else
{
GameObject fxGo = new GameObject("GameplayCombatFxLayer", typeof(RectTransform));
fxGo.transform.SetParent(canvasRect, false);
gameplayCombatFxLayer = fxGo.GetComponent<RectTransform>();
gameplayCombatFxLayer.anchorMin = Vector2.zero;
gameplayCombatFxLayer.anchorMax = Vector2.one;
gameplayCombatFxLayer.offsetMin = Vector2.zero;
gameplayCombatFxLayer.offsetMax = Vector2.zero;
gameplayCombatFxLayer.pivot = new Vector2(0.5f, 0.5f);
}
gameplayCombatFxLayer.SetSiblingIndex(0);
}
return gameplayCombatFxLayer;
}
public void EnforceLayerHierarchy()
{
if (canvasRect == null) return;
// 1. Gameplay Combat FX Layer (Hosts FloatingCombatText underneath all HUD panels and modals)
EnsureGameplayCombatFxLayer();
if (gameplayCombatFxLayer != null)
{
gameplayCombatFxLayer.SetSiblingIndex(0);
}
// 2. In-game HUD Elements & Action Buttons (Ordered below all modals)
string[] hudElements = new string[]
{
"TopWaveBadge",
"BossHealthBar",
"BottomLeftStatusDeck",
"AbilityRingSlot_0",
"AbilityRingSlot_1",
"AbilityRingSlot_2",
"AbilityRingSlot_3",
"MetaTreeBtn",
"LevelUpTechBtn",
"SettingsBtn",
"CenterWaveClearPrompt"
};
int currentIndex = 1;
for (int i = 0; i < hudElements.Length; i++)
{
Transform t = canvasRect.Find(hudElements[i]);
if (t != null)
{
t.SetSiblingIndex(currentIndex++);
}
}
// 3. Modals and Overlays (Ordered above HUD elements)
string[] modals = new string[]
{
"TechTreeModal",
"MetaTreeModal",
"SettingsPauseModal",
"GameOverModal",
"TooltipModalPopup"
};
for (int i = 0; i < modals.Length; i++)
{
Transform t = canvasRect.Find(modals[i]);
if (t != null)
{
t.SetSiblingIndex(currentIndex++);
}
}
// 4. Reticle is always topmost
if (reticleRoot != null)
{
reticleRoot.SetAsLastSibling();
}
}
private void HandleSpawnFloatingText(Vector3 worldPos, string msg, Color col, float scale)
{
RectTransform fxLayer = EnsureGameplayCombatFxLayer();
RectTransform target = fxLayer != null ? fxLayer : canvasRect;
FloatingCombatText.SpawnOnCanvas(target, defaultFont, worldPos, msg, col, scale);
}
// =====================================================================
// Shared UI Element Factory Methods (Used by HUD & TechTreeModalView)
// =====================================================================
public RectTransform CreatePanelElement(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Color bgColor)
{
return CreatePanel(parent, name, anchorMin, anchorMax, Vector2.zero, Vector2.zero, bgColor);
}
public Text CreateTextElement(Transform parent, string name, string content, int fontSize, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Color color)
{
return CreateText(parent, name, content, fontSize, anchor, anchorMin, anchorMax, color);
}
public Button CreateButtonElement(Transform parent, string name, string label, Vector2 anchorMin, Vector2 anchorMax, Sprite bgSprite, Color bgColor, Action onClick, out Text labelText, int fontSize = 14, KeyCode shortcut = KeyCode.None)
{
return CreateActionButton(parent, name, label, anchorMin, anchorMax, bgSprite, bgColor, onClick, out labelText, fontSize, shortcut);
}
private RectTransform CreatePanel(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax,
Vector2 offsetMin, Vector2 offsetMax, Color bgColor)
{
GameObject go = new GameObject(name, typeof(RectTransform), typeof(Image), typeof(Outline));
go.transform.SetParent(parent, false);
RectTransform rt = go.GetComponent<RectTransform>();
rt.anchorMin = anchorMin;
rt.anchorMax = anchorMax;
rt.offsetMin = offsetMin;
rt.offsetMax = offsetMax;
Image img = go.GetComponent<Image>();
if (panelContainerSprite != null)
{
img.sprite = panelContainerSprite;
img.type = Image.Type.Sliced;
}
img.color = bgColor;
Outline ol = go.GetComponent<Outline>();
ol.effectColor = new Color(0.22f, 0.65f, 0.95f, 0.35f);
ol.effectDistance = new Vector2(1.5f, -1.5f);
return rt;
}
private Text CreateText(Transform parent, string name, string content, int fontSize, TextAnchor anchor,
Vector2 anchorMin, Vector2 anchorMax, Color color)
{
GameObject go = new GameObject(name, typeof(RectTransform), typeof(Text), typeof(Outline));
go.transform.SetParent(parent, false);
RectTransform rt = go.GetComponent<RectTransform>();
rt.anchorMin = anchorMin;
rt.anchorMax = anchorMax;
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
if (defaultFont == null) EnsureDefaultFont();
Text txt = go.GetComponent<Text>();
txt.font = defaultFont;
txt.text = content;
txt.fontSize = fontSize;
txt.fontStyle = FontStyle.Bold;
txt.alignment = anchor;
txt.color = color;
txt.supportRichText = true;
txt.horizontalOverflow = HorizontalWrapMode.Wrap;
txt.verticalOverflow = VerticalWrapMode.Overflow;
txt.raycastTarget = false;
Outline ol = go.GetComponent<Outline>();
ol.effectColor = new Color(0f, 0f, 0f, 0.82f);
ol.effectDistance = new Vector2(1.2f, -1.2f);
return txt;
}
private Image CreateProgressBar(Transform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Color fillColor)
{
GameObject bgGo = new GameObject(name + "_Bg", typeof(RectTransform), typeof(Image));
bgGo.transform.SetParent(parent, false);
RectTransform bgRt = bgGo.GetComponent<RectTransform>();
bgRt.anchorMin = anchorMin;
bgRt.anchorMax = anchorMax;
bgRt.offsetMin = Vector2.zero;
bgRt.offsetMax = Vector2.zero;
Image bgImg = bgGo.GetComponent<Image>();
bgImg.color = new Color(0.04f, 0.08f, 0.14f, 0.88f);
GameObject fillGo = new GameObject(name + "_Fill", typeof(RectTransform), typeof(Image));
fillGo.transform.SetParent(bgGo.transform, false);
RectTransform fRt = fillGo.GetComponent<RectTransform>();
fRt.anchorMin = Vector2.zero;
fRt.anchorMax = Vector2.one;
fRt.offsetMin = Vector2.zero;
fRt.offsetMax = Vector2.zero;
Image fImg = fillGo.GetComponent<Image>();
fImg.sprite = CreateSolidWhiteSprite();
fImg.type = Image.Type.Filled;
fImg.fillMethod = Image.FillMethod.Horizontal;
fImg.fillOrigin = (int)Image.OriginHorizontal.Left;
fImg.fillAmount = 1f;
fImg.color = fillColor;
return fImg;
}
private void CreateResourceBadge(Transform parent, string name, Sprite icon, Vector2 anchorMin, Vector2 anchorMax,
Color textColor, out Text countLabel)
{
GameObject badgeGo = new GameObject(name, typeof(RectTransform));
badgeGo.transform.SetParent(parent, false);
RectTransform rt = badgeGo.GetComponent<RectTransform>();
rt.anchorMin = anchorMin;
rt.anchorMax = anchorMax;
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
GameObject iconGo = new GameObject("ResIcon", typeof(RectTransform), typeof(Image));
iconGo.transform.SetParent(badgeGo.transform, false);
RectTransform iRt = iconGo.GetComponent<RectTransform>();
iRt.anchorMin = new Vector2(0.02f, 0.08f);
iRt.anchorMax = new Vector2(0.34f, 0.92f);
iRt.offsetMin = Vector2.zero;
iRt.offsetMax = Vector2.zero;
Image img = iconGo.GetComponent<Image>();
img.sprite = icon != null ? icon : ShockwaveExplosionController.GetFallbackGlowSprite();
img.preserveAspect = true;
img.color = icon != null ? Color.white : textColor;
img.raycastTarget = false;
countLabel = CreateText(badgeGo.transform, "ResCount", "0", 13, TextAnchor.MiddleLeft,
new Vector2(0.38f, 0f), new Vector2(0.98f, 1f), textColor);
}
private Button CreateActionButton(Transform parent, string name, string label, Vector2 anchorMin, Vector2 anchorMax,
Sprite bgSprite, Color bgColor, Action onClick, out Text labelText, int fontSize = 14, KeyCode shortcut = KeyCode.None)
{
GameObject btnGo = new GameObject(name, typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
btnGo.transform.SetParent(parent, false);
RectTransform rt = btnGo.GetComponent<RectTransform>();
rt.anchorMin = anchorMin;
rt.anchorMax = anchorMax;
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
Image img = btnGo.GetComponent<Image>();
if (bgSprite != null)
{
img.sprite = bgSprite;
img.type = Image.Type.Sliced;
}
img.color = bgColor;
Outline ol = btnGo.GetComponent<Outline>();
ol.effectColor = new Color(0.35f, 0.90f, 1f, 0.55f);
ol.effectDistance = new Vector2(1.5f, -1.5f);
Button btn = btnGo.GetComponent<Button>();
btn.targetGraphic = img;
labelText = CreateText(btnGo.transform, "BtnLabel", label, fontSize, TextAnchor.MiddleCenter,
new Vector2(0.03f, 0.08f), new Vector2(0.97f, 0.92f), Color.white);
DwellButton dwell = btnGo.GetComponent<DwellButton>();
dwell.Bind(onClick, 0.90f, shortcut);
return btn;
}
private static Sprite CreateSolidWhiteSprite()
{
if (fallbackWhiteSprite != null) return fallbackWhiteSprite;
Texture2D tex = new Texture2D(4, 4, TextureFormat.RGBA32, false);
for (int i = 0; i < 16; i++) tex.SetPixel(i % 4, i / 4, Color.white);
tex.Apply();
fallbackWhiteSprite = Sprite.Create(tex, new Rect(0, 0, 4, 4), new Vector2(0.5f, 0.5f));
return fallbackWhiteSprite;
}
}
}