diff --git a/Assets/Scripts/MainMenu.cs b/Assets/Scripts/MainMenu.cs index 4b5dd90..a5e112d 100644 --- a/Assets/Scripts/MainMenu.cs +++ b/Assets/Scripts/MainMenu.cs @@ -15,6 +15,7 @@ public class MainMenu : MonoBehaviour RectTransform contentRoot; TextMeshProUGUI homeTabLabel; TextMeshProUGUI towersTabLabel; + TextMeshProUGUI deckTabLabel; void Start() { @@ -123,6 +124,8 @@ public class MainMenu : MonoBehaviour homeTabLabel = homeButton.GetComponentInChildren(); Button towersButton = CreateButton("TowersButton", nav, "TOWERS", () => ShowTowers()); towersTabLabel = towersButton.GetComponentInChildren(); + Button deckButton = CreateButton("DeckButton", nav, "DECK", () => ShowDeck()); + deckTabLabel = deckButton.GetComponentInChildren(); contentRoot = CreatePanel("Content", root, UITheme.Panel); contentRoot.anchorMin = new Vector2(0.5f, 0.5f); @@ -143,7 +146,7 @@ public class MainMenu : MonoBehaviour void ShowHome() { - SetTabState(true); + SetTabState(homeTabLabel); ClearContent(); int stage = Mathf.Max(1, PlayerPrefs.GetInt(CurrentStageKey, 1)); @@ -165,7 +168,7 @@ public class MainMenu : MonoBehaviour void ShowTowers() { - SetTabState(false); + SetTabState(towersTabLabel); ClearContent(); TextMeshProUGUI heading = CreateText("Heading", contentRoot, "TOWERS", 26f, FontStyles.Bold, TextAlignmentOptions.Center); @@ -176,6 +179,118 @@ public class MainMenu : MonoBehaviour CreateTowerCard("TeslaTowerCard", "TESLA TOWER", "Rapid arcs with longer range and steadier damage.", TeslaTowerId, IsTowerUnlocked(TeslaTowerId), 216f); } + void ShowDeck() + { + SetTabState(deckTabLabel); + ClearContent(); + + string selectedTower = PlayerPrefs.GetString(SelectedTowerKey, CannonTowerId); + string towerName = selectedTower == TeslaTowerId ? "TESLA TOWER" : "CANNON TOWER"; + TextMeshProUGUI heading = CreateText("Heading", contentRoot, $"{towerName} DECK", 24f, FontStyles.Bold, TextAlignmentOptions.Center); + PlaceTop(heading.rectTransform, -22f, 32f); + heading.color = UITheme.CyanBright; + + TextMeshProUGUI detail = CreateText("Detail", contentRoot, "CURRENTLY EQUIPPED TOWER // ALL CARDS", 12f, FontStyles.Bold, TextAlignmentOptions.Center); + PlaceTop(detail.rectTransform, -52f, 20f); + detail.color = UITheme.TextMuted; + + RectTransform scrollView = CreateRect("DeckScrollView", contentRoot); + PlaceCenter(scrollView, 0f, -38f, 604f, 248f); + ScrollRect scrollRect = scrollView.gameObject.AddComponent(); + scrollRect.horizontal = false; + scrollRect.vertical = true; + scrollRect.movementType = ScrollRect.MovementType.Clamped; + scrollRect.scrollSensitivity = 22f; + + RectTransform viewport = CreatePanel("Viewport", scrollView, new Color(0.025f, 0.04f, 0.06f, 0.72f)); + viewport.anchorMin = Vector2.zero; + viewport.anchorMax = Vector2.one; + viewport.offsetMin = Vector2.zero; + viewport.offsetMax = Vector2.zero; + Mask mask = viewport.gameObject.AddComponent(); + mask.showMaskGraphic = true; + + RectTransform grid = CreateRect("Cards", viewport); + grid.anchorMin = new Vector2(0f, 1f); + grid.anchorMax = new Vector2(1f, 1f); + grid.pivot = new Vector2(0.5f, 1f); + grid.anchoredPosition = Vector2.zero; + grid.sizeDelta = Vector2.zero; + GridLayoutGroup layout = grid.gameObject.AddComponent(); + layout.padding = new RectOffset(12, 12, 12, 12); + layout.cellSize = new Vector2(184f, 94f); + layout.spacing = new Vector2(12f, 12f); + layout.constraint = GridLayoutGroup.Constraint.FixedColumnCount; + layout.constraintCount = 3; + ContentSizeFitter fitter = grid.gameObject.AddComponent(); + fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; + + scrollRect.viewport = viewport; + scrollRect.content = grid; + + foreach (UpgradeManager.CardDefinition card in UpgradeManager.GetCardsForTower(selectedTower)) + CreateDeckCard(grid, card); + } + + void CreateDeckCard(Transform parent, UpgradeManager.CardDefinition definition) + { + RectTransform card = CreatePanel(definition.title + "Card", parent, UITheme.PanelRaised); + UITheme.AddTopAccent(card, GetRarityColor(definition.rarity), 3f); + Button button = card.gameObject.AddComponent