LobbyPanels.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace DiamondArrow
  4. {
  5. public sealed partial class DiamondArrowGame
  6. {
  7. string checkinDisplayedDate;
  8. public void ShowCheckin()
  9. {
  10. checkinDisplayedDate = Today;
  11. bool claimed = Save.checkinDate == checkinDisplayedDate;
  12. int current = claimed ? (Save.checkinDay + 5) % 7 + 1 : Save.checkinDay;
  13. var page = Sheet("DAILY CHECK-IN", 944);
  14. for (int day = 1; day <= 7; day++)
  15. {
  16. bool finale = day == 7;
  17. bool collected = day < current || (day == current && claimed);
  18. bool available = day == current && !claimed;
  19. const float margin = 40, gap = 24, height = 138;
  20. float fullWidth = page.rect.width - 2 * margin;
  21. float cardWidth = (fullWidth - gap) / 2;
  22. float x = margin + (day - 1) % 2 * (cardWidth + gap);
  23. float y = 142 + (day - 1) / 2 * (height + gap);
  24. float width = finale ? fullWidth : cardWidth;
  25. var tile = Panel(page, "Day " + day, x, y, width, height, false);
  26. var face = tile.GetComponent<NeonPanel>();
  27. face.top = available ? Neon.Hex("#503649") : finale ? Neon.Hex("#3C2149") : Neon.Hex("#2D1B3B");
  28. if (available) Rule(tile, 6, 36, 4, Neon.Gold, 66);
  29. float textX = finale ? 182 : 98;
  30. float textWidth = width - textX - 16;
  31. string date = "DAY " + day;
  32. if (available) date = "TODAY · " + date;
  33. if (collected) date += " · CLAIMED";
  34. Label(tile, date, textX, 29, textWidth, 28, 18, available ? Neon.Gold : Neon.Muted, TextAnchor.MiddleLeft);
  35. Label(tile, Economy.CheckinLabels[day - 1], textX, 68, textWidth, 40, finale ? 27 : 23,
  36. collected ? Neon.Muted : Color.white, TextAnchor.MiddleLeft);
  37. if (finale)
  38. {
  39. Icon(tile, 1, 24, 38, 62);
  40. Icon(tile, 11, 96, 38, 62);
  41. }
  42. else
  43. {
  44. Icon(tile, day == 4 ? 10 : 1, 20, 38, 62);
  45. }
  46. }
  47. var claim = FooterButton(page, "Claim", 70, 540, claimed ? "CLAIMED TODAY" : "CLAIM DAY " + current, () => {
  48. if (!Economy.CheckIn(Save, Today)) return;
  49. Persist();
  50. Sound(SoundCue.Reward);
  51. ShowCheckin();
  52. }, !claimed);
  53. claim.GetComponent<Button>().interactable = !claimed;
  54. }
  55. public void ShowShop()
  56. {
  57. var page = Sheet("SHOP", 920);
  58. Icon(page, 1, 381, 35, 36);
  59. Label(page, Save.gems.ToString(), 424, 29, 133, 46, 27, Neon.Ice, TextAnchor.MiddleLeft);
  60. const float margin = 40, rowHeight = 164, gap = 24, priceWidth = 144;
  61. float width = page.rect.width - 2 * margin;
  62. float priceX = width - 24 - priceWidth;
  63. const float textX = 136;
  64. float textWidth = priceX - gap - textX;
  65. int[] displayOrder = { 3, 0, 1, 2 };
  66. int[] iconsByProduct = { 10, 12, 11, 5 };
  67. int[] stock = { Save.spotlight, Save.heart, Save.hammer };
  68. string[] descriptions = { "Find a clear arrow", "Restore one heart", "Break any arrow", "One of each power-up" };
  69. for (int i = 0; i < displayOrder.Length; i++)
  70. {
  71. int product = displayOrder[i];
  72. bool bundle = product == 3;
  73. var row = Panel(page, Economy.Products[product], margin, 144 + i * (rowHeight + gap), width, rowHeight, false);
  74. row.GetComponent<NeonPanel>().top = Neon.Hex(bundle ? "#493054" : "#30203F");
  75. Icon(row, iconsByProduct[product], 30, bundle ? 42 : 27, 80);
  76. if (!bundle)
  77. Label(row, "Owned " + stock[product], 10, 113, 120, 29, 18, Neon.Ice);
  78. Label(row, Economy.Products[product], textX, 39, textWidth, 48, 30, Color.white, TextAnchor.MiddleLeft);
  79. Label(row, descriptions[product], textX, 92, textWidth, 35, 21, Neon.Muted, TextAnchor.MiddleLeft);
  80. BuyButton(row, product, priceX, (rowHeight - 88) / 2, priceWidth);
  81. }
  82. }
  83. void BuyButton(RectTransform parent, int product, float x, float y, float width)
  84. {
  85. bool affordable = Save.gems >= Economy.Prices[product];
  86. var control = Button(parent, "Buy " + Economy.Products[product], x, y, width, 88, "", () => {
  87. if (!Economy.Buy(Save, product)) { Toast("Not enough diamonds"); return; }
  88. Persist();
  89. Sound(SoundCue.Reward);
  90. ShowShop();
  91. Toast("Added to your inventory");
  92. }, affordable, false);
  93. var face = control.GetComponent<NeonPanel>();
  94. face.top = Neon.Hex(affordable ? (product == 3 ? "#A82D80" : "#63417D") : "#31253C");
  95. face.bottom = Neon.Hex(affordable ? "#44254F" : "#251C30");
  96. Icon(control, 1, 22, 26, 36);
  97. Label(control, Economy.Prices[product].ToString(), 65, 17, width - 77, 54, 27,
  98. affordable ? Color.white : Neon.Muted, TextAnchor.MiddleLeft);
  99. }
  100. public void ShowHelp()
  101. {
  102. var page = Sheet("HOW TO PLAY", 1020);
  103. var demo = Panel(page, "Practice", 32, 130, 616, 318, false);
  104. demo.GetComponent<NeonPanel>().top = Neon.Hex("#352044");
  105. var frame = Panel(demo, "Board frame", 16, 16, 286, 286);
  106. frame.gameObject.AddComponent<RectMask2D>();
  107. var board = Node(frame, "Practice arrows", 0, 0, 286, 286).gameObject.AddComponent<ArrowBoard>();
  108. var sample = new LevelData { size = 5, seconds = 60, arrows = new[] {
  109. new ArrowData { cells = new[] { new Cell(0, 3), new Cell(0, 2), new Cell(1, 2) } },
  110. new ArrowData { cells = new[] { new Cell(2, 3), new Cell(3, 3), new Cell(3, 2) } },
  111. new ArrowData { cells = new[] { new Cell(2, 1), new Cell(3, 1), new Cell(4, 1) } }
  112. }};
  113. var practice = new GameSession(sample);
  114. board.Configure(sample, practice);
  115. Label(demo, "Try the board", 318, 27, 280, 54, 30, Color.white, TextAnchor.MiddleLeft);
  116. var hint = Label(demo, "Tap an arrow with a clear path to the edge.", 321, 92, 270, 107, 23,
  117. Neon.Ice, TextAnchor.UpperLeft);
  118. board.clicked = index => {
  119. int blocker = practice.Blocker(index);
  120. if (blocker >= 0)
  121. {
  122. board.Flash(index, blocker);
  123. hint.text = "Blocked. Clear the arrow in front first.";
  124. return;
  125. }
  126. if (practice.Tap(index) != TapResult.Removed) return;
  127. board.AnimateExit(index, false);
  128. hint.text = practice.Remaining == 0 ? "Board cleared!" : "Clear the next arrow.";
  129. };
  130. Button(demo, "Reset demo", 323, 205, 262, 88, "RESET BOARD", ShowHelp, false);
  131. Icon(page, 12, 42, 474, 70);
  132. Label(page, "Hearts & time", 134, 462, 489, 49, 29, Color.white, TextAnchor.MiddleLeft);
  133. Label(page, "Blocked taps cost one heart. Clear the board before time runs out.", 134, 514, 484, 75, 22,
  134. Neon.Muted, TextAnchor.UpperLeft);
  135. Label(page, "Watch an ad to revive once per attempt with +1 heart. A timeout also gives 30 seconds.", 55, 603, 573, 83, 22,
  136. Neon.Ice, TextAnchor.UpperLeft);
  137. Rule(page, 40, 699, 600, Neon.Purple);
  138. int[] tools = { 10, 11, 12 };
  139. string[] tips = { "Reveal a clear arrow", "Break one arrow", "Add a heart (max 5)" };
  140. for (int i = 0; i < tools.Length; i++)
  141. {
  142. float x = 34 + 205 * i;
  143. Icon(page, tools[i], x + 69, 716, 64);
  144. Label(page, tips[i], x + 4, 790, 190, 67, 20, Color.white, TextAnchor.UpperCenter);
  145. }
  146. Label(page, "A flawless clear earns 3 stars. Spare time earns diamonds.", 36, 849, 608, 35, 18, Neon.Muted);
  147. FooterButton(page, "Got it", 95, 490, "GOT IT", CloseAndRefresh);
  148. }
  149. }
  150. }