using GameAudio = DevilLink2.Presentation.AudioManager; using System; using DevilLink2.Gameplay; using DevilLink2.Persistence; using DevilLink2.Presentation; using UnityEngine; using UnityEngine.UI; namespace DevilLink2.UI { public enum UIPage { Start, Lobby, Gameplay } [ExecuteAlways] [DisallowMultipleComponent] public sealed class UIManager : MonoBehaviour { private SavedPlayer player; private PlayerEconomy subscribedEconomy; private BoardDemoBootstrap bootstrap; private ModeSelectionController modes; private bool ownsPlayer, navigating; private readonly int[] lastInventory = new int[3]; private readonly System.Collections.Generic.HashSet heardCoins = new System.Collections.Generic.HashSet(); private GameFlowController shopFlow; private bool shopReturnsToSettings,helpReturnsToSettings; public HelpScreen Help {get;private set;} public void AttachHelp(HelpScreen help){Help=help;} public void OpenHelp(){if(!IsInitialized || CurrentPage!=UIPage.Lobby || Shop.IsVisible || Daily.IsVisible || Wheel.IsVisible || Profile.IsVisible || Settings.IsVisible || Help.IsVisible)return;transform.SetAsLastSibling();Help.transform.SetAsLastSibling();Help.Open();SetUnderlyingInput(false);} public void CloseHelp(){bool goBack=helpReturnsToSettings;helpReturnsToSettings=false;if(Help)Help.Close();SetUnderlyingInput(true);if(goBack)OpenSettings();} private void OpenHelpFromSettings(){if(!Settings.IsVisible)return;CloseSettings();OpenHelp();helpReturnsToSettings=Help.IsVisible;} public SettingsScreen Settings {get;private set;} public void AttachSettings(SettingsScreen settings){Settings=settings;} public void OpenSettings(){if(!IsInitialized || CurrentPage!=UIPage.Lobby || Shop.IsVisible || Daily.IsVisible || Wheel.IsVisible || Profile.IsVisible || Settings.IsVisible || (Help && Help.IsVisible))return;transform.SetAsLastSibling();Settings.transform.SetAsLastSibling();Settings.Open();SetUnderlyingInput(false);} public void CloseSettings(){if(Settings)Settings.Close();SetUnderlyingInput(true);} private void OpenShopFromSettings(){if(!Settings.IsVisible)return;CloseSettings();OpenShop();shopReturnsToSettings=Shop.IsVisible;} private void OnResetCompleted(){RefreshLobby();Shop.Refresh();Daily.Refresh();Wheel.Bind(null);Wheel.Bind(player);Profile.Refresh();} public ProfileScreen Profile {get;private set;} public void AttachProfile(ProfileScreen profile){Profile=profile;} public void OpenProfile(){if(!IsInitialized || CurrentPage!=UIPage.Lobby || Shop.IsVisible || Daily.IsVisible || Wheel.IsVisible || Profile.IsVisible || (Settings && Settings.IsVisible) || (Help && Help.IsVisible))return;transform.SetAsLastSibling();Profile.transform.SetAsLastSibling();Profile.Open();SetUnderlyingInput(false);} public void CloseProfile(){if(Profile)Profile.Close();SetUnderlyingInput(true);} private void OnProfileChanged(){RefreshLobby();if(Profile)Profile.Refresh();} public LuckyWheelScreen Wheel {get;private set;} public void AttachWheel(LuckyWheelScreen wheel) {Wheel=wheel;} public void OpenWheel() { if(!IsInitialized || CurrentPage!=UIPage.Lobby || Shop.IsVisible || Daily.IsVisible || Wheel.IsVisible || (Profile && Profile.IsVisible) || (Settings && Settings.IsVisible) || (Help && Help.IsVisible))return; transform.SetAsLastSibling(); Wheel.transform.SetAsLastSibling(); Wheel.Open(); SetUnderlyingInput(false); } public void CloseWheel() {if(Wheel)Wheel.Close(); SetUnderlyingInput(true);} public DailyCheckInScreen Daily { get; private set; } public void AttachDaily(DailyCheckInScreen daily) { Daily=daily; } public void OpenDaily() { if(!IsInitialized || CurrentPage!=UIPage.Lobby || Shop.IsVisible || Daily.IsVisible || (Wheel && Wheel.IsVisible) || (Profile && Profile.IsVisible) || (Settings && Settings.IsVisible) || (Help && Help.IsVisible))return; transform.SetAsLastSibling(); Daily.transform.SetAsLastSibling(); Daily.Open(); SetUnderlyingInput(false); } public void CloseDaily() { if(Daily)Daily.SetVisible(false); SetUnderlyingInput(true); } public ShopScreen Shop { get; private set; } public Button GameShopButton { get; private set; } public void AttachShop(ShopScreen shop) { Shop=shop; GameShopButton=Gameplay.transform.Find("ShopEntry")?.GetComponent