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