using System; using System.Linq; using TMPro; using UnityEngine; using UnityEngine.UI; using U = Olympus.OlympusUi; namespace Olympus { public sealed partial class OlympusGame { ReferenceAView referenceView; float nextLobbyRankingRefresh; string lobbyWeek,lobbyRankingName; int lobbyWeeklyScore,lobbyRankingAvatar; void Bind(string name,Action action) { var b=referenceView.FindButton(name);if(!b)throw new InvalidOperationException("Missing approved UI binding: "+name); b.onClick.AddListener(()=>{Play("click");action();}); } void ReferencePage(string name) { NewPage(name);referenceView=page.GetComponent(); if(!referenceView)throw new InvalidOperationException("Run Olympus/Rebuild approved A interface before playing."); if(backdrop){backdrop.texture=Texture(name=="Trial"?"background_olympus":"Olympus/Elements/v3_background");backdrop.color=Color.white;FitBackdrop();} } void Lobby() { game.Quit();ReferencePage("Lobby");store.EnsurePeriods(); referenceView.playerName.text=store.Data.name;referenceView.balance.text=store.Data.coins.ToString("N0");referenceView.playerAvatar.sprite=Sprite("avatar_"+store.Data.avatar); RefreshCheckinDot(); RefreshLobbyLeaderboard(true); foreach(string panel in new[]{"Profile","Check-in","Coin records","Shop","Settings","Leaderboard"}){string key=panel;Bind(key,()=>OpenPanel(key=="Leaderboard"?"Weekly":key));} foreach(string nav in new[]{"Ranks","Shop","How to","Profile","Settings"}){string key=nav;Bind("Nav "+key,()=>OpenPanel(key=="Ranks"?"Weekly":key));} for(int i=0;i{ArtReviewMode=false;Play("click");if(!game.Start(realm.id))Notify("Need "+Math.Max(0,realm.fee-store.Data.coins)+" more coins");}); } } Sprite StandingPortrait(LocalStanding row)=>Sprite("avatar_"+(row.you?row.avatar:(row.avatar+2)%10)); void RefreshLobbyLeaderboard(bool force=false) { if(!referenceView||referenceView.trial||(!force&&Time.unscaledTime();if(questionFit)questionFit.aspectRatio=v.question.sprite.rect.width/v.question.sprite.rect.height; cover.Configure(game.Current.id,game.RevealStyle);cover.SetAmount((float)game.Reveal); Bind("Menu",()=>OpenPanel("Menu"));Bind("OK",Submit);Bind("Delete",DeleteLetter); v.rivalAvatars[0].sprite=Sprite("avatar_"+store.Data.avatar); for(int i=1;i<6;i++)v.rivalAvatars[i].sprite=Sprite("avatar_"+(i+1)); foreach(var effect in v.rivalGains)effect.owner=this; int rows=game.Pool.Length>18?3:2; for(int i=0;i().text=letter.ToString(); int countInRow=Math.Min(9,game.Pool.Length-(i/9)*9); float tileSize=rows==3?60:86,pitch=rows==3?64:95; float rowInset=(851-((countInRow-1)*pitch+tileSize))*.5f; var r=(RectTransform)b.transform;r.anchoredPosition=new Vector2((rowInset+i%9*pitch)*750/941,-(i/9)*(rows==3?64:96)*750f/941);r.sizeDelta=Vector2.one*tileSize*750/941; var label=b.GetComponentInChildren();label.rectTransform.anchorMin=Vector2.zero;label.rectTransform.anchorMax=Vector2.one;label.rectTransform.offsetMin=label.rectTransform.offsetMax=Vector2.zero;label.fontSizeMax=(rows==3?44:60)*750f/941; int index=i;b.onClick.AddListener(()=>SelectLetter(index));tiles.Add(b); } for(int i=0;i<4;i++){Item item=(Item)i;v.itemButtons[i].onClick.AddListener(()=>{Play("click");if(game.Use(item))RefreshTrial();});itemButtons.Add(v.itemButtons[i]);} RefreshTrial(); } void RefreshReferenceTrial() { var v=referenceView;timer.color=game.TimeLeft<=8?new Color32(255,156,113,255):new Color32(255,244,215,255); for(int i=0;i<6;i++)v.rivalScores[i].text=(i==0?game.Score:game.Rivals[i-1].score).ToString(); for(int i=0;i<4;i++){v.inventory[i].text=store.Data.items[i].ToString();v.itemButtons[i].interactable=game.CanUse((Item)i);v.inventory[i].color=v.itemButtons[i].interactable?U.Ink:new Color(.65f,.58f,.45f);} RefreshTiles(); } void RefreshCheckinDot(){if(referenceView&&referenceView.checkinDot)referenceView.checkinDot.SetActive(store.CanCheckin);} public bool EffectsPaused => ArtReviewMode || game==null || game.Paused; void OnRivalAnswered(int index,int gain) { if(!referenceView||!referenceView.trial||game.Paused)return; referenceView.rivalScores[index+1].text=game.Rivals[index].score.ToString(); referenceView.rivalGains[index].Show(gain); if(store.Data.haptics)LightHaptics.Pulse(); } } }