|
|
@@ -2,6 +2,7 @@ using System;
|
|
|
using System.Collections;
|
|
|
using System.Linq;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using HexaCrazy.Ads;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
|
using TMPro;
|
|
|
@@ -11,14 +12,21 @@ namespace HexaCrazy
|
|
|
public partial class HexGameApp
|
|
|
{
|
|
|
readonly bool[] faqOpen={true,true,false,false,false,false,false,false,false,false,false};
|
|
|
+ bool helpShowsFaq;
|
|
|
+ RectTransform drawWheel;
|
|
|
+ float drawRestAngle;
|
|
|
TMP_InputField nicknameInput;
|
|
|
+ Button adButton;
|
|
|
+ TextMeshProUGUI adLabel;
|
|
|
+ string readyCaption;
|
|
|
+ RewardedAdStatus? displayedAdStatus;
|
|
|
public void OpenPanel(string name)
|
|
|
{
|
|
|
if(modal!=null&¤tPanel!=name&¤tPanel!="result")panelHistory.Push(currentPanel);
|
|
|
BuildPanel(name);
|
|
|
}
|
|
|
void Reopen(string name){BuildPanel(name);}
|
|
|
- void RemoveModal(){if(modal!=null){modal.gameObject.SetActive(false);Destroy(modal.gameObject);modal=null;}}
|
|
|
+ void RemoveModal(){adButton=null;adLabel=null;drawWheel=null;if(modal!=null){modal.gameObject.SetActive(false);Destroy(modal.gameObject);modal=null;}}
|
|
|
public void ClosePanel()
|
|
|
{
|
|
|
if(currentPanel=="result")return;
|
|
|
@@ -31,12 +39,25 @@ namespace HexaCrazy
|
|
|
{
|
|
|
RemoveModal();currentPanel=name;modal=Layer("Modal_"+name);modal.SetAsLastSibling();toastLayer.SetAsLastSibling();
|
|
|
var shade=HexUI.Image(modal,"Dimmer",null,375,667,750,1334,new Color(0,0,0,.76f));shade.raycastTarget=true;
|
|
|
- HexUI.Image(modal,"Dialog","card",375,667,700,1100,null,true);
|
|
|
string title=name=="draw"?"LUCKY DRAW":name=="checkin"?"CHECK-IN":name=="ledger"?"COIN LEDGER":name=="result"?resultTitle:name.ToUpperInvariant();
|
|
|
- HexUI.Text(modal,"PanelTitle",title,350,208,540,72,name=="result"?58:46,true);
|
|
|
- if(name!="result")HexUI.IconButton(modal,"ClosePanel","close",666,205,55,ClosePanel);
|
|
|
- HexUI.Image(modal,"PanelRule","ornament",375,259,570,20);
|
|
|
- if(name=="shop"||name=="draw")HexUI.Text(modal,"PanelCoins",Profile.Data.coins.ToString("N0")+" COINS",375,292,550,34,26,true);
|
|
|
+ switch (name)
|
|
|
+ {
|
|
|
+ case "checkin":
|
|
|
+ int day = Profile.CanCheckin ? Profile.CheckinSlot : Profile.ClaimedCheckinSlot;
|
|
|
+ FolioHeader(title, "dock_checkin", "DAY " + day + " OF 7"); break;
|
|
|
+ case "shop": case "draw":
|
|
|
+ FolioHeader(title, "dock_" + name, Profile.Data.coins.ToString("N0") + " COINS"); break;
|
|
|
+ case "help": FolioHeader(title, "rulebook", "PLAYER HANDBOOK"); break;
|
|
|
+ case "profile": FolioHeader(title, "dock_profile", "LOCAL PLAYER · ID " + Profile.Data.id); break;
|
|
|
+ case "settings": FolioHeader(title, "pref_gear", "HEXA CRAZY 7+ · v1.0"); break;
|
|
|
+ case "result": FolioBackdrop(); break;
|
|
|
+ default:
|
|
|
+ HexUI.Image(modal,"Dialog","card",375,667,700,1100,null,true);
|
|
|
+ HexUI.Text(modal,"PanelTitle",title,350,208,540,72,46,true);
|
|
|
+ HexUI.IconButton(modal,"ClosePanel","close",666,205,55,ClosePanel);
|
|
|
+ HexUI.Image(modal,"PanelRule","ornament",375,259,570,20);
|
|
|
+ break;
|
|
|
+ }
|
|
|
switch(name)
|
|
|
{
|
|
|
case "shop":ShopPanel();break;case "ledger":LedgerPanel();break;case "checkin":CheckinPanel();break;case "draw":DrawPanel();break;
|
|
|
@@ -44,32 +65,98 @@ namespace HexaCrazy
|
|
|
case "result":ResultPanel();break;case "reset":ResetPanel();break;
|
|
|
}
|
|
|
}
|
|
|
- RectTransform Content(float height=740,bool coinHeader=false)
|
|
|
+ void FolioBackdrop()
|
|
|
{
|
|
|
- float y=coinHeader?701:682,h=coinHeader?750:788;
|
|
|
- var view=HexUI.Node(modal,"ScrollViewport",375,y,620,h);var mask=view.gameObject.AddComponent<RectMask2D>();
|
|
|
+ HexUI.Image(modal, "FolioBacking", null, 375, 667, 664, 1070, HexUI.ColorOf("220C20"));
|
|
|
+ HexUI.Image(modal, "Dialog", "folio", 375, 667, 710, 1124);
|
|
|
+ }
|
|
|
+ void FolioHeader(string title, string icon, string detail)
|
|
|
+ {
|
|
|
+ FolioBackdrop();
|
|
|
+ HexUI.Image(modal, "PageIcon", icon, 149, 215, 75, 75);
|
|
|
+ LeftText(modal, "PanelTitle", title, 205, 198, 372, 61, 46, true);
|
|
|
+ LeftText(modal, "PanelDetail", detail, 208, 243, 368, 30, 20, false, HexUI.Gold);
|
|
|
+ var close = HexUI.Button(modal, "ClosePanel", "", 611, 214, 68, 68, ClosePanel, null);
|
|
|
+ close.targetGraphic = HexUI.Image(close.transform, "Icon", "icon_close", 34, 34, 33, 33);
|
|
|
+ HexUI.Image(modal, "PanelRule", "ornament", 375, 278, 536, 14);
|
|
|
+ }
|
|
|
+ static TextMeshProUGUI LeftText(Transform parent, string name, string value, float left, float y,
|
|
|
+ float width, float height, float size, bool display = false, Color? color = null)
|
|
|
+ {
|
|
|
+ var label = HexUI.Text(parent, name, value, left + width / 2, y, width, height, size, display, color);
|
|
|
+ label.alignment = TextAlignmentOptions.MidlineLeft;
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ static void Hairline(Transform parent, float x, float y, float width)
|
|
|
+ {
|
|
|
+ HexUI.Image(parent, "Rule", null, x, y, width, 1.5f, HexUI.ColorOf("A47B4C99"));
|
|
|
+ }
|
|
|
+ RectTransform Content(float height=740,float topInset=0)
|
|
|
+ {
|
|
|
+ float h=788-topInset;
|
|
|
+ var view=HexUI.Node(modal,"ScrollViewport",375,682+topInset/2,620,h);view.gameObject.AddComponent<RectMask2D>();
|
|
|
var touch=view.gameObject.AddComponent<Image>();touch.color=new Color(0,0,0,.001f);touch.raycastTarget=true;
|
|
|
var content=HexUI.Node(view,"Content",310,0,620,Mathf.Max(h,height));content.pivot=new Vector2(.5f,1);content.anchoredPosition=new Vector2(310,0);
|
|
|
var scroll=view.gameObject.AddComponent<ScrollRect>();scroll.viewport=view;scroll.content=content;scroll.horizontal=false;scroll.vertical=height>h;scroll.movementType=ScrollRect.MovementType.Clamped;scroll.scrollSensitivity=35;
|
|
|
return content;
|
|
|
}
|
|
|
void PText(Transform p,string value,float y,float h=55,float size=24,bool title=false){HexUI.Text(p,"Text",value,310,y,580,h,size,title);}
|
|
|
- void Footer(string label,Action action,string second=null,Action other=null)
|
|
|
+ Button Footer(string label,Action action,string second=null,Action other=null)
|
|
|
+ {
|
|
|
+ if(second==null)return HexUI.Button(modal,"Footer_"+label,label,375,1144,460,82,action,"primary",34,true);
|
|
|
+ HexUI.Button(modal,"Footer_"+label,label,215,1144,290,82,action,"panel",28,true);
|
|
|
+ return HexUI.Button(modal,"Footer_"+second,second,530,1144,290,82,other,"primary",28,true);
|
|
|
+ }
|
|
|
+ void BindAdButton(Button button)
|
|
|
+ {
|
|
|
+ adButton = button;
|
|
|
+ adLabel = button.GetComponentInChildren<TextMeshProUGUI>();
|
|
|
+ readyCaption = adLabel.text;
|
|
|
+ displayedAdStatus = null;
|
|
|
+ RefreshAdButton();
|
|
|
+ }
|
|
|
+ void RefreshAdButton()
|
|
|
{
|
|
|
- if(second==null)HexUI.Button(modal,"Footer_"+label,label,375,1144,460,82,action,"primary",34,true);
|
|
|
- else {HexUI.Button(modal,"Footer_"+label,label,215,1144,290,82,action,"panel",28,true);HexUI.Button(modal,"Footer_"+second,second,530,1144,290,82,other,"primary",28,true);}
|
|
|
+ if (adButton == null || Ads == null || displayedAdStatus == Ads.Status) return;
|
|
|
+ var status = Ads.Status;
|
|
|
+ displayedAdStatus = status;
|
|
|
+ adButton.interactable = status != RewardedAdStatus.Preparing && status != RewardedAdStatus.Loading;
|
|
|
+ switch (status)
|
|
|
+ {
|
|
|
+ case RewardedAdStatus.Ready: adLabel.text = readyCaption; break;
|
|
|
+ case RewardedAdStatus.Preparing: adLabel.text = "PREPARING ADS…"; break;
|
|
|
+ case RewardedAdStatus.Loading: adLabel.text = "LOADING AD…"; break;
|
|
|
+ case RewardedAdStatus.NetworkError: adLabel.text = "NETWORK ERROR\nRETRY AD"; break;
|
|
|
+ case RewardedAdStatus.NoFill: adLabel.text = "NO AD AVAILABLE\nRETRY"; break;
|
|
|
+ case RewardedAdStatus.PrivacyUnavailable: adLabel.text = "PRIVACY CHECK\nRETRY"; break;
|
|
|
+ default: adLabel.text = "AD LOAD FAILED\nRETRY"; break;
|
|
|
+ }
|
|
|
}
|
|
|
void ShopPanel()
|
|
|
{
|
|
|
- var c=Content(750,true);string[] descriptions={"Clear any occupied stack. No points awarded.","Replace all remaining hand groups with three new groups.","Add a group of three; replaces slot 3 if the hand is full.","Open the locked cell with the lowest score threshold."};
|
|
|
- for(int i=0;i<4;i++)
|
|
|
+ var c = Content();
|
|
|
+ string[] descriptions = {
|
|
|
+ "Remove an occupied stack without scoring.",
|
|
|
+ "Replace the remaining hand with three new groups.",
|
|
|
+ "Add a group of three. Replaces slot 3 if the hand is full.",
|
|
|
+ "Open the locked cell with the lowest score threshold."
|
|
|
+ };
|
|
|
+ Hairline(c, 310, 391, 558);
|
|
|
+ HexUI.Image(c, "ShelfDivider", null, 310, 391, 1.5f, 710, HexUI.ColorOf("A47B4C66"));
|
|
|
+ for (int i = 0; i < descriptions.Length; i++)
|
|
|
{
|
|
|
- int item=i;float y=92+i*181;HexUI.Image(c,"ShopRow"+i,"panel",310,y,605,162,null,true);
|
|
|
- HexUI.Image(c,"ItemIcon","icon_"+HexUI.ItemIcons[i],67,y-26,66,66);
|
|
|
- HexUI.Text(c,"ItemName",LevelDatabase.ItemNames[i],258,y-51,300,40,31,true);
|
|
|
- HexUI.Text(c,"Owned","OWNED "+Profile.Data.items[i],256,y-12,295,30,20);
|
|
|
- HexUI.Text(c,"Description",descriptions[i],260,y+43,345,64,19);
|
|
|
- var buy=HexUI.Button(c,"BuyItem_"+i,LevelDatabase.Prices[i].ToString("N0")+"\nBUY",510,y,155,99,()=>{if(Profile.Buy(item)){audioPlayer.Play("coin");Reopen("shop");Toast("Purchased "+LevelDatabase.ItemNames[item]);}else Toast("Need "+(LevelDatabase.Prices[item]-Profile.Data.coins).ToString("N0")+" more coins");},"primary",24,true);
|
|
|
+ int item = i;
|
|
|
+ float x = 160 + i % 2 * 300, y = 14 + i / 2 * 385;
|
|
|
+ HexUI.Image(c, "ItemIcon", "power_" + HexUI.ItemIcons[i], x, y + 79, 117, 117);
|
|
|
+ HexUI.Text(c, "ItemName", LevelDatabase.ItemNames[i], x, y + 161, 272, 46, 33, true);
|
|
|
+ HexUI.Text(c, "Owned", "OWNED " + Profile.Data.items[i], x, y + 200, 260, 27, 18, false, HexUI.Gold);
|
|
|
+ HexUI.Text(c, "Description", descriptions[i], x, y + 252, 260, 67, 21);
|
|
|
+ var buy = HexUI.Button(c, "BuyItem_" + i, "BUY · " + LevelDatabase.Prices[i].ToString("N0"),
|
|
|
+ x, y + 326, 218, 59, () =>
|
|
|
+ {
|
|
|
+ if (Profile.Buy(item)) { audioPlayer.Play("coin"); Reopen("shop"); Toast("Purchased " + LevelDatabase.ItemNames[item]); }
|
|
|
+ else Toast("Need " + (LevelDatabase.Prices[item] - Profile.Data.coins).ToString("N0") + " more coins");
|
|
|
+ }, "primary", 23);
|
|
|
if(Profile.Data.coins<LevelDatabase.Prices[i])buy.image.color=new Color(.65f,.55f,.6f);
|
|
|
}
|
|
|
Footer("COIN LEDGER",()=>OpenPanel("ledger"));
|
|
|
@@ -84,85 +171,257 @@ namespace HexaCrazy
|
|
|
}
|
|
|
void CheckinPanel()
|
|
|
{
|
|
|
- var c=Content();int slot=Profile.CheckinSlot;string[] rewards={"200 COINS","HAMMER ×1","300 COINS","SWAP ×1","500 COINS","BONUS ×1","1,000 COINS"};
|
|
|
- PText(c,"A LITTLE LUCK, EVERY DAY",32,48,28,true);PText(c,"Rewards advance each calendar day. Missed days are skipped.",86,58,20);
|
|
|
- for(int i=0;i<7;i++)
|
|
|
+ var c = Content();
|
|
|
+ bool canClaim = Profile.CanCheckin;
|
|
|
+ int slot = canClaim ? Profile.CheckinSlot : Profile.ClaimedCheckinSlot;
|
|
|
+ PText(c, "Rewards advance each day. Missed days are skipped.", 43, 54, 21);
|
|
|
+ for (int i = 0; i < 6; i++)
|
|
|
+ {
|
|
|
+ bool today = i + 1 == slot;
|
|
|
+ var tile = HexUI.Image(c, "Day_" + (i+1), null, 113 + i % 3 * 197, 206 + i / 3 * 222,
|
|
|
+ 181, 201, HexUI.ColorOf(today ? "17494C" : "3D1A38"));
|
|
|
+ HexUI.Image(tile.transform, "TopEdge", null, 90.5f, 1.5f, 181, 3, today ? HexUI.Gold : HexUI.ColorOf("825B59"));
|
|
|
+ HexUI.Text(tile.transform, "Day", "DAY " + (i+1), 90.5f, 30, 128, 32, 21, false, HexUI.Gold);
|
|
|
+ string icon = i % 2 == 0 ? "reward_coins" : "power_" + HexUI.ItemIcons[i / 2];
|
|
|
+ HexUI.Image(tile.transform, "Reward", icon, 90.5f, 100, 77, 77);
|
|
|
+ HexUI.Text(tile.transform, "Name", LocalProfile.CheckinRewardName(i+1), 90.5f, 165, 173, 36, 22);
|
|
|
+ if (today && !canClaim) HexUI.Image(tile.transform, "Claimed", "icon_check", 154, 30, 22, 22);
|
|
|
+ }
|
|
|
+ var finalDay = HexUI.Image(c, "Day_7", "dock_frame", 310, 659, 598, 180);
|
|
|
+ HexUI.Image(finalDay.transform, "Reward", "reward_chest", 172, 90, 110, 120);
|
|
|
+ LeftText(finalDay.transform, "Day", "DAY 7", 261, 57, 210, 36, 23, false, HexUI.Gold);
|
|
|
+ LeftText(finalDay.transform, "Name", LocalProfile.CheckinRewardName(7), 261, 108, 240, 55, 34, true);
|
|
|
+ if (slot == 7) HexUI.Image(finalDay.transform, "Today", canClaim ? "coin" : "icon_check", 367, 57, 23, 23);
|
|
|
+ if (Ads != null && Ads.Supported && Profile.CanClaimCheckinBonus)
|
|
|
{
|
|
|
- float x=i==6?310:110+(i%3)*200,y=i==6?650:245+(i/3)*210,w=i==6?590:185,h=i==6?160:195;
|
|
|
- var im=HexUI.Image(c,"Day_"+(i+1),"panel",x,y,w,h,null,true);
|
|
|
- if(i+1==slot&&Profile.CanCheckin)im.color=HexUI.Gold;
|
|
|
- HexUI.Text(im.transform,"Day","DAY "+(i+1),w/2,30,w-10,35,24,true);
|
|
|
- string icon=i==1?"icon_hammer":i==3?"icon_swap":i==5?"icon_bonus":"coin";
|
|
|
- HexUI.Image(im.transform,"Reward",icon,w/2,i==6?77:92,65,65);
|
|
|
- HexUI.Text(im.transform,"Name",rewards[i],w/2,i==6?130:157,w-10,40,20);
|
|
|
+ var profile = Profile;
|
|
|
+ string date = profile.Data.checkinLast;
|
|
|
+ BindAdButton(HexUI.Button(modal, "AdCheckin", "WATCH AD · " + LocalProfile.CheckinRewardName(slot), 375,1144,590,82, () =>
|
|
|
+ {
|
|
|
+ if (!profile.CanClaimCheckinBonus || profile.Data.checkinLast != date) { Reopen("checkin"); return; }
|
|
|
+ WatchReward("checkin", () => profile.ClaimCheckinBonus(date), "Extra daily reward claimed");
|
|
|
+ }, "primary", 29, true));
|
|
|
+ return;
|
|
|
}
|
|
|
Footer(Profile.CanCheckin?"CLAIM DAY "+slot:"CLAIMED TODAY",()=>{if(Profile.ClaimCheckin()){audioPlayer.Play("coin");Reopen("checkin");Toast("Daily reward claimed");}else Toast("Come back tomorrow");});
|
|
|
}
|
|
|
void DrawPanel()
|
|
|
{
|
|
|
- var c=Content(750,true);PText(c,"ONE FREE SPIN EACH DAY",30,40,26,true);PText(c,"Free play rewards · no cash value",76,35,20);
|
|
|
- int[,] coords={{0,0},{1,0},{2,0},{2,1},{2,2},{1,2},{0,2},{0,1}};
|
|
|
- for(int i=0;i<8;i++)
|
|
|
+ var c = Content();
|
|
|
+ PText(c, "ONE FREE SPIN EACH DAY", 29, 36, 23);
|
|
|
+ var frame = HexUI.Node(c, "WheelFrame", 310, 351, 580, 580);
|
|
|
+ HexUI.Image(frame, "WheelRim", "prize_wheel", 290, 290, 580, 580);
|
|
|
+ // The gold rim and its four fan ornaments stay on the stationary layer.
|
|
|
+ // Clip a slightly enlarged copy to the velvet opening so only wedges turn.
|
|
|
+ const float faceRadius = 240;
|
|
|
+ var aperture = HexUI.Fill(frame, "WheelAperture", 290, 290, faceRadius * 2, faceRadius * 2);
|
|
|
+ aperture.Value = 1;
|
|
|
+ aperture.canvasRenderer.SetColor(HexUI.ColorOf("291420"));
|
|
|
+ aperture.gameObject.AddComponent<Mask>();
|
|
|
+ drawWheel = HexUI.Image(aperture.transform, "PrizeWheel", "prize_wheel", faceRadius, faceRadius, 580, 580).rectTransform;
|
|
|
+ drawWheel.localScale = Vector3.one * 1.035f;
|
|
|
+ for (int i = 0; i < LocalProfile.DrawNames.Length; i++)
|
|
|
{
|
|
|
- float x=110+coords[i,0]*200,y=221+coords[i,1]*178;
|
|
|
- var im=HexUI.Image(c,"Prize_"+i,"panel",x,y,188,164,null,true);
|
|
|
- HexUI.Image(im.transform,"PrizeIcon",LocalProfile.DrawCoins[i]>0?"coin":"icon_"+HexUI.ItemIcons[LocalProfile.DrawItems[i]],94,61,65,65);
|
|
|
- HexUI.Text(im.transform,"PrizeName",LocalProfile.DrawNames[i],94,125,174,42,21,true);
|
|
|
+ Vector2 pos = WheelPoint(i, 157);
|
|
|
+ var wedge = HexUI.Node(drawWheel, "Wedge_" + i, pos.x, pos.y, 128, 88);
|
|
|
+ string icon = LocalProfile.DrawCoins[i] > 0 ? "reward_coins" : "power_" + HexUI.ItemIcons[LocalProfile.DrawItems[i]];
|
|
|
+ HexUI.Image(wedge, "Prize_" + i, icon, 64, 29, 57, 57);
|
|
|
+ HexUI.Text(wedge, "PrizeName", LocalProfile.DrawNames[i], 64, 74, 128, 30, 18);
|
|
|
+ }
|
|
|
+ SetWheelRotation(drawWheel, drawRestAngle);
|
|
|
+ var pointer = HexUI.Image(frame, "PrizeIndicator", "icon_play", 290, 39, 40, 44).rectTransform;
|
|
|
+ pointer.localRotation = Quaternion.Euler(0, 0, -90);
|
|
|
+ HexUI.Image(pointer, "Enamel", "icon_play", 19, 22, 27, 30, HexUI.ColorOf("C82D4B"));
|
|
|
+
|
|
|
+ // An opaque disc behind the medallion covers the rotating spokes.
|
|
|
+ var hub = HexUI.Fill(frame, "HubBacking", 290, 290, 136, 136);
|
|
|
+ hub.Value = 1;
|
|
|
+ hub.canvasRenderer.SetColor(HexUI.ColorOf("391329"));
|
|
|
+ var spin = HexUI.Button(frame, "Spin", "", 290, 290, 142, 142, StartDraw, "medallion");
|
|
|
+ var colors = spin.colors;
|
|
|
+ colors.disabledColor = new Color(.74f, .68f, .72f, 1f);
|
|
|
+ spin.colors = colors;
|
|
|
+ HexUI.Text(spin.transform, "Label", "SPIN", 71, 57, 109, 55, 40, true);
|
|
|
+ string status = drawBusy ? "SPINNING…" : Profile.FreeDraw ? "FREE TODAY" : Profile.Data.tickets > 0 ? "USE 1 TICKET" : "NO TICKET";
|
|
|
+ spin.interactable = !drawBusy && (Profile.FreeDraw || Profile.Data.tickets > 0);
|
|
|
+ HexUI.Text(c, "SpinStatus", status, 172, 687, 275, 40, 25, false, HexUI.Gold);
|
|
|
+ HexUI.Image(c, "Divider", null, 310, 687, 1.5f, 30, HexUI.Muted);
|
|
|
+ HexUI.Text(c, "DrawTickets", "DRAW TICKETS " + Profile.Data.tickets, 453, 687, 270, 40, 23);
|
|
|
+ PText(c, "Free play rewards · no cash value", 752, 32, 19);
|
|
|
+ if (Ads != null && Ads.Supported)
|
|
|
+ {
|
|
|
+ var profile = Profile;
|
|
|
+ HexUI.Button(modal, "Footer_BACK", "BACK", 160, 1144, 176, 78, ClosePanel, "panel", 26);
|
|
|
+ const string rewardCaption = "WATCH AD · +1 TICKET";
|
|
|
+ var reward = HexUI.Button(modal, "Footer_" + rewardCaption, rewardCaption, 472, 1144, 412, 82, () =>
|
|
|
+ {
|
|
|
+ if (!drawBusy) WatchReward("draw", profile.GrantDrawTicket, "+1 draw ticket");
|
|
|
+ }, "primary", 27);
|
|
|
+ var label = reward.GetComponentInChildren<TextMeshProUGUI>();
|
|
|
+ label.rectTransform.sizeDelta = new Vector2(326, 62);
|
|
|
+ label.textWrappingMode = TextWrappingModes.NoWrap;
|
|
|
+ BindAdButton(reward);
|
|
|
+ }
|
|
|
+ else Footer("BACK",ClosePanel);
|
|
|
+ }
|
|
|
+ void WatchReward(string panel, Action grant, string message, Action resume = null)
|
|
|
+ {
|
|
|
+ if (currentPanel != panel || Ads.IsShowing) return;
|
|
|
+ if (Ads.Status != RewardedAdStatus.Ready)
|
|
|
+ {
|
|
|
+ Ads.Retry();
|
|
|
+ RefreshAdButton();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var view = modal;
|
|
|
+ if (!Ads.TryShow(grant, earned =>
|
|
|
+ {
|
|
|
+ if (this == null || modal != view) return;
|
|
|
+ if (earned && resume != null) resume();
|
|
|
+ else Reopen(panel);
|
|
|
+ Toast(earned ? message : "Ad ended without a reward · try again");
|
|
|
+ }))
|
|
|
+ {
|
|
|
+ Ads.Retry();
|
|
|
+ RefreshAdButton();
|
|
|
}
|
|
|
- string caption=drawBusy?"SPINNING":Profile.FreeDraw?"SPIN\nFREE TODAY":Profile.Data.tickets>0?"SPIN\nTICKET ×"+Profile.Data.tickets:"NO TICKET";
|
|
|
- var spin=HexUI.Button(c,"Spin",caption,310,399,180,158,StartDraw,"primary",27,true);spin.interactable=!drawBusy&&(Profile.FreeDraw||Profile.Data.tickets>0);
|
|
|
- PText(c,"DRAW TICKETS "+Profile.Data.tickets,675,45,26,true);
|
|
|
- Footer("BACK",ClosePanel);
|
|
|
}
|
|
|
void StartDraw()
|
|
|
{
|
|
|
if(drawBusy)return;int prize=Profile.Draw(rng);if(prize<0){Toast("Clear levels to earn more tickets");return;}
|
|
|
drawBusy=true;Reopen("draw");StartCoroutine(SpinAnimation(prize));
|
|
|
}
|
|
|
+ static Vector2 WheelPoint(int prize, float radius)
|
|
|
+ {
|
|
|
+ float angle = prize * 2 * Mathf.PI / LocalProfile.DrawNames.Length;
|
|
|
+ return new Vector2(290 + Mathf.Sin(angle) * radius, 290 - Mathf.Cos(angle) * radius);
|
|
|
+ }
|
|
|
+ static void SetWheelRotation(RectTransform wheel, float angle)
|
|
|
+ {
|
|
|
+ var rotation = Quaternion.Euler(0, 0, angle);
|
|
|
+ wheel.localRotation = rotation;
|
|
|
+ // Keep the prize illustrations and names upright as their wedges move.
|
|
|
+ var upright = Quaternion.Inverse(rotation);
|
|
|
+ for (int i = 0; i < wheel.childCount; i++)
|
|
|
+ wheel.GetChild(i).localRotation = upright;
|
|
|
+ }
|
|
|
IEnumerator SpinAnimation(int prize)
|
|
|
{
|
|
|
- int total=16+prize;float delay=.055f;
|
|
|
- for(int i=0;i<=total;i++)
|
|
|
+ var wheel = drawWheel;
|
|
|
+ float target = prize * 360f / LocalProfile.DrawNames.Length;
|
|
|
+ float start = drawRestAngle;
|
|
|
+ float travel = 3 * 360f + Mathf.Repeat(start - target, 360f);
|
|
|
+ const float duration = 2.8f;
|
|
|
+ float startedAt = Time.unscaledTime;
|
|
|
+ while (wheel != null && wheel == drawWheel && !Profile.Data.reduceMotion)
|
|
|
{
|
|
|
- if(currentPanel!="draw"||modal==null)break;
|
|
|
- foreach(var im in modal.GetComponentsInChildren<Image>())if(im.name.StartsWith("Prize_"))im.color=im.name=="Prize_"+(i%8)?HexUI.Gold:Color.white;
|
|
|
- if(!Profile.Data.reduceMotion){yield return new WaitForSecondsRealtime(delay);if(i>total-9)delay*=1.24f;}
|
|
|
+ float t = (Time.unscaledTime - startedAt) / duration;
|
|
|
+ if (t >= 1) break;
|
|
|
+ SetWheelRotation(wheel, start - travel * Mathf.SmoothStep(0, 1, t));
|
|
|
+ yield return null;
|
|
|
}
|
|
|
+ drawRestAngle = target;
|
|
|
drawBusy=false;audioPlayer.Play("coin");Toast("WON "+LocalProfile.DrawNames[prize]);
|
|
|
- if(currentPanel=="draw"){Reopen("draw");foreach(var im in modal.GetComponentsInChildren<Image>())if(im.name=="Prize_"+prize)im.color=HexUI.Gold;}
|
|
|
+ if(currentPanel=="draw") Reopen("draw");
|
|
|
}
|
|
|
void ProfilePanel()
|
|
|
{
|
|
|
- var d=Profile.Data;var c=Content(850);
|
|
|
- PText(c,"LOCAL PLAYER · ID "+d.id,25,40,20);
|
|
|
- for(int i=0;i<8;i++)
|
|
|
+ var d = Profile.Data;
|
|
|
+ var c = Content();
|
|
|
+ int selected = Mathf.Clamp(d.avatar, 0, HexUI.Symbols.Length - 1);
|
|
|
+ var medal = HexUI.Image(c, "PortraitMedal", "medallion", 89, 92, 120, 120);
|
|
|
+ var portrait = HexUI.Image(medal.transform, "Portrait", HexUI.Symbols[selected], 60, 54, 78, 78);
|
|
|
+ LeftText(c, "NicknameLabel", "NICKNAME", 174, 30, 405, 32, 20, false, HexUI.Gold);
|
|
|
+ var input = HexUI.Image(c, "NicknameInput", "nickname_field", 379, 82, 428, 63);
|
|
|
+ input.raycastTarget = true;
|
|
|
+ nicknameInput = input.gameObject.AddComponent<TMP_InputField>();
|
|
|
+ var text = LeftText(input.transform, "EditableName", d.nickname, 34, 32, 360, 48, 27);
|
|
|
+ nicknameInput.textComponent=text;nicknameInput.textViewport=input.rectTransform;nicknameInput.characterLimit=16;nicknameInput.text=d.nickname;nicknameInput.lineType=TMP_InputField.LineType.SingleLine;
|
|
|
+ LeftText(c, "NameHint", "3–16 letters, numbers, _ or -", 174, 138, 416, 30, 18, false, HexUI.Muted);
|
|
|
+ LeftText(c, "AvatarLabel", "AVATAR", 24, 190, 566, 30, 20, false, HexUI.Gold);
|
|
|
+ var avatars = new Button[HexUI.Symbols.Length];
|
|
|
+ for (int i = 0; i < avatars.Length; i++)
|
|
|
{
|
|
|
- int av=i;var b=HexUI.Button(c,"ChooseAvatar_"+i,"",100+i%4*140,108+i/4*115,95,94,()=>{d.avatar=av;Profile.Save();Reopen("profile");},"holder");
|
|
|
- HexUI.Image(b.transform,"OriginalIcon",HexUI.Symbols[i],47,45,67,67);if(i==d.avatar)b.image.color=HexUI.Gold;
|
|
|
+ int index = i;
|
|
|
+ var b = HexUI.Button(c, "ChooseAvatar_" + i, "", 56 + i * 72.5f, 248, 69, 72, () =>
|
|
|
+ {
|
|
|
+ avatars[selected].image.sprite = HexUI.Sprite("holder");
|
|
|
+ selected = index;
|
|
|
+ avatars[selected].image.sprite = HexUI.Sprite("chip_teal");
|
|
|
+ portrait.sprite = HexUI.Sprite(HexUI.Symbols[selected]);
|
|
|
+ d.avatar = selected;
|
|
|
+ Profile.Save();
|
|
|
+ }, selected == i ? "chip_teal" : "holder");
|
|
|
+ avatars[i] = b;
|
|
|
+ HexUI.Image(b.transform, "OriginalIcon", HexUI.Symbols[i], 34.5f, 34, 45, 45);
|
|
|
+ }
|
|
|
+ Hairline(c, 310, 306, 570);
|
|
|
+ HexUI.Text(c, "PlayerLevel", "LEVEL " + (1+d.totalWins/3), 152, 352, 248, 55, 34, true);
|
|
|
+ HexUI.Text(c, "Balance", d.coins.ToString("N0") + " COINS", 436, 352, 312, 55, 32, true);
|
|
|
+ string[] statNames = { "WINS", "CLEARS", "BEST SCORE", "TOTAL EARNED" };
|
|
|
+ int[] values = { d.totalWins, d.totalClears, d.best, d.earned };
|
|
|
+ for (int i = 0; i < values.Length; i++)
|
|
|
+ {
|
|
|
+ float x = 92 + i * 145;
|
|
|
+ HexUI.Text(c, "StatValue", values[i].ToString("N0"), x, 430, 139, 43, 30);
|
|
|
+ HexUI.Text(c, "StatName", statNames[i], x, 468, 141, 30, 17, false, HexUI.Muted);
|
|
|
+ }
|
|
|
+ Hairline(c, 310, 513, 570);
|
|
|
+ LeftText(c, "ProgressTitle", "MODE PROGRESS", 24, 558, 560, 44, 28, true);
|
|
|
+ for (int i = 0; i < LevelDatabase.ModeNames.Length; i++)
|
|
|
+ {
|
|
|
+ float y = 620 + i * 62;
|
|
|
+ LeftText(c, "ModeName", LevelDatabase.ModeNames[i], 25, y, 230, 35, 22);
|
|
|
+ HexUI.Image(c, "ProgressTrack", "bar", 365, y, 193, 16);
|
|
|
+ HexUI.Fill(c, "ProgressFill", 365, y, 185, 8).Value = d.cleared[i] / 20f;
|
|
|
+ HexUI.Text(c, "ModeCount", d.cleared[i] + " / 20", 546, y, 104, 34, 23, false, HexUI.Gold);
|
|
|
}
|
|
|
- PText(c,"NICKNAME",310,45,26,true);
|
|
|
- var input=HexUI.Image(c,"NicknameInput","panel",310,368,560,70,null,true);input.raycastTarget=true;
|
|
|
- nicknameInput=input.gameObject.AddComponent<TMP_InputField>();var text=HexUI.Text(input.transform,"EditableName",d.nickname,280,35,520,50,27);
|
|
|
- nicknameInput.textComponent=text;nicknameInput.textViewport=input.rectTransform;nicknameInput.characterLimit=16;nicknameInput.text=d.nickname;nicknameInput.lineType=TMP_InputField.LineType.SingleLine;
|
|
|
- PText(c,"3–16 letters, numbers, _ or -",424,35,19);
|
|
|
- PText(c,"LEVEL "+(1+d.totalWins/3)+" · "+d.coins.ToString("N0")+" COINS",480,50,32,true);
|
|
|
- PText(c,"WINS "+d.totalWins+" CLEARS "+d.totalClears+"\nBEST SCORE "+d.best+" TOTAL EARNED "+d.earned.ToString("N0"),550,90,23);
|
|
|
- for(int i=0;i<3;i++){HexUI.Image(c,"ModeProgress","panel",310,646+i*72,575,60,null,true);PText(c,LevelDatabase.ModeNames[i]+" "+d.cleared[i]+" / 20",646+i*72,50,24,true);}
|
|
|
Footer("SAVE PROFILE",()=>{string value=nicknameInput.text.Trim();if(!Regex.IsMatch(value,"^[A-Za-z0-9_-]{3,16}$")){Toast("Use 3–16 letters, digits, _ or -");return;}d.nickname=value;Profile.Save();Toast("Profile saved");});
|
|
|
}
|
|
|
void SettingsPanel()
|
|
|
{
|
|
|
- var c=Content();var d=Profile.Data;string[] names={"MUSIC","SOUND FX","REDUCE MOTION"};bool[] values={d.music,d.sound,d.reduceMotion};
|
|
|
- for(int i=0;i<3;i++)
|
|
|
- {
|
|
|
- int option=i;float y=70+i*120;HexUI.Image(c,"SettingRow","panel",310,y,590,94,null,true);HexUI.Text(c,"SettingName",names[i],219,y,370,55,29,true);
|
|
|
- HexUI.Button(c,"Toggle_"+i,values[i]?"ON":"OFF",510,y,135,67,()=>{if(option==0)d.music=!d.music;else if(option==1)d.sound=!d.sound;else d.reduceMotion=!d.reduceMotion;Profile.Save();SyncAudio();Reopen("settings");},"primary",27,true);
|
|
|
- }
|
|
|
- HexUI.Button(c,"OpenLedger","COIN LEDGER",310,442,530,83,()=>OpenPanel("ledger"),"panel",30,true);
|
|
|
- HexUI.Button(c,"ResetSave","RESET SAVE",310,550,530,83,()=>OpenPanel("reset"),"primary",30,true);
|
|
|
- PText(c,"HEXA CRAZY 7+ · v1.0\n3 MODES · 60 LEVELS\nLOCAL SAVE: "+(Profile.Available?"AVAILABLE":"UNAVAILABLE"),678,130,22);
|
|
|
+ var c = Content();
|
|
|
+ var d = Profile.Data;
|
|
|
+ AddSettingSwitch(c, "Toggle_0", "Music", "pref_music", 73, d.music, () => d.music = !d.music);
|
|
|
+ AddSettingSwitch(c, "Toggle_1", "Sound effects", "pref_sound", 184, d.sound, () => d.sound = !d.sound);
|
|
|
+ AddSettingSwitch(c, "Toggle_2", "Reduce motion", "pref_motion", 295, d.reduceMotion, () => d.reduceMotion = !d.reduceMotion);
|
|
|
+
|
|
|
+ LeftText(c, "DataHeading", "LOCAL DATA", 35, 407, 250, 45, 29, true);
|
|
|
+ var saveState = HexUI.Text(c, "SaveState", Profile.Available ? "SAVE AVAILABLE" : "SAVE UNAVAILABLE",
|
|
|
+ 465, 407, 240, 36, 18, false, HexUI.Muted);
|
|
|
+ saveState.alignment = TextAlignmentOptions.Right;
|
|
|
+ SettingsLink(c, "OpenLedger", "Coin ledger", 488, () => OpenPanel("ledger"), HexUI.Cream);
|
|
|
+ bool privacy = Ads != null && Ads.NeedsPrivacyOptions;
|
|
|
+ if (privacy) SettingsLink(c, "AdPrivacy", "Ad privacy options", 569, Ads.ShowPrivacyOptions, HexUI.Cream);
|
|
|
+ SettingsLink(c, "ResetSave", "Reset save", privacy ? 650 : 569, () => OpenPanel("reset"), HexUI.ColorOf("FFA3A8"));
|
|
|
+ HexUI.Text(c, "GameInfo", "3 MODES · 60 LEVELS", 310, 747, 530, 32, 18, false, HexUI.Muted);
|
|
|
Footer("DONE",ClosePanel);
|
|
|
}
|
|
|
+ void AddSettingSwitch(Transform parent, string name, string label, string icon, float y, bool enabled, Action toggle)
|
|
|
+ {
|
|
|
+ var row = HexUI.Button(parent, name, "", 310, y, 568, 96, () =>
|
|
|
+ {
|
|
|
+ toggle();
|
|
|
+ Profile.Save();
|
|
|
+ SyncAudio();
|
|
|
+ Reopen("settings");
|
|
|
+ }, null);
|
|
|
+ HexUI.Image(row.transform, "Icon", icon, 48, 48, 61, 61);
|
|
|
+ LeftText(row.transform, "SettingName", label, 104, 48, 263, 50, 28);
|
|
|
+ var track = HexUI.Image(row.transform, "Switch", "switch_track", 494, 48, 124, 48, enabled ? Color.white : HexUI.Muted);
|
|
|
+ row.targetGraphic = track;
|
|
|
+ HexUI.Image(track.transform, "Thumb", enabled ? "chip_teal" : "holder", enabled ? 98 : 26, 24, 32, 32);
|
|
|
+ HexUI.Text(track.transform, "Value", enabled ? "ON" : "OFF", enabled ? 46 : 79, 24, 57, 30, 20);
|
|
|
+ Hairline(parent, 310, y + 55, 550);
|
|
|
+ }
|
|
|
+ static void SettingsLink(Transform parent, string name, string label, float y, Action action, Color ink)
|
|
|
+ {
|
|
|
+ var row = HexUI.Button(parent, name, "", 310, y, 558, 78, action, null);
|
|
|
+ row.targetGraphic = LeftText(row.transform, "Label", label, 9, 39, 461, 47, 25, false, ink);
|
|
|
+ var arrow = HexUI.Image(row.transform, "Chevron", "icon_back", 533, 39, 17, 22, ink);
|
|
|
+ arrow.rectTransform.localScale = new Vector3(-1, 1, 1);
|
|
|
+ Hairline(parent, 310, y + 40, 550);
|
|
|
+ }
|
|
|
void PausePanel()
|
|
|
{
|
|
|
var c=Content();PText(c,"TAKE YOUR TIME",95,90,49,true);PText(c,"Your table will be here when you return.",178,70,24);
|
|
|
@@ -173,14 +432,74 @@ namespace HexaCrazy
|
|
|
}
|
|
|
void ResultPanel()
|
|
|
{
|
|
|
- var c=Content();HexUI.Image(c,"ResultMedallion","medallion",310,150,210,210);HexUI.Image(c,"ResultIcon","icon_"+(resultWin?"check":resultTitle=="TIME UP"?"clock":"close"),310,132,105,105);
|
|
|
- PText(c,resultWin?"TABLE CLEARED!":resultTitle=="TIME UP"?"OUT OF TIME":"BOARD IS FULL",300,75,47,true);
|
|
|
- PText(c,"SCORE "+Game.Score+"\nCLEARS "+Game.Clears+" TARGET "+Game.Spec.target,421,115,29);
|
|
|
- PText(c,resultWin?"+"+resultCoins.ToString("N0")+" COINS":"No reward this time. Give it another go.",562,85,resultWin?45:24,true);
|
|
|
- if(resultTicket>0)PText(c,"+1 DRAW TICKET",658,60,30,true);
|
|
|
- else if(!resultWin&&resultTitle=="NO MOVES")PText(c,"Every cell is taken. There is nowhere left to drop.",659,80,22);
|
|
|
- int mode=Game.Spec.mode,level=Game.Spec.level;
|
|
|
- Footer("BACK",LeaveGame,resultWin?(level==20?"REPLAY LV 20":"NEXT LEVEL"):"RETRY",()=>{CloseAll();StartLevel(mode,resultWin?Math.Min(20,level+1):level);});
|
|
|
+ var round = Game;
|
|
|
+ int mode = round.Spec.mode, level = round.Spec.level;
|
|
|
+ bool timedOut = resultTitle == "TIME UP";
|
|
|
+ HexUI.Text(modal, "ResultLevel", LevelDatabase.ModeNames[mode] + " · LEVEL " + level, 375, 187, 500, 34, 22, false, HexUI.Gold);
|
|
|
+ HexUI.Text(modal, "PanelTitle", resultWin ? "TABLE CLEARED" : resultTitle, 375, 249, 555, 80, 56, true);
|
|
|
+ var c = Content();
|
|
|
+ string art = resultWin ? "result_trophy" : timedOut ? "result_hourglass" : "result_hive";
|
|
|
+ HexUI.Image(c, "ResultIcon", art, 310, 144, 225, 225);
|
|
|
+ Hairline(c, 108, 144, 116);
|
|
|
+ Hairline(c, 512, 144, 116);
|
|
|
+
|
|
|
+ ResultStat(c, "SCORE", round.Score, 108);
|
|
|
+ ResultStat(c, "TARGET", round.Spec.target, 310);
|
|
|
+ ResultStat(c, "CLEARS", round.Clears, 512);
|
|
|
+ HexUI.Image(c, "ProgressTrack", "bar", 310, 435, 520, 20);
|
|
|
+ HexUI.Fill(c, "ScoreProgress", 310, 435, 510, 10).Value = (float)round.Score / round.Spec.target;
|
|
|
+
|
|
|
+ if (resultWin)
|
|
|
+ {
|
|
|
+ HexUI.Text(c, "RewardHeading", "REWARDS", 310, 548, 350, 42, 27, true);
|
|
|
+ var plaque = HexUI.Image(c, "RewardPlaque", "dock_frame", 310, 655, 585, 133);
|
|
|
+ ResultReward(plaque.transform, "reward_coins", resultCoins, "COINS", resultTicket > 0 ? 114 : 229);
|
|
|
+ if (resultTicket > 0) ResultReward(plaque.transform, "reward_ticket", resultTicket, "DRAW TICKET", 340);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ HexUI.Text(c, "OutcomeDetail", timedOut ? "Time ran out before you reached the target." :
|
|
|
+ "There are no open cells for your next group.", 310, 563, 510, 72, 28);
|
|
|
+ if (!round.ReviveUsed && Ads != null && Ads.Supported)
|
|
|
+ {
|
|
|
+ string effect = timedOut ? "+30 SECONDS" : "FREE 3 CELLS";
|
|
|
+ if (timedOut && !round.Cells.Any(cell => cell.need <= round.Score && cell.tiles.Count == 0))
|
|
|
+ effect = "+30 SECONDS · FREE 3 CELLS";
|
|
|
+ BindAdButton(HexUI.Button(c, "AdRevive", "WATCH AD TO REVIVE\n" + effect, 310, 685, 535, 93,
|
|
|
+ () => WatchReward("result", null, "Back in play", () => ResumeRound(round)), "panel", 26));
|
|
|
+ }
|
|
|
+ else HexUI.Text(c, "RewardStatus", "No reward this round.", 310, 647, 500, 42, 21, false, HexUI.Muted);
|
|
|
+ }
|
|
|
+
|
|
|
+ var back = HexUI.Button(modal, "Footer_BACK", "", 193, 1144, 181, 82, LeaveGame, null);
|
|
|
+ HexUI.Image(back.transform, "BackArrow", "icon_back", 38, 41, 22, 25);
|
|
|
+ back.targetGraphic = HexUI.Text(back.transform, "Label", "BACK", 107, 41, 116, 46, 26);
|
|
|
+ string next = resultWin ? (level == 20 ? "REPLAY LV 20" : "NEXT LEVEL") : "RETRY";
|
|
|
+ HexUI.Button(modal, "Footer_" + next, next, 480, 1144, 360, 84,
|
|
|
+ () => { CloseAll(); StartLevel(mode, resultWin ? Math.Min(20, level + 1) : level); }, "primary", 32, true);
|
|
|
+ }
|
|
|
+ static void ResultStat(Transform parent, string label, int value, float x)
|
|
|
+ {
|
|
|
+ HexUI.Text(parent, label + "Label", label, x, 318, 178, 35, 21, false, HexUI.Muted);
|
|
|
+ HexUI.Text(parent, label + "Value", value.ToString("N0"), x, 375, 180, 66, 46, true);
|
|
|
+ }
|
|
|
+ static void ResultReward(Transform parent, string icon, int amount, string label, float x)
|
|
|
+ {
|
|
|
+ HexUI.Image(parent, icon, icon, x, 66, 60, 60);
|
|
|
+ LeftText(parent, label + "Amount", "+" + amount.ToString("N0"), x + 42, 52, 132, 45, 35, true);
|
|
|
+ LeftText(parent, label + "Label", label, x + 43, 90, 133, 33, 18);
|
|
|
+ }
|
|
|
+ void ResumeRound(HexRules round)
|
|
|
+ {
|
|
|
+ if (Game != round || !round.TryRevive()) return;
|
|
|
+ CloseAll();
|
|
|
+ finished = Busy = hammer = false;
|
|
|
+ resumedFrame = Time.frameCount;
|
|
|
+ SelectedSlot = activePointerSlot = -1;
|
|
|
+ if (dragGhost != null) Destroy(dragGhost.gameObject);
|
|
|
+ dragGhost = null;
|
|
|
+ hintText.text = "DRAG TO AN EMPTY CELL";
|
|
|
+ DrawBoard(); DrawHand(); DrawDock(); UpdateHud();
|
|
|
}
|
|
|
void ResetPanel()
|
|
|
{
|
|
|
@@ -213,20 +532,65 @@ namespace HexaCrazy
|
|
|
};
|
|
|
void HelpPanel()
|
|
|
{
|
|
|
- float height=80+8*160;for(int i=0;i<11;i++)height+=faqOpen[i]?178:76;
|
|
|
- var c=Content(height);PText(c,"STACK · SORT · CLEAR",32,50,31,true);float y=135;
|
|
|
- for(int i=0;i<8;i++)
|
|
|
+ HelpTab("HOW TO PLAY", false, 228);
|
|
|
+ HelpTab("FAQ", true, 522);
|
|
|
+ if (helpShowsFaq) BuildFaqList();
|
|
|
+ else
|
|
|
{
|
|
|
- var parts=Steps[i].Split('|');HexUI.Image(c,"StepPanel","panel",310,y,600,147,null,true);
|
|
|
- HexUI.Text(c,"Number",(i+1).ToString("00"),50,y-36,65,50,36,true);HexUI.Text(c,"StepTitle",parts[0],345,y-42,470,45,25,true);
|
|
|
- HexUI.Text(c,"StepBody",parts[1],338,y+27,490,90,20);y+=160;
|
|
|
+ const float rowHeight = 174;
|
|
|
+ var c = Content(16 + Steps.Length * rowHeight, 85);
|
|
|
+ for (int i = 0; i < Steps.Length; i++)
|
|
|
+ {
|
|
|
+ float y = 10 + i * rowHeight;
|
|
|
+ var parts = Steps[i].Split('|');
|
|
|
+ HexUI.Text(c, "Number", (i+1).ToString("00"), 60, y + 38, 76, 53, 35, true);
|
|
|
+ LeftText(c, "StepTitle", parts[0], 118, y + 37, 468, 43, 26, true);
|
|
|
+ LeftText(c, "StepBody", parts[1], 118, y + 109, 466, 89, 22);
|
|
|
+ Hairline(c, 310, y + 165, 552);
|
|
|
+ }
|
|
|
}
|
|
|
- for(int i=0;i<11;i++)
|
|
|
+ Footer("GOT IT",ClosePanel);
|
|
|
+ }
|
|
|
+ void HelpTab(string label, bool faq, float x)
|
|
|
+ {
|
|
|
+ var tab = HexUI.Button(modal, "Tab_" + label, "", x, 332, 282, 65, () =>
|
|
|
{
|
|
|
- int f=i;var parts=Faqs[i].Split('|');HexUI.Button(c,"FAQ_"+i,(faqOpen[i]?"− ":"+ ")+parts[0],310,y,595,64,()=>{faqOpen[f]=!faqOpen[f];Reopen("help");},"panel",22);
|
|
|
- y+=76;if(faqOpen[i]){HexUI.Text(c,"Answer",parts[1],310,y+34,555,95,20);y+=102;}
|
|
|
+ if (helpShowsFaq == faq) return;
|
|
|
+ helpShowsFaq = faq;
|
|
|
+ Reopen("help");
|
|
|
+ }, null);
|
|
|
+ bool active = helpShowsFaq == faq;
|
|
|
+ tab.targetGraphic = HexUI.Text(tab.transform, "Label", label, 141, 28, 256, 43, 25, false, active ? HexUI.Cream : HexUI.Muted);
|
|
|
+ HexUI.Image(tab.transform, "Underline", null, 141, 61, 266, active ? 4 : 1.5f, active ? HexUI.Gold : HexUI.ColorOf("825B59"));
|
|
|
+ }
|
|
|
+ void BuildFaqList()
|
|
|
+ {
|
|
|
+ const float questionHeight = 76, answerHeight = 92;
|
|
|
+ var c = Content(24 + Faqs.Length * questionHeight + faqOpen.Count(open => open) * answerHeight, 85);
|
|
|
+ float y = 10;
|
|
|
+ for (int i = 0; i < Faqs.Length; i++)
|
|
|
+ {
|
|
|
+ int index = i;
|
|
|
+ var parts = Faqs[i].Split('|');
|
|
|
+ var question = HexUI.Button(c, "FAQ_" + i, "", 310, y + questionHeight / 2, 572, questionHeight, () =>
|
|
|
+ {
|
|
|
+ float offset = c.anchoredPosition.y;
|
|
|
+ faqOpen[index] = !faqOpen[index];
|
|
|
+ Reopen("help");
|
|
|
+ var list = modal.GetComponentInChildren<ScrollRect>();
|
|
|
+ list.content.anchoredPosition = new Vector2(list.content.anchoredPosition.x,
|
|
|
+ Mathf.Clamp(offset, 0, Mathf.Max(0, list.content.rect.height - list.viewport.rect.height)));
|
|
|
+ }, null);
|
|
|
+ question.targetGraphic = LeftText(question.transform, "Question", parts[0], 8, 38, 506, 60, 23);
|
|
|
+ HexUI.Text(question.transform, "Toggle", faqOpen[i] ? "−" : "+", 548, 38, 40, 48, 31, false, HexUI.Gold);
|
|
|
+ y += questionHeight;
|
|
|
+ if (faqOpen[i])
|
|
|
+ {
|
|
|
+ LeftText(c, "Answer", parts[1], 45, y + 40, 527, 83, 21, false, HexUI.Muted);
|
|
|
+ y += answerHeight;
|
|
|
+ }
|
|
|
+ Hairline(c, 310, y, 552);
|
|
|
}
|
|
|
- Footer("GOT IT",ClosePanel);
|
|
|
}
|
|
|
}
|
|
|
}
|