1485 lines
63 KiB
C#
1485 lines
63 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using GazeLab.Combat;
|
|
using GazeLab.Core;
|
|
using GazeLab.Data;
|
|
using GazeLab.Entities;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace GazeLab.UI
|
|
{
|
|
/// <summary>
|
|
/// Modular presenter and procedural builder for the redesigned Left-to-Right Branching
|
|
/// Tech Upgrade Tree, Prerequisite Path Highlighter, Node Inspector, and Station Hardpoint Loadout bar.
|
|
/// </summary>
|
|
public sealed class TechTreeModalView
|
|
{
|
|
private sealed class TechNodeSocketWidget
|
|
{
|
|
public GameObject rootGo;
|
|
public RectTransform rectTransform;
|
|
public Button button;
|
|
public DwellButton dwellButton;
|
|
public Image outerGlowImage;
|
|
public Image socketRimImage;
|
|
public Outline outline;
|
|
public Image iconImage;
|
|
public Text shortNameLabel;
|
|
public Text rankBadgeText;
|
|
public UpgradeTreeNodeSO boundNode;
|
|
public Vector2 normalizedPos;
|
|
}
|
|
|
|
private sealed class HardpointSlotWidget
|
|
{
|
|
public int slotIndex;
|
|
public GameObject rootGo;
|
|
public Image backgroundImage;
|
|
public Image weaponIconImage;
|
|
public Text headerText;
|
|
public Text weaponNameText;
|
|
public Button swapWeaponButton;
|
|
public Text swapWeaponLabel;
|
|
public Button priorityButton;
|
|
public Text priorityLabel;
|
|
}
|
|
|
|
private readonly GazeLabHUD hud;
|
|
private readonly Font font;
|
|
private readonly GazeLabUIThemeSO theme;
|
|
|
|
private GameObject overlayRoot;
|
|
private Text stationInfoText;
|
|
private Button repairButton;
|
|
private Text repairLabel;
|
|
private Button instantBuyBtn;
|
|
private Text instantBuyToggleLabel;
|
|
private bool instantBuyEnabled = true;
|
|
|
|
private Text headerScrapCountText;
|
|
private Text headerGoldCountText;
|
|
private Text headerUraniumCountText;
|
|
|
|
private RectTransform graphCanvasRect;
|
|
private TechTreeConduitGraphic conduitGraphic;
|
|
private readonly List<TechNodeSocketWidget> nodeSockets = new List<TechNodeSocketWidget>();
|
|
private readonly List<ConduitEdgeData> conduitEdgesBuffer = new List<ConduitEdgeData>();
|
|
|
|
// Right Inspector Card
|
|
private RectTransform detailCardRoot;
|
|
private Image detailTrackBanner;
|
|
private Text detailCategoryBadge;
|
|
private Image detailIconBg;
|
|
private Image detailIcon;
|
|
private Text detailTitle;
|
|
private Text detailRankStatus;
|
|
private Text detailDescription;
|
|
private Text detailPrereqHeader;
|
|
private Text detailPrereqChecklist;
|
|
private Text detailCostText;
|
|
private Button detailBuyButton;
|
|
private Text detailBuyBtnLabel;
|
|
|
|
// Bottom Hardpoint Loadout & Wave Launch Bar
|
|
private readonly List<HardpointSlotWidget> hardpointWidgets = new List<HardpointSlotWidget>();
|
|
private Button launchWaveBtn;
|
|
private Text launchWaveLabel;
|
|
|
|
private UpgradeTreeNodeSO currentlySelectedNode;
|
|
private UpgradeTreeNodeSO currentlyHoveredNode;
|
|
|
|
public GameObject RootGameObject => overlayRoot;
|
|
public bool IsOpen => overlayRoot != null && overlayRoot.activeSelf;
|
|
|
|
public TechTreeModalView(GazeLabHUD ownerHud, Font defaultFont, GazeLabUIThemeSO uiTheme)
|
|
{
|
|
hud = ownerHud;
|
|
font = defaultFont;
|
|
theme = uiTheme != null ? uiTheme : ScriptableObject.CreateInstance<GazeLabUIThemeSO>();
|
|
}
|
|
|
|
public void Build(RectTransform canvasRect)
|
|
{
|
|
Transform existing = canvasRect.Find("TechTreeModal");
|
|
if (existing != null)
|
|
{
|
|
BindExisting(existing.gameObject);
|
|
return;
|
|
}
|
|
|
|
RectTransform overlay = hud.CreatePanelElement(
|
|
canvasRect,
|
|
"TechTreeModal",
|
|
Vector2.zero,
|
|
Vector2.one,
|
|
theme.modalBackdropColor);
|
|
overlayRoot = overlay.gameObject;
|
|
|
|
BuildHeaderBar(overlay);
|
|
BuildSubBarAndLegend(overlay);
|
|
BuildConstellationGraphArea(overlay);
|
|
BuildDetailInspectorCard(overlay);
|
|
BuildBottomLoadoutAndLaunchBar(overlay);
|
|
|
|
overlayRoot.SetActive(false);
|
|
}
|
|
|
|
public void BindExisting(GameObject modalRoot)
|
|
{
|
|
overlayRoot = modalRoot;
|
|
RectTransform overlay = overlayRoot.GetComponent<RectTransform>();
|
|
|
|
Transform closeBtn = overlay.Find("CloseTreeBtn");
|
|
if (closeBtn != null)
|
|
{
|
|
Button b = closeBtn.GetComponent<Button>();
|
|
if (b != null)
|
|
{
|
|
b.onClick.RemoveAllListeners();
|
|
b.onClick.AddListener(CloseModal);
|
|
}
|
|
DwellButton dw = closeBtn.GetComponent<DwellButton>();
|
|
if (dw != null) dw.Bind(CloseModal, 0.85f);
|
|
}
|
|
|
|
Transform resPanel = overlay.Find("HeaderResourcesBadgeRow");
|
|
if (resPanel != null)
|
|
{
|
|
headerScrapCountText = resPanel.Find("HeaderScrapBadge/Count")?.GetComponent<Text>();
|
|
headerGoldCountText = resPanel.Find("HeaderGoldBadge/Count")?.GetComponent<Text>();
|
|
headerUraniumCountText = resPanel.Find("HeaderUraniumBadge/Count")?.GetComponent<Text>();
|
|
}
|
|
|
|
Transform subBar = overlay.Find("SubBar");
|
|
if (subBar != null)
|
|
{
|
|
stationInfoText = subBar.Find("StationStatus")?.GetComponent<Text>();
|
|
repairButton = subBar.Find("QuickRepairBtn")?.GetComponent<Button>();
|
|
repairLabel = subBar.Find("QuickRepairBtn/BtnLabel")?.GetComponent<Text>();
|
|
if (repairButton != null)
|
|
{
|
|
repairButton.onClick.RemoveAllListeners();
|
|
repairButton.onClick.AddListener(OnClickRepairStation);
|
|
repairButton.GetComponent<DwellButton>()?.Bind(OnClickRepairStation, 0.90f);
|
|
}
|
|
|
|
instantBuyBtn = subBar.Find("InstantBuyBtn")?.GetComponent<Button>();
|
|
instantBuyToggleLabel = subBar.Find("InstantBuyBtn/BtnLabel")?.GetComponent<Text>();
|
|
if (instantBuyBtn != null)
|
|
{
|
|
instantBuyBtn.onClick.RemoveAllListeners();
|
|
instantBuyBtn.onClick.AddListener(() =>
|
|
{
|
|
instantBuyEnabled = !instantBuyEnabled;
|
|
if (instantBuyToggleLabel != null)
|
|
{
|
|
instantBuyToggleLabel.text = instantBuyEnabled
|
|
? "<color=#55FF77>[✓] INSTANT 1-STEP BUY</color>"
|
|
: "[ ] INSTANT 1-STEP BUY";
|
|
}
|
|
Refresh();
|
|
});
|
|
}
|
|
}
|
|
|
|
Transform graphContainer = overlay.Find("ConstellationGraphContainer");
|
|
if (graphContainer != null)
|
|
{
|
|
graphCanvasRect = graphContainer.Find("GraphInnerCanvas")?.GetComponent<RectTransform>();
|
|
if (graphCanvasRect != null)
|
|
{
|
|
conduitGraphic = graphCanvasRect.Find("ConduitGraphicLayer")?.GetComponent<TechTreeConduitGraphic>();
|
|
}
|
|
}
|
|
|
|
detailCardRoot = overlay.Find("TechTreeDetailCard")?.GetComponent<RectTransform>();
|
|
if (detailCardRoot != null)
|
|
{
|
|
detailTrackBanner = detailCardRoot.Find("TrackBanner")?.GetComponent<Image>();
|
|
detailCategoryBadge = detailCardRoot.Find("TrackBanner/CategoryBadge")?.GetComponent<Text>();
|
|
detailIconBg = detailCardRoot.Find("DetailIconBg")?.GetComponent<Image>();
|
|
detailIcon = detailCardRoot.Find("DetailIconBg/DetailIcon")?.GetComponent<Image>();
|
|
detailTitle = detailCardRoot.Find("DetailTitle")?.GetComponent<Text>();
|
|
detailRankStatus = detailCardRoot.Find("DetailRank")?.GetComponent<Text>();
|
|
detailDescription = detailCardRoot.Find("BenefitBox/DetailDesc")?.GetComponent<Text>();
|
|
detailPrereqHeader = detailCardRoot.Find("PrereqChecklistBox/PrereqHeader")?.GetComponent<Text>();
|
|
detailPrereqChecklist = detailCardRoot.Find("PrereqChecklistBox/PrereqList")?.GetComponent<Text>();
|
|
detailCostText = detailCardRoot.Find("DetailCost")?.GetComponent<Text>();
|
|
detailBuyButton = detailCardRoot.Find("DetailBuyBtn")?.GetComponent<Button>();
|
|
detailBuyBtnLabel = detailCardRoot.Find("DetailBuyBtn/BtnLabel")?.GetComponent<Text>();
|
|
if (detailBuyButton != null)
|
|
{
|
|
detailBuyButton.onClick.RemoveAllListeners();
|
|
detailBuyButton.onClick.AddListener(OnDetailBuyClicked);
|
|
detailBuyButton.GetComponent<DwellButton>()?.Bind(OnDetailBuyClicked, 0.90f);
|
|
}
|
|
}
|
|
|
|
Transform bottomBar = overlay.Find("BottomLoadoutBar");
|
|
if (bottomBar != null)
|
|
{
|
|
launchWaveBtn = bottomBar.Find("LaunchWaveBtn")?.GetComponent<Button>();
|
|
launchWaveLabel = bottomBar.Find("LaunchWaveBtn/BtnLabel")?.GetComponent<Text>();
|
|
if (launchWaveBtn != null)
|
|
{
|
|
launchWaveBtn.onClick.RemoveAllListeners();
|
|
launchWaveBtn.onClick.AddListener(OnLaunchOrResumeClicked);
|
|
launchWaveBtn.GetComponent<DwellButton>()?.Bind(OnLaunchOrResumeClicked, 0.90f, KeyCode.Space);
|
|
}
|
|
|
|
hardpointWidgets.Clear();
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Transform card = bottomBar.Find($"HardpointCard_{i}");
|
|
if (card == null) continue;
|
|
int capturedIdx = i;
|
|
var w = new HardpointSlotWidget
|
|
{
|
|
slotIndex = i,
|
|
rootGo = card.gameObject,
|
|
backgroundImage = card.GetComponent<Image>(),
|
|
weaponIconImage = card.Find("WepIcon")?.GetComponent<Image>(),
|
|
headerText = card.Find("SlotHeader")?.GetComponent<Text>(),
|
|
weaponNameText = card.Find("WepName")?.GetComponent<Text>(),
|
|
swapWeaponButton = card.Find("SwapWepBtn")?.GetComponent<Button>(),
|
|
swapWeaponLabel = card.Find("SwapWepBtn/BtnLabel")?.GetComponent<Text>(),
|
|
priorityButton = card.Find("PrioBtn")?.GetComponent<Button>(),
|
|
priorityLabel = card.Find("PrioBtn/BtnLabel")?.GetComponent<Text>()
|
|
};
|
|
|
|
if (w.swapWeaponButton != null)
|
|
{
|
|
w.swapWeaponButton.onClick.RemoveAllListeners();
|
|
w.swapWeaponButton.onClick.AddListener(() =>
|
|
{
|
|
if (SpaceStationController.Instance != null)
|
|
{
|
|
SpaceStationController.Instance.CycleSlotEquippedWeapon(capturedIdx);
|
|
RefreshLoadoutBar();
|
|
}
|
|
});
|
|
}
|
|
|
|
if (w.priorityButton != null)
|
|
{
|
|
w.priorityButton.onClick.RemoveAllListeners();
|
|
w.priorityButton.onClick.AddListener(() =>
|
|
{
|
|
if (SpaceStationController.Instance != null)
|
|
{
|
|
SpaceStationController.Instance.CycleSlotTargetPriority(capturedIdx);
|
|
RefreshLoadoutBar();
|
|
}
|
|
});
|
|
}
|
|
|
|
hardpointWidgets.Add(w);
|
|
}
|
|
}
|
|
|
|
overlayRoot.SetActive(false);
|
|
}
|
|
|
|
private void BuildHeaderBar(RectTransform overlay)
|
|
{
|
|
hud.CreateTextElement(
|
|
overlay,
|
|
"TreeTitle",
|
|
"ORBITAL RESEARCH & EVOLUTION MATRIX",
|
|
22,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.018f, 0.935f),
|
|
new Vector2(0.48f, 0.99f),
|
|
new Color(0.38f, 0.95f, 1f));
|
|
|
|
// Header Resources Panel with Icons
|
|
RectTransform resPanel = hud.CreatePanelElement(
|
|
overlay,
|
|
"HeaderResourcesBadgeRow",
|
|
new Vector2(0.48f, 0.932f),
|
|
new Vector2(0.925f, 0.992f),
|
|
new Color(0.02f, 0.05f, 0.12f, 0.75f));
|
|
|
|
CreateHeaderResourceBadge(resPanel, "HeaderScrapBadge", hud.scrapIconSprite, new Vector2(0.02f, 0.08f), new Vector2(0.33f, 0.92f),
|
|
new Color(0.85f, 0.92f, 1f), out headerScrapCountText);
|
|
|
|
CreateHeaderResourceBadge(resPanel, "HeaderGoldBadge", hud.goldIconSprite, new Vector2(0.35f, 0.08f), new Vector2(0.66f, 0.92f),
|
|
new Color(1f, 0.88f, 0.35f), out headerGoldCountText);
|
|
|
|
CreateHeaderResourceBadge(resPanel, "HeaderUraniumBadge", hud.uraniumIconSprite, new Vector2(0.68f, 0.08f), new Vector2(0.98f, 0.92f),
|
|
new Color(0.45f, 1f, 0.65f), out headerUraniumCountText);
|
|
|
|
hud.CreateButtonElement(
|
|
overlay,
|
|
"CloseTreeBtn",
|
|
"[ X ]",
|
|
new Vector2(0.935f, 0.935f),
|
|
new Vector2(0.985f, 0.99f),
|
|
hud.buttonOrangeSprite,
|
|
new Color(0.72f, 0.22f, 0.22f),
|
|
CloseModal,
|
|
out _,
|
|
15);
|
|
}
|
|
|
|
private void CreateHeaderResourceBadge(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("Icon", typeof(RectTransform), typeof(Image));
|
|
iconGo.transform.SetParent(badgeGo.transform, false);
|
|
RectTransform iRt = iconGo.GetComponent<RectTransform>();
|
|
iRt.anchorMin = new Vector2(0.02f, 0.06f);
|
|
iRt.anchorMax = new Vector2(0.32f, 0.94f);
|
|
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 = Color.white;
|
|
img.raycastTarget = false;
|
|
|
|
countLabel = hud.CreateTextElement(
|
|
badgeGo.transform,
|
|
"Count",
|
|
"0",
|
|
14,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.36f, 0f),
|
|
new Vector2(0.98f, 1f),
|
|
textColor);
|
|
}
|
|
|
|
private void BuildSubBarAndLegend(RectTransform overlay)
|
|
{
|
|
RectTransform subBar = hud.CreatePanelElement(
|
|
overlay,
|
|
"SubBar",
|
|
new Vector2(0.015f, 0.855f),
|
|
new Vector2(0.985f, 0.925f),
|
|
theme.subHeaderSurfaceColor);
|
|
|
|
stationInfoText = hud.CreateTextElement(
|
|
subBar,
|
|
"StationStatus",
|
|
"STATION LVL 1: TINY SATELLITE",
|
|
14,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.015f, 0.08f),
|
|
new Vector2(0.27f, 0.92f),
|
|
new Color(0.48f, 0.94f, 1f));
|
|
|
|
repairButton = hud.CreateButtonElement(
|
|
subBar,
|
|
"QuickRepairBtn",
|
|
"REPAIR HULL (+50 HP) [10 SCRAP]",
|
|
new Vector2(0.275f, 0.12f),
|
|
new Vector2(0.485f, 0.88f),
|
|
hud.buttonBlueSprite,
|
|
new Color(0.18f, 0.46f, 0.68f),
|
|
OnClickRepairStation,
|
|
out repairLabel,
|
|
12);
|
|
|
|
instantBuyBtn = hud.CreateButtonElement(
|
|
subBar,
|
|
"InstantBuyBtn",
|
|
"<color=#55FF77>[✓] INSTANT 1-STEP BUY</color>",
|
|
new Vector2(0.495f, 0.12f),
|
|
new Vector2(0.645f, 0.88f),
|
|
hud.buttonBlueSprite,
|
|
new Color(0.14f, 0.30f, 0.48f),
|
|
() =>
|
|
{
|
|
instantBuyEnabled = !instantBuyEnabled;
|
|
if (instantBuyToggleLabel != null)
|
|
{
|
|
instantBuyToggleLabel.text = instantBuyEnabled
|
|
? "<color=#55FF77>[✓] INSTANT 1-STEP BUY</color>"
|
|
: "[ ] INSTANT 1-STEP BUY";
|
|
}
|
|
Refresh();
|
|
},
|
|
out instantBuyToggleLabel,
|
|
12);
|
|
|
|
// Track Legend Badges on Right of SubBar
|
|
hud.CreateTextElement(
|
|
subBar,
|
|
"TrackLegend",
|
|
"<color=#40D1FF>■ DEFENSE</color> <color=#FFAD38>■ ORDNANCE</color> <color=#E073FF>■ CITADEL & ABILITIES</color> <color=#59F294>■ LOGISTICS</color>",
|
|
12,
|
|
TextAnchor.MiddleRight,
|
|
new Vector2(0.65f, 0.08f),
|
|
new Vector2(0.988f, 0.92f),
|
|
Color.white);
|
|
}
|
|
|
|
private void BuildConstellationGraphArea(RectTransform overlay)
|
|
{
|
|
RectTransform graphContainer = hud.CreatePanelElement(
|
|
overlay,
|
|
"ConstellationGraphContainer",
|
|
new Vector2(0.015f, 0.165f),
|
|
new Vector2(0.675f, 0.845f),
|
|
theme.panelSurfaceColor);
|
|
|
|
// Column Tier Header Bar inside graph
|
|
RectTransform tierHeaderBar = hud.CreatePanelElement(
|
|
graphContainer,
|
|
"TierColumnHeaderBar",
|
|
new Vector2(0f, 0.92f),
|
|
new Vector2(1f, 1f),
|
|
new Color(0.02f, 0.05f, 0.11f, 0.85f));
|
|
|
|
string[] tierTitles =
|
|
{
|
|
"CORE ROOT",
|
|
"TIER I: BASE",
|
|
"TIER II: SYSTEMS",
|
|
"TIER III: ADVANCED",
|
|
"TIER IV: HEAVY",
|
|
"TIER V: APEX"
|
|
};
|
|
float[] tierXCenters = { 0.07f, 0.24f, 0.42f, 0.60f, 0.77f, 0.93f };
|
|
for (int i = 0; i < tierTitles.Length; i++)
|
|
{
|
|
float cx = tierXCenters[i];
|
|
hud.CreateTextElement(
|
|
tierHeaderBar,
|
|
$"TierColHeader_{i}",
|
|
tierTitles[i],
|
|
11,
|
|
TextAnchor.MiddleCenter,
|
|
new Vector2(Mathf.Max(0.005f, cx - 0.075f), 0.05f),
|
|
new Vector2(Mathf.Min(0.995f, cx + 0.075f), 0.95f),
|
|
i == 0 ? new Color(0.45f, 0.95f, 1f, 0.95f) : new Color(0.65f, 0.82f, 0.98f, 0.85f));
|
|
}
|
|
|
|
// Inner Canvas where normalized (0..1, 0..1) nodes and conduits live
|
|
GameObject innerGo = new GameObject("GraphInnerCanvas", typeof(RectTransform));
|
|
innerGo.transform.SetParent(graphContainer, false);
|
|
graphCanvasRect = innerGo.GetComponent<RectTransform>();
|
|
graphCanvasRect.anchorMin = new Vector2(0.01f, 0.02f);
|
|
graphCanvasRect.anchorMax = new Vector2(0.99f, 0.91f);
|
|
graphCanvasRect.offsetMin = Vector2.zero;
|
|
graphCanvasRect.offsetMax = Vector2.zero;
|
|
|
|
// Subtle Left Track Watermark Labels
|
|
CreateTrackLaneWatermark(graphCanvasRect, "DEFENSE", 0.85f, theme.defenseTrackColor);
|
|
CreateTrackLaneWatermark(graphCanvasRect, "ORDNANCE", 0.64f, theme.ordnanceTrackColor);
|
|
CreateTrackLaneWatermark(graphCanvasRect, "CITADEL", 0.36f, theme.citadelTrackColor);
|
|
CreateTrackLaneWatermark(graphCanvasRect, "LOGISTICS", 0.14f, theme.logisticsTrackColor);
|
|
|
|
// Conduit Mesh Graphic (First sibling behind all sockets)
|
|
GameObject conduitGo = new GameObject("ConduitGraphicLayer", typeof(RectTransform), typeof(CanvasRenderer), typeof(TechTreeConduitGraphic));
|
|
conduitGo.transform.SetParent(graphCanvasRect, false);
|
|
RectTransform cRt = conduitGo.GetComponent<RectTransform>();
|
|
cRt.anchorMin = Vector2.zero;
|
|
cRt.anchorMax = Vector2.one;
|
|
cRt.offsetMin = Vector2.zero;
|
|
cRt.offsetMax = Vector2.zero;
|
|
conduitGraphic = conduitGo.GetComponent<TechTreeConduitGraphic>();
|
|
conduitGraphic.raycastTarget = false;
|
|
}
|
|
|
|
private void CreateTrackLaneWatermark(RectTransform parent, string label, float normY, Color trackCol)
|
|
{
|
|
Color c = new Color(trackCol.r, trackCol.g, trackCol.b, 0.32f);
|
|
hud.CreateTextElement(
|
|
parent,
|
|
$"TrackLabel_{label}",
|
|
label,
|
|
10,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.005f, Mathf.Clamp01(normY - 0.04f)),
|
|
new Vector2(0.14f, Mathf.Clamp01(normY + 0.04f)),
|
|
c);
|
|
}
|
|
|
|
private void BuildDetailInspectorCard(RectTransform overlay)
|
|
{
|
|
detailCardRoot = hud.CreatePanelElement(
|
|
overlay,
|
|
"TechTreeDetailCard",
|
|
new Vector2(0.685f, 0.165f),
|
|
new Vector2(0.985f, 0.845f),
|
|
theme.cardSurfaceColor);
|
|
|
|
RectTransform bannerRt = hud.CreatePanelElement(
|
|
detailCardRoot,
|
|
"TrackBanner",
|
|
new Vector2(0f, 0.91f),
|
|
new Vector2(1f, 1f),
|
|
new Color(0.10f, 0.24f, 0.42f, 0.95f));
|
|
detailTrackBanner = bannerRt.GetComponent<Image>();
|
|
|
|
detailCategoryBadge = hud.CreateTextElement(
|
|
bannerRt,
|
|
"CategoryBadge",
|
|
"★ COMMAND CORE ★",
|
|
13,
|
|
TextAnchor.MiddleCenter,
|
|
new Vector2(0.04f, 0.05f),
|
|
new Vector2(0.96f, 0.95f),
|
|
new Color(1f, 0.88f, 0.30f));
|
|
|
|
// Large Node Icon + Frame
|
|
GameObject iconBgGo = new GameObject("DetailIconBg", typeof(RectTransform), typeof(Image), typeof(Outline));
|
|
iconBgGo.transform.SetParent(detailCardRoot, false);
|
|
RectTransform iconBgRt = iconBgGo.GetComponent<RectTransform>();
|
|
iconBgRt.anchorMin = new Vector2(0.16f, 0.78f);
|
|
iconBgRt.anchorMax = new Vector2(0.16f, 0.78f);
|
|
iconBgRt.pivot = new Vector2(0.5f, 0.5f);
|
|
iconBgRt.sizeDelta = new Vector2(68f, 68f);
|
|
detailIconBg = iconBgGo.GetComponent<Image>();
|
|
detailIconBg.sprite = hud.roundSlotGoldSprite != null ? hud.roundSlotGoldSprite : hud.roundSlotCyanSprite;
|
|
detailIconBg.color = new Color(0.18f, 0.38f, 0.60f, 0.95f);
|
|
iconBgGo.GetComponent<Outline>().effectColor = new Color(0.35f, 0.85f, 1f, 0.75f);
|
|
|
|
GameObject dIconGo = new GameObject("DetailIcon", typeof(RectTransform), typeof(Image));
|
|
dIconGo.transform.SetParent(iconBgGo.transform, false);
|
|
RectTransform dIconRt = dIconGo.GetComponent<RectTransform>();
|
|
dIconRt.anchorMin = new Vector2(0.16f, 0.16f);
|
|
dIconRt.anchorMax = new Vector2(0.84f, 0.84f);
|
|
dIconRt.offsetMin = Vector2.zero;
|
|
dIconRt.offsetMax = Vector2.zero;
|
|
detailIcon = dIconGo.GetComponent<Image>();
|
|
detailIcon.preserveAspect = true;
|
|
detailIcon.raycastTarget = false;
|
|
|
|
detailTitle = hud.CreateTextElement(
|
|
detailCardRoot,
|
|
"DetailTitle",
|
|
"SELECT A TECH NODE",
|
|
18,
|
|
TextAnchor.LowerLeft,
|
|
new Vector2(0.31f, 0.77f),
|
|
new Vector2(0.96f, 0.89f),
|
|
new Color(0.45f, 0.96f, 1f));
|
|
|
|
detailRankStatus = hud.CreateTextElement(
|
|
detailCardRoot,
|
|
"DetailRank",
|
|
"RANK 0 / 5",
|
|
14,
|
|
TextAnchor.UpperLeft,
|
|
new Vector2(0.31f, 0.67f),
|
|
new Vector2(0.96f, 0.77f),
|
|
new Color(0.80f, 0.92f, 1f));
|
|
|
|
// Benefit & Effect Box
|
|
RectTransform descBox = hud.CreatePanelElement(
|
|
detailCardRoot,
|
|
"BenefitBox",
|
|
new Vector2(0.04f, 0.46f),
|
|
new Vector2(0.96f, 0.66f),
|
|
new Color(0.02f, 0.05f, 0.10f, 0.85f));
|
|
|
|
detailDescription = hud.CreateTextElement(
|
|
descBox,
|
|
"DetailDesc",
|
|
"Hover or gaze at any node in the constellation to inspect its upgrade path and requirements.",
|
|
14,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.04f, 0.04f),
|
|
new Vector2(0.96f, 0.96f),
|
|
Color.white);
|
|
|
|
// Prerequisite & Unlock Path Box
|
|
RectTransform prereqBox = hud.CreatePanelElement(
|
|
detailCardRoot,
|
|
"PrereqChecklistBox",
|
|
new Vector2(0.04f, 0.22f),
|
|
new Vector2(0.96f, 0.45f),
|
|
new Color(0.025f, 0.055f, 0.11f, 0.90f));
|
|
|
|
detailPrereqHeader = hud.CreateTextElement(
|
|
prereqBox,
|
|
"PrereqHeader",
|
|
"REQUIRED TECH PATH & GATES:",
|
|
12,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.04f, 0.76f),
|
|
new Vector2(0.96f, 0.98f),
|
|
new Color(0.65f, 0.85f, 1f));
|
|
|
|
detailPrereqChecklist = hud.CreateTextElement(
|
|
prereqBox,
|
|
"PrereqList",
|
|
"✓ Core Root Node",
|
|
13,
|
|
TextAnchor.UpperLeft,
|
|
new Vector2(0.04f, 0.04f),
|
|
new Vector2(0.96f, 0.75f),
|
|
Color.white);
|
|
|
|
detailCostText = hud.CreateTextElement(
|
|
detailCardRoot,
|
|
"DetailCost",
|
|
"",
|
|
15,
|
|
TextAnchor.MiddleCenter,
|
|
new Vector2(0.05f, 0.155f),
|
|
new Vector2(0.95f, 0.235f),
|
|
new Color(1f, 0.86f, 0.35f));
|
|
|
|
detailBuyButton = hud.CreateButtonElement(
|
|
detailCardRoot,
|
|
"DetailBuyBtn",
|
|
"[ RESEARCH UPGRADE ]",
|
|
new Vector2(0.06f, 0.03f),
|
|
new Vector2(0.94f, 0.14f),
|
|
hud.buttonGreenSprite,
|
|
new Color(0.16f, 0.68f, 0.38f),
|
|
OnDetailBuyClicked,
|
|
out detailBuyBtnLabel,
|
|
16);
|
|
}
|
|
|
|
private void BuildBottomLoadoutAndLaunchBar(RectTransform overlay)
|
|
{
|
|
RectTransform bottomBar = hud.CreatePanelElement(
|
|
overlay,
|
|
"BottomLoadoutBar",
|
|
new Vector2(0.015f, 0.015f),
|
|
new Vector2(0.985f, 0.150f),
|
|
theme.subHeaderSurfaceColor);
|
|
|
|
hud.CreateTextElement(
|
|
bottomBar,
|
|
"LoadoutTitle",
|
|
"STATION TURRET HARDPOINTS",
|
|
11,
|
|
TextAnchor.MiddleLeft,
|
|
new Vector2(0.012f, 0.76f),
|
|
new Vector2(0.35f, 0.98f),
|
|
new Color(0.45f, 0.92f, 1f));
|
|
|
|
hardpointWidgets.Clear();
|
|
const int maxDisplayedHardpoints = 4;
|
|
for (int i = 0; i < maxDisplayedHardpoints; i++)
|
|
{
|
|
float xMin = 0.01f + i * 0.175f;
|
|
float xMax = xMin + 0.168f;
|
|
HardpointSlotWidget w = CreateHardpointSlotWidget(bottomBar, i, new Vector2(xMin, 0.07f), new Vector2(xMax, 0.76f));
|
|
hardpointWidgets.Add(w);
|
|
}
|
|
|
|
launchWaveBtn = hud.CreateButtonElement(
|
|
bottomBar,
|
|
"LaunchWaveBtn",
|
|
"LAUNCH NEXT WAVE >>> [SPACE]",
|
|
new Vector2(0.725f, 0.12f),
|
|
new Vector2(0.988f, 0.88f),
|
|
hud.buttonGreenSprite,
|
|
new Color(0.15f, 0.68f, 0.38f),
|
|
OnLaunchOrResumeClicked,
|
|
out launchWaveLabel,
|
|
17,
|
|
KeyCode.Space);
|
|
}
|
|
|
|
private HardpointSlotWidget CreateHardpointSlotWidget(RectTransform parent, int slotIdx, Vector2 anchorMin, Vector2 anchorMax)
|
|
{
|
|
RectTransform card = hud.CreatePanelElement(
|
|
parent,
|
|
$"HardpointCard_{slotIdx}",
|
|
anchorMin,
|
|
anchorMax,
|
|
new Color(0.025f, 0.06f, 0.125f, 0.95f));
|
|
|
|
GameObject iconGo = new GameObject("WepIcon", typeof(RectTransform), typeof(Image));
|
|
iconGo.transform.SetParent(card, false);
|
|
RectTransform iRt = iconGo.GetComponent<RectTransform>();
|
|
iRt.anchorMin = new Vector2(0.03f, 0.15f);
|
|
iRt.anchorMax = new Vector2(0.24f, 0.85f);
|
|
iRt.offsetMin = Vector2.zero;
|
|
iRt.offsetMax = Vector2.zero;
|
|
Image iconImg = iconGo.GetComponent<Image>();
|
|
iconImg.preserveAspect = true;
|
|
iconImg.raycastTarget = false;
|
|
|
|
string slotRole = slotIdx == 0 ? "SLOT 1 [GAZE]" : $"SLOT {slotIdx + 1} [AUTO]";
|
|
Text headerTxt = hud.CreateTextElement(
|
|
card,
|
|
"SlotHeader",
|
|
slotRole,
|
|
11,
|
|
TextAnchor.LowerLeft,
|
|
new Vector2(0.26f, 0.54f),
|
|
new Vector2(0.62f, 0.95f),
|
|
slotIdx == 0 ? new Color(1f, 0.86f, 0.32f) : new Color(0.45f, 0.90f, 1f));
|
|
|
|
Text wepTxt = hud.CreateTextElement(
|
|
card,
|
|
"WepName",
|
|
"Vulcan Mk.I",
|
|
12,
|
|
TextAnchor.UpperLeft,
|
|
new Vector2(0.26f, 0.05f),
|
|
new Vector2(0.62f, 0.54f),
|
|
Color.white);
|
|
|
|
int capturedIdx = slotIdx;
|
|
Button swapBtn = hud.CreateButtonElement(
|
|
card,
|
|
"SwapWepBtn",
|
|
"SWAP",
|
|
new Vector2(0.63f, 0.52f),
|
|
new Vector2(0.97f, 0.92f),
|
|
hud.buttonBlueSprite,
|
|
new Color(0.18f, 0.42f, 0.65f),
|
|
() =>
|
|
{
|
|
if (SpaceStationController.Instance != null)
|
|
{
|
|
SpaceStationController.Instance.CycleSlotEquippedWeapon(capturedIdx);
|
|
RefreshLoadoutBar();
|
|
}
|
|
},
|
|
out Text swapLbl,
|
|
9);
|
|
|
|
Button prioBtn = hud.CreateButtonElement(
|
|
card,
|
|
"PrioBtn",
|
|
"AI: NEAR",
|
|
new Vector2(0.63f, 0.08f),
|
|
new Vector2(0.97f, 0.48f),
|
|
hud.buttonBlueSprite,
|
|
new Color(0.14f, 0.32f, 0.50f),
|
|
() =>
|
|
{
|
|
if (SpaceStationController.Instance != null)
|
|
{
|
|
SpaceStationController.Instance.CycleSlotTargetPriority(capturedIdx);
|
|
RefreshLoadoutBar();
|
|
}
|
|
},
|
|
out Text prioLbl,
|
|
9);
|
|
|
|
return new HardpointSlotWidget
|
|
{
|
|
slotIndex = slotIdx,
|
|
rootGo = card.gameObject,
|
|
backgroundImage = card.GetComponent<Image>(),
|
|
weaponIconImage = iconImg,
|
|
headerText = headerTxt,
|
|
weaponNameText = wepTxt,
|
|
swapWeaponButton = swapBtn,
|
|
swapWeaponLabel = swapLbl,
|
|
priorityButton = prioBtn,
|
|
priorityLabel = prioLbl
|
|
};
|
|
}
|
|
|
|
private TechNodeSocketWidget GetOrCreateSocketWidget(int index)
|
|
{
|
|
while (nodeSockets.Count <= index)
|
|
{
|
|
int idx = nodeSockets.Count;
|
|
GameObject socketGo = new GameObject($"TechNodeSocket_{idx}", typeof(RectTransform), typeof(Image), typeof(Button), typeof(DwellButton), typeof(Outline));
|
|
socketGo.transform.SetParent(graphCanvasRect, false);
|
|
RectTransform rt = socketGo.GetComponent<RectTransform>();
|
|
rt.pivot = new Vector2(0.5f, 0.5f);
|
|
rt.sizeDelta = new Vector2(54f, 54f);
|
|
|
|
// Outer highlight halo for prerequisite path & selection
|
|
GameObject glowGo = new GameObject("OuterHalo", typeof(RectTransform), typeof(Image));
|
|
glowGo.transform.SetParent(socketGo.transform, false);
|
|
RectTransform gRt = glowGo.GetComponent<RectTransform>();
|
|
gRt.anchorMin = new Vector2(-0.18f, -0.18f);
|
|
gRt.anchorMax = new Vector2(1.18f, 1.18f);
|
|
gRt.offsetMin = Vector2.zero;
|
|
gRt.offsetMax = Vector2.zero;
|
|
Image glowImg = glowGo.GetComponent<Image>();
|
|
glowImg.sprite = hud.roundSlotGoldSprite != null ? hud.roundSlotGoldSprite : hud.roundSlotCyanSprite;
|
|
glowImg.color = Color.clear;
|
|
glowImg.raycastTarget = false;
|
|
|
|
Image rim = socketGo.GetComponent<Image>();
|
|
rim.sprite = hud.roundSlotCyanSprite != null ? hud.roundSlotCyanSprite : hud.buttonBlueSprite;
|
|
|
|
Outline ol = socketGo.GetComponent<Outline>();
|
|
ol.effectColor = new Color(0.25f, 0.85f, 1f, 0.65f);
|
|
ol.effectDistance = new Vector2(2f, -2f);
|
|
|
|
Button btn = socketGo.GetComponent<Button>();
|
|
btn.targetGraphic = rim;
|
|
|
|
GameObject iconGo = new GameObject("SocketIcon", typeof(RectTransform), typeof(Image));
|
|
iconGo.transform.SetParent(socketGo.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;
|
|
|
|
// Compact node name above socket
|
|
Text nameLbl = hud.CreateTextElement(
|
|
socketGo.transform,
|
|
"ShortName",
|
|
"",
|
|
10,
|
|
TextAnchor.LowerCenter,
|
|
new Vector2(-0.95f, 0.96f),
|
|
new Vector2(1.95f, 1.48f),
|
|
new Color(0.82f, 0.92f, 1f, 0.92f));
|
|
|
|
// Rank / status pill below socket
|
|
Text rankBadge = hud.CreateTextElement(
|
|
socketGo.transform,
|
|
"RankBadge",
|
|
"0/5",
|
|
11,
|
|
TextAnchor.UpperCenter,
|
|
new Vector2(-0.95f, -0.48f),
|
|
new Vector2(1.95f, -0.02f),
|
|
Color.white);
|
|
|
|
var widget = new TechNodeSocketWidget
|
|
{
|
|
rootGo = socketGo,
|
|
rectTransform = rt,
|
|
button = btn,
|
|
dwellButton = socketGo.GetComponent<DwellButton>(),
|
|
outerGlowImage = glowImg,
|
|
socketRimImage = rim,
|
|
outline = ol,
|
|
iconImage = iconImg,
|
|
shortNameLabel = nameLbl,
|
|
rankBadgeText = rankBadge
|
|
};
|
|
|
|
widget.dwellButton.showDwellBar = false;
|
|
widget.dwellButton.Bind(
|
|
onClick: () => OnSocketActivated(widget),
|
|
dwellTime: 0.82f,
|
|
shortcut: KeyCode.None,
|
|
onHover: () => OnSocketHovered(widget));
|
|
|
|
nodeSockets.Add(widget);
|
|
}
|
|
|
|
return nodeSockets[index];
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
GazeLabGameManager gm = GazeLabGameManager.Instance;
|
|
SpaceStationController st = SpaceStationController.Instance;
|
|
if (gm == null || st == null || overlayRoot == null) return;
|
|
|
|
gm.EnsureUpgradeTreeDefinitionLoaded();
|
|
UpgradeTreeDefinitionSO tree = gm.upgradeTreeDefinition;
|
|
if (tree == null || tree.allNodes == null) return;
|
|
|
|
if (headerScrapCountText != null) headerScrapCountText.text = gm.scrapBank.ToString();
|
|
if (headerGoldCountText != null) headerGoldCountText.text = gm.goldBank.ToString();
|
|
if (headerUraniumCountText != null) headerUraniumCountText.text = gm.uraniumBank.ToString();
|
|
|
|
StationLevelDefinition curDef = st.CurrentLevelDef;
|
|
stationInfoText.text = $"STATION LVL {st.currentLevel}: {(curDef != null ? curDef.title.ToUpper() : "OUTPOST")} | HARDPOINTS: {st.TurretSlots.Count}";
|
|
|
|
bool canRepair = gm.CanAfford(new ResourceCost(10, 0, 0)) && st.StationDamageable != null && st.StationDamageable.currentHull < st.StationDamageable.maxHull;
|
|
int curHp = st.StationDamageable != null ? Mathf.CeilToInt(st.StationDamageable.currentHull) : 0;
|
|
int maxHp = st.StationDamageable != null ? Mathf.CeilToInt(st.StationDamageable.maxHull) : 0;
|
|
repairLabel.text = $"REPAIR HULL (+50 HP) [10 SCRAP] ({curHp}/{maxHp})";
|
|
repairButton.interactable = canRepair;
|
|
repairButton.GetComponent<Image>().color = canRepair ? new Color(0.18f, 0.46f, 0.68f) : new Color(0.14f, 0.18f, 0.24f, 0.65f);
|
|
|
|
int maxTier = Mathf.Max(5, tree.GetMaxTier());
|
|
UpgradeTreeNodeSO focusHighlightNode = currentlyHoveredNode != null ? currentlyHoveredNode : currentlySelectedNode;
|
|
HashSet<UpgradeTreeNodeSO> highlightedAncestors = tree.GetAncestorSet(focusHighlightNode);
|
|
|
|
Dictionary<UpgradeTreeNodeSO, TechNodeSocketWidget> widgetByNode = new Dictionary<UpgradeTreeNodeSO, TechNodeSocketWidget>();
|
|
int activeCount = 0;
|
|
|
|
for (int i = 0; i < tree.allNodes.Length; i++)
|
|
{
|
|
UpgradeTreeNodeSO node = tree.allNodes[i];
|
|
if (node == null) continue;
|
|
|
|
TechNodeSocketWidget socket = GetOrCreateSocketWidget(activeCount);
|
|
activeCount++;
|
|
|
|
socket.rootGo.SetActive(true);
|
|
socket.boundNode = node;
|
|
|
|
Vector2 normPos = node.GetNormalizedCanvasPosition(maxTier);
|
|
socket.normalizedPos = normPos;
|
|
socket.rectTransform.anchorMin = normPos;
|
|
socket.rectTransform.anchorMax = normPos;
|
|
socket.rectTransform.anchoredPosition = Vector2.zero;
|
|
|
|
int currentRank = gm.GetNodeRank(node.nodeId);
|
|
int maxRank = Mathf.Max(1, node.maxRank);
|
|
bool isMaxed = currentRank >= maxRank;
|
|
int reqWave = node.GetRequiredWaveForRank(currentRank + 1);
|
|
bool isWaveLocked = !isMaxed && gm.highestWaveCleared < reqWave;
|
|
bool prereqsMet = gm.TechTree.ArePrerequisitesMet(node, out _);
|
|
bool isPrereqLocked = !isMaxed && !prereqsMet;
|
|
|
|
ResourceCost nextCost = node.GetCostForRank(currentRank + 1);
|
|
bool canAfford = gm.CanAfford(nextCost);
|
|
|
|
Color trackCol = theme.GetTrackColor(node.branchTrack);
|
|
Sprite containerSprite = hud.GetNodeContainerSprite(node, out Vector2 socketSize);
|
|
socket.rectTransform.sizeDelta = socketSize;
|
|
socket.socketRimImage.sprite = containerSprite;
|
|
socket.outline.effectDistance = socketSize.x > 60f ? new Vector2(2.5f, -2.5f) : (socketSize.x > 50f ? new Vector2(2f, -2f) : new Vector2(1.5f, -1.5f));
|
|
|
|
socket.iconImage.sprite = node.icon != null
|
|
? node.icon
|
|
: TechTreeManager.GetProceduralStatIcon(node.category, node.statType);
|
|
|
|
socket.shortNameLabel.text = CompactNodeTitle(node.displayName);
|
|
|
|
bool isSelectedOrHovered = (node == focusHighlightNode);
|
|
bool isOnHighlightedPath = highlightedAncestors.Contains(node) && !isMaxed;
|
|
|
|
if (isSelectedOrHovered)
|
|
{
|
|
socket.outerGlowImage.color = new Color(1f, 0.92f, 0.35f, 0.75f);
|
|
}
|
|
else if (isOnHighlightedPath)
|
|
{
|
|
socket.outerGlowImage.color = new Color(1f, 0.68f, 0.18f, 0.58f);
|
|
}
|
|
else
|
|
{
|
|
socket.outerGlowImage.color = Color.clear;
|
|
}
|
|
|
|
if (isMaxed)
|
|
{
|
|
socket.button.interactable = !instantBuyEnabled;
|
|
socket.dwellButton.isDwellEnabled = false;
|
|
socket.socketRimImage.color = theme.nodeMaxedColor;
|
|
socket.iconImage.color = Color.white;
|
|
socket.outline.effectColor = new Color(0.45f, 1f, 0.65f, 0.85f);
|
|
socket.rankBadgeText.text = maxRank > 1 ? $"<color=#55FF77>★ {currentRank}/{maxRank}</color>" : "<color=#55FF77>✓ ACTIVE</color>";
|
|
}
|
|
else if (isWaveLocked || isPrereqLocked)
|
|
{
|
|
socket.button.interactable = !instantBuyEnabled;
|
|
socket.dwellButton.isDwellEnabled = false;
|
|
socket.socketRimImage.color = isOnHighlightedPath
|
|
? new Color(0.55f, 0.38f, 0.14f, 0.90f)
|
|
: theme.nodeLockedColor;
|
|
socket.iconImage.color = isOnHighlightedPath
|
|
? new Color(0.95f, 0.82f, 0.55f, 0.85f)
|
|
: new Color(0.42f, 0.48f, 0.58f, 0.55f);
|
|
socket.outline.effectColor = isOnHighlightedPath
|
|
? theme.highlightPathColor
|
|
: new Color(0.18f, 0.22f, 0.32f, 0.45f);
|
|
socket.rankBadgeText.text = isWaveLocked
|
|
? $"<color=#FF8866>W{reqWave}🔒</color>"
|
|
: (currentRank > 0 ? $"{currentRank}/{maxRank}" : "<color=#99AABB>🔒</color>");
|
|
}
|
|
else
|
|
{
|
|
// Unlockable right now (or partially ranked up)
|
|
socket.button.interactable = true;
|
|
|
|
if (canAfford)
|
|
{
|
|
socket.dwellButton.isDwellEnabled = true;
|
|
socket.socketRimImage.color = node.isMajorNode ? theme.nodeAvailableMajorColor : Color.Lerp(trackCol, theme.nodeAvailableMinorColor, 0.5f);
|
|
socket.iconImage.color = Color.white;
|
|
socket.outline.effectColor = new Color(1f, 0.92f, 0.40f, 0.95f);
|
|
socket.rankBadgeText.text = maxRank > 1
|
|
? $"<color=#55FF77>{currentRank}/{maxRank} ▲</color>"
|
|
: "<color=#FFE066>READY</color>";
|
|
}
|
|
else
|
|
{
|
|
// Unlocked but not enough resources for next rank:
|
|
// 1. Disable cursor fill indicator (so dwelling does not misleadingly charge)
|
|
socket.dwellButton.isDwellEnabled = false;
|
|
// 2. Tint the whole circular icon, rim, and outline red
|
|
socket.socketRimImage.color = new Color(0.75f, 0.15f, 0.18f, 0.95f);
|
|
socket.iconImage.color = new Color(1f, 0.45f, 0.45f, 0.90f);
|
|
socket.outline.effectColor = new Color(0.92f, 0.18f, 0.18f, 0.85f);
|
|
socket.rankBadgeText.text = maxRank > 1
|
|
? $"<color=#FF7777>{currentRank}/{maxRank}</color>"
|
|
: $"<color=#FF7777>{nextCost.scrap}S</color>";
|
|
}
|
|
}
|
|
|
|
widgetByNode[node] = socket;
|
|
}
|
|
|
|
for (int i = activeCount; i < nodeSockets.Count; i++)
|
|
{
|
|
nodeSockets[i].rootGo.SetActive(false);
|
|
nodeSockets[i].boundNode = null;
|
|
}
|
|
|
|
RebuildConduitEdges(gm, tree, widgetByNode, focusHighlightNode, highlightedAncestors);
|
|
|
|
if (currentlySelectedNode == null && tree.allNodes.Length > 0)
|
|
{
|
|
currentlySelectedNode = tree.allNodes[0];
|
|
}
|
|
if (currentlySelectedNode != null)
|
|
{
|
|
PopulateDetailInspector(currentlySelectedNode);
|
|
}
|
|
|
|
RefreshLoadoutBar();
|
|
|
|
bool isInterWave = gm.IsInterWave;
|
|
if (launchWaveLabel != null)
|
|
{
|
|
launchWaveLabel.text = isInterWave ? "LAUNCH NEXT WAVE >>> [SPACE]" : "BACK TO MISSION >>> [ESC / SPACE]";
|
|
}
|
|
if (launchWaveBtn != null)
|
|
{
|
|
Image btnImg = launchWaveBtn.GetComponent<Image>();
|
|
if (btnImg != null)
|
|
{
|
|
btnImg.color = isInterWave ? new Color(0.15f, 0.68f, 0.38f) : new Color(0.18f, 0.46f, 0.72f);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RebuildConduitEdges(
|
|
GazeLabGameManager gm,
|
|
UpgradeTreeDefinitionSO tree,
|
|
Dictionary<UpgradeTreeNodeSO, TechNodeSocketWidget> widgetByNode,
|
|
UpgradeTreeNodeSO focusNode,
|
|
HashSet<UpgradeTreeNodeSO> highlightedAncestors)
|
|
{
|
|
conduitEdgesBuffer.Clear();
|
|
|
|
for (int i = 0; i < tree.allNodes.Length; i++)
|
|
{
|
|
UpgradeTreeNodeSO child = tree.allNodes[i];
|
|
if (child == null || !widgetByNode.TryGetValue(child, out TechNodeSocketWidget childWidget))
|
|
continue;
|
|
|
|
bool childInHighlightChain = (child == focusNode) || highlightedAncestors.Contains(child);
|
|
Color trackCol = theme.GetTrackColor(child.branchTrack);
|
|
|
|
var prereqs = gm.TechTree.EvaluatePrerequisites(child);
|
|
for (int p = 0; p < prereqs.Count; p++)
|
|
{
|
|
PrerequisiteStatus req = prereqs[p];
|
|
if (req.parentNode == null || !widgetByNode.TryGetValue(req.parentNode, out TechNodeSocketWidget parentWidget))
|
|
continue;
|
|
|
|
bool childPurchased = gm.IsNodePurchased(child.nodeId);
|
|
ConduitVisualState edgeState;
|
|
|
|
if (childPurchased && req.isSatisfied)
|
|
{
|
|
edgeState = ConduitVisualState.Purchased;
|
|
}
|
|
else if (childInHighlightChain && !req.isSatisfied)
|
|
{
|
|
edgeState = ConduitVisualState.HighlightedPath;
|
|
}
|
|
else if (req.isSatisfied)
|
|
{
|
|
edgeState = ConduitVisualState.Unlockable;
|
|
}
|
|
else
|
|
{
|
|
edgeState = ConduitVisualState.Locked;
|
|
}
|
|
|
|
conduitEdgesBuffer.Add(new ConduitEdgeData
|
|
{
|
|
startNormalized = parentWidget.normalizedPos,
|
|
endNormalized = childWidget.normalizedPos,
|
|
state = edgeState,
|
|
trackAccentColor = trackCol
|
|
});
|
|
}
|
|
}
|
|
|
|
if (conduitGraphic != null)
|
|
{
|
|
conduitGraphic.SetEdges(conduitEdgesBuffer);
|
|
}
|
|
}
|
|
|
|
public void UpdatePulseAnimations()
|
|
{
|
|
if (!IsOpen || GazeLabGameManager.Instance == null) return;
|
|
GazeLabGameManager gm = GazeLabGameManager.Instance;
|
|
|
|
float ping = Mathf.PingPong(Time.unscaledTime * 2.6f, 1f);
|
|
Color pulseCol = Color.Lerp(new Color(0.28f, 0.88f, 1f, 0.55f), new Color(1f, 0.88f, 0.25f, 0.98f), ping);
|
|
|
|
for (int i = 0; i < nodeSockets.Count; i++)
|
|
{
|
|
TechNodeSocketWidget s = nodeSockets[i];
|
|
if (s.rootGo.activeSelf && s.boundNode != null && gm.CanPurchaseNode(s.boundNode))
|
|
{
|
|
s.outline.effectColor = pulseCol;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnSocketHovered(TechNodeSocketWidget socket)
|
|
{
|
|
if (socket == null || socket.boundNode == null) return;
|
|
currentlyHoveredNode = socket.boundNode;
|
|
currentlySelectedNode = socket.boundNode;
|
|
Refresh();
|
|
}
|
|
|
|
private void OnSocketActivated(TechNodeSocketWidget socket)
|
|
{
|
|
if (socket == null || socket.boundNode == null) return;
|
|
currentlySelectedNode = socket.boundNode;
|
|
|
|
if (instantBuyEnabled)
|
|
{
|
|
TryPurchaseNode(socket.boundNode);
|
|
}
|
|
else
|
|
{
|
|
if (SpaceAudioController.Instance != null)
|
|
SpaceAudioController.Instance.PlayClick();
|
|
Refresh();
|
|
}
|
|
}
|
|
|
|
private void OnDetailBuyClicked()
|
|
{
|
|
if (currentlySelectedNode != null)
|
|
{
|
|
TryPurchaseNode(currentlySelectedNode);
|
|
}
|
|
}
|
|
|
|
private void TryPurchaseNode(UpgradeTreeNodeSO node)
|
|
{
|
|
if (node == null || GazeLabGameManager.Instance == null) return;
|
|
if (GazeLabGameManager.Instance.TryPurchaseNode(node))
|
|
{
|
|
Refresh();
|
|
}
|
|
}
|
|
|
|
private void PopulateDetailInspector(UpgradeTreeNodeSO node)
|
|
{
|
|
GazeLabGameManager gm = GazeLabGameManager.Instance;
|
|
if (node == null || gm == null) return;
|
|
|
|
int curRank = gm.GetNodeRank(node.nodeId);
|
|
int maxRk = Mathf.Max(1, node.maxRank);
|
|
bool isMaxed = curRank >= maxRk;
|
|
int reqWave = node.GetRequiredWaveForRank(curRank + 1);
|
|
bool isWaveLocked = !isMaxed && gm.highestWaveCleared < reqWave;
|
|
|
|
Color trackCol = theme.GetTrackColor(node.branchTrack);
|
|
if (detailTrackBanner != null)
|
|
{
|
|
detailTrackBanner.color = new Color(trackCol.r * 0.32f, trackCol.g * 0.32f, trackCol.b * 0.38f, 0.95f);
|
|
}
|
|
|
|
string trackName = GazeLabUIThemeSO.GetTrackDisplayName(node.branchTrack);
|
|
string catType = node.category == TechNodeCategory.WeaponUnlock ? "WEAPON SYSTEM"
|
|
: (node.category == TechNodeCategory.AbilityUnlock ? "TACTICAL ABILITY"
|
|
: (node.category == TechNodeCategory.StationEvolution ? "CITADEL EVOLUTION" : "PASSIVE AUGMENT"));
|
|
detailCategoryBadge.text = $"{trackName} • {catType}";
|
|
detailCategoryBadge.color = trackCol;
|
|
|
|
detailIcon.sprite = node.icon != null
|
|
? node.icon
|
|
: TechTreeManager.GetProceduralStatIcon(node.category, node.statType);
|
|
detailIconBg.sprite = hud.GetNodeContainerSprite(node, out _);
|
|
detailIconBg.color = isMaxed ? theme.nodeMaxedColor : trackCol;
|
|
|
|
detailTitle.text = node.displayName.ToUpper();
|
|
detailRankStatus.text = isMaxed
|
|
? $"<color=#55FF77>RANK {curRank} / {maxRk} [MAXIMUM RANK]</color>"
|
|
: $"RANK {curRank} / {maxRk} <color=#FFE066>(Next: Rank {curRank + 1})</color>";
|
|
|
|
// Build specific next-rank benefit preview
|
|
string extraInfo = BuildProgressionPreviewText(node, curRank, maxRk);
|
|
detailDescription.text = $"{node.shortBenefit}\n<color=#99CCFF>{extraInfo}</color>";
|
|
|
|
// Build Prerequisite & Wave Gate Checklist
|
|
var prereqs = gm.TechTree.EvaluatePrerequisites(node);
|
|
bool allPrereqsMet = true;
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
|
if (prereqs.Count == 0 && reqWave <= 0)
|
|
{
|
|
sb.AppendLine("<color=#55FF77>✓ Base Root Tech (No Prerequisites)</color>");
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < prereqs.Count; i++)
|
|
{
|
|
PrerequisiteStatus p = prereqs[i];
|
|
if (p.isSatisfied)
|
|
{
|
|
sb.AppendLine($"<color=#55FF77>✓ {p.parentNode.displayName} (Rank {p.currentRank}/{p.requiredRank})</color>");
|
|
}
|
|
else
|
|
{
|
|
allPrereqsMet = false;
|
|
sb.AppendLine($"<color=#FFAA44>🔒 {p.parentNode.displayName} — Need Rank {p.requiredRank} (Have {p.currentRank})</color>");
|
|
}
|
|
}
|
|
|
|
if (reqWave > 0)
|
|
{
|
|
if (gm.highestWaveCleared >= reqWave)
|
|
{
|
|
sb.AppendLine($"<color=#55FF77>✓ Clear Sector Wave {reqWave} (Cleared: {gm.highestWaveCleared})</color>");
|
|
}
|
|
else
|
|
{
|
|
sb.AppendLine($"<color=#FF7777>🔒 Clear Sector Wave {reqWave} (Cleared: {gm.highestWaveCleared})</color>");
|
|
}
|
|
}
|
|
}
|
|
|
|
detailPrereqChecklist.text = sb.ToString().TrimEnd();
|
|
|
|
ResourceCost nextCost = node.GetCostForRank(curRank + 1);
|
|
bool canAfford = gm.CanAfford(nextCost);
|
|
|
|
if (isMaxed)
|
|
{
|
|
detailCostText.text = "<color=#55FF77>✓ FULLY RESEARCHED</color>";
|
|
detailBuyButton.interactable = false;
|
|
detailBuyBtnLabel.text = "MAX RANK REACHED";
|
|
detailBuyButton.GetComponent<Image>().color = new Color(0.12f, 0.26f, 0.18f, 0.75f);
|
|
}
|
|
else if (!allPrereqsMet || isWaveLocked)
|
|
{
|
|
detailCostText.text = $"NEXT RANK COST: {FormatColoredCost(gm, nextCost)}";
|
|
detailBuyButton.interactable = false;
|
|
detailBuyBtnLabel.text = isWaveLocked ? $"LOCKED UNTIL WAVE {reqWave} CLEARED" : "UNLOCK HIGHLIGHTED PATH FIRST";
|
|
detailBuyButton.GetComponent<Image>().color = new Color(0.22f, 0.20f, 0.16f, 0.75f);
|
|
}
|
|
else
|
|
{
|
|
detailCostText.text = $"NEXT RANK COST: {FormatColoredCost(gm, nextCost)}";
|
|
detailBuyButton.interactable = canAfford;
|
|
detailBuyBtnLabel.text = canAfford
|
|
? (curRank == 0 ? "[ UNLOCK TECH ]" : $"[ UPGRADE TO RANK {curRank + 1} ]")
|
|
: "INSUFFICIENT RESOURCES";
|
|
detailBuyButton.GetComponent<Image>().color = canAfford
|
|
? new Color(0.16f, 0.68f, 0.38f)
|
|
: new Color(0.20f, 0.22f, 0.28f, 0.70f);
|
|
}
|
|
}
|
|
|
|
private static string BuildProgressionPreviewText(UpgradeTreeNodeSO node, int curRank, int maxRank)
|
|
{
|
|
switch (node.category)
|
|
{
|
|
case TechNodeCategory.StatBuff:
|
|
float step = node.GetSingleRankStatStep();
|
|
bool isPct = step < 1.0f && node.statType != TechStatType.MagnetRange;
|
|
string curStr = isPct ? $"+{Mathf.RoundToInt(curRank * step * 100f)}%" : $"+{curRank * step:0.#}";
|
|
string nextStr = isPct ? $"+{Mathf.RoundToInt( Mathf.Min(maxRank, curRank + 1) * step * 100f )}%" : $"+{Mathf.Min(maxRank, curRank + 1) * step:0.#}";
|
|
return curRank >= maxRank
|
|
? $"Total Cumulative Bonus: {curStr}"
|
|
: $"Cumulative Bonus: {curStr} >>> {nextStr}";
|
|
|
|
case TechNodeCategory.WeaponUnlock:
|
|
WeaponDefinition nextWep = node.GetWeaponForRank(Mathf.Min(maxRank, curRank + 1));
|
|
if (nextWep != null)
|
|
{
|
|
float dps = nextWep.projectile != null ? nextWep.projectile.baseDamage * nextWep.shotsPerSecond * Mathf.Max(1, nextWep.barrelCount) : 0f;
|
|
return $"Mounts: {nextWep.displayName} (Tier {nextWep.tierLevel} • ~{Mathf.RoundToInt(dps)} DPS)";
|
|
}
|
|
return "Unlocks & upgrades weapon family in your station arsenal.";
|
|
|
|
case TechNodeCategory.AbilityUnlock:
|
|
int nextTier = Mathf.Min(maxRank, curRank + 1);
|
|
if (node.unlockedAbility != null && node.unlockedAbility.abilityType == StationAbilityType.HarpoonGrappleChain)
|
|
{
|
|
int chains = node.unlockedAbility.baseChainCount + (nextTier - 1);
|
|
return $"Tier {nextTier}: Fires {chains} Harpoon Chain(s) to immobilize & reel in Bosses.";
|
|
}
|
|
return $"Tier {nextTier}: Increases ability potency & effectiveness.";
|
|
|
|
case TechNodeCategory.StationEvolution:
|
|
return "Evolves station hull, increases base Hull/Shield, and unlocks additional turret hardpoints.";
|
|
}
|
|
return string.Empty;
|
|
}
|
|
|
|
public void RefreshLoadoutBar()
|
|
{
|
|
SpaceStationController st = SpaceStationController.Instance;
|
|
if (st == null) return;
|
|
|
|
var slots = st.TurretSlots;
|
|
bool canSwapWeapons = st.UnlockedWeapons != null && st.UnlockedWeapons.Count > 1;
|
|
|
|
for (int i = 0; i < hardpointWidgets.Count; i++)
|
|
{
|
|
HardpointSlotWidget w = hardpointWidgets[i];
|
|
if (i < slots.Count && slots[i].isUnlocked)
|
|
{
|
|
StationTurretSlotState s = slots[i];
|
|
w.backgroundImage.color = new Color(0.04f, 0.11f, 0.22f, 0.96f);
|
|
w.headerText.text = i == 0 ? "SLOT 1 [PRIMARY GAZE]" : $"SLOT {i + 1} [AUTO TURRET]";
|
|
w.headerText.color = i == 0 ? new Color(1f, 0.86f, 0.32f) : new Color(0.45f, 0.92f, 1f);
|
|
|
|
if (s.equippedWeapon != null)
|
|
{
|
|
w.weaponIconImage.enabled = true;
|
|
w.weaponIconImage.sprite = s.equippedWeapon.weaponSprite != null
|
|
? s.equippedWeapon.weaponSprite
|
|
: TechTreeManager.GetProceduralStatIcon(TechNodeCategory.WeaponUnlock, TechStatType.TurretDamage);
|
|
w.weaponIconImage.color = Color.white;
|
|
w.weaponNameText.text = CompactNodeTitle(s.equippedWeapon.displayName);
|
|
}
|
|
else
|
|
{
|
|
w.weaponIconImage.enabled = false;
|
|
w.weaponNameText.text = "Empty Slot";
|
|
}
|
|
|
|
w.swapWeaponButton.gameObject.SetActive(true);
|
|
w.swapWeaponButton.interactable = canSwapWeapons;
|
|
w.swapWeaponLabel.text = canSwapWeapons ? $"SWAP ({st.UnlockedWeapons.Count})" : "1 WPN";
|
|
|
|
bool isAuto = i > 0 || st.currentLevel >= 3;
|
|
w.priorityButton.gameObject.SetActive(isAuto);
|
|
if (isAuto)
|
|
{
|
|
w.priorityLabel.text = FormatPriorityShort(s.priority);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
w.backgroundImage.color = new Color(0.02f, 0.04f, 0.08f, 0.70f);
|
|
w.headerText.text = $"SLOT {i + 1} [LOCKED]";
|
|
w.headerText.color = new Color(0.45f, 0.52f, 0.62f);
|
|
w.weaponIconImage.enabled = false;
|
|
w.weaponNameText.text = "<color=#778899>🔒 Evolve Station</color>";
|
|
w.swapWeaponButton.gameObject.SetActive(false);
|
|
w.priorityButton.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static string FormatPriorityShort(TurretTargetPriority p)
|
|
{
|
|
switch (p)
|
|
{
|
|
case TurretTargetPriority.HighestHealthOrBoss: return "AI: BOSS";
|
|
case TurretTargetPriority.ShieldedEnemies: return "AI: SHLD";
|
|
case TurretTargetPriority.AsteroidsAndLoot: return "AI: LOOT";
|
|
default: return "AI: NEAR";
|
|
}
|
|
}
|
|
|
|
private static string CompactNodeTitle(string name)
|
|
{
|
|
if (string.IsNullOrEmpty(name)) return "";
|
|
return name.Length > 20 ? name.Substring(0, 19) + "…" : name;
|
|
}
|
|
|
|
private static string FormatColoredCost(GazeLabGameManager gm, ResourceCost c)
|
|
{
|
|
List<string> parts = new List<string>();
|
|
if (c.scrap > 0)
|
|
{
|
|
string col = gm.scrapBank >= c.scrap ? "#88FFAA" : "#FF6666";
|
|
parts.Add($"<color={col}>{c.scrap} SCRAP</color>");
|
|
}
|
|
if (c.gold > 0)
|
|
{
|
|
string col = gm.goldBank >= c.gold ? "#FFE066" : "#FF6666";
|
|
parts.Add($"<color={col}>{c.gold} GOLD</color>");
|
|
}
|
|
if (c.uranium > 0)
|
|
{
|
|
string col = gm.uraniumBank >= c.uranium ? "#66FFCC" : "#FF6666";
|
|
parts.Add($"<color={col}>{c.uranium} URANIUM</color>");
|
|
}
|
|
return parts.Count > 0 ? string.Join(" ", parts) : "<color=#88FFAA>FREE</color>";
|
|
}
|
|
|
|
private void OnClickRepairStation()
|
|
{
|
|
GazeLabGameManager gm = GazeLabGameManager.Instance;
|
|
SpaceStationController st = SpaceStationController.Instance;
|
|
if (gm == null || st == null || st.StationDamageable == null) return;
|
|
if (st.StationDamageable.currentHull >= st.StationDamageable.maxHull) return;
|
|
|
|
if (gm.TrySpendResources(new ResourceCost(10, 0, 0)))
|
|
{
|
|
st.StationDamageable.currentHull = Mathf.Min(st.StationDamageable.maxHull, st.StationDamageable.currentHull + 50f);
|
|
Refresh();
|
|
}
|
|
}
|
|
|
|
public void CloseModal()
|
|
{
|
|
if (hud != null)
|
|
{
|
|
hud.CloseTechTree();
|
|
}
|
|
else if (overlayRoot != null)
|
|
{
|
|
overlayRoot.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OpenModal()
|
|
{
|
|
if (hud != null)
|
|
{
|
|
hud.OpenTechTree();
|
|
}
|
|
else if (overlayRoot != null)
|
|
{
|
|
overlayRoot.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void ToggleModal()
|
|
{
|
|
if (IsOpen) CloseModal();
|
|
else OpenModal();
|
|
}
|
|
|
|
private void OnLaunchOrResumeClicked()
|
|
{
|
|
if (overlayRoot != null) overlayRoot.SetActive(false);
|
|
if (hud != null) hud.SetCenterWavePromptRequested(false);
|
|
GazeLabGameManager gm = GazeLabGameManager.Instance;
|
|
if (gm == null) return;
|
|
|
|
bool isInterWave = gm.IsInterWave;
|
|
if (isInterWave)
|
|
{
|
|
gm.StartNextWaveFromShop();
|
|
}
|
|
else
|
|
{
|
|
gm.ResumeGameSession();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|