UIScreenBase LoadScreen(UIScreenType screenType) { string fileName; m_prefabFiles.TryGetValue(screenType, out fileName); if (fileName == null) { Debug.LogError("Attempting to load screen '" + screenType.ToString() + "' which does not exist in UIManagerData!"); return(null); } UIScreenBase prefab = Resources.Load <UIScreenBase>(fileName); if (prefab == null) { Debug.LogError("Could not load the ui prefab file: " + fileName); return(null); } UIScreenBase screen = GameObject.Instantiate(prefab) as UIScreenBase; GameObject go = screen.gameObject; go.transform.SetParent(gameObject.transform); go.SetActive(true); return(screen); }
void ShowScreen(UIScreenType type) { for (int i = 0; i < screens.Count; i++) { screens [i].gameObject.SetActive(screens [i].type == type); } }
public UIScreenBase SetHUD(UIScreenType screenType, UIScreenArgs args) { if (m_hud != null) { m_hud.ReleaseResources(); m_hud.transform.parent = null; m_hud.gameObject.SetActive(false); GameObject.Destroy(m_hud.gameObject); } if (screenType == UIScreenType.None) { m_hud = null; return(null); } m_hud = LoadScreen(screenType); if (m_hud == null) { return(null); } m_hud.Initialize(args); return(m_hud); }
public void SwitchToScreen(UIScreenType screenType) { int index = (int)screenType; if (screens[index] == null) { switch (screenType) { case UIScreenType.MainMenu: screens[index] = new MainMenu(installedMpq); break; case UIScreenType.Login: screens[index] = new LoginScreen(playingMpq); break; case UIScreenType.Connection: screens[index] = new ConnectionScreen(playingMpq); break; default: throw new Exception(); } } SwitchToScreen(screens[(int)screenType]); }
public void OnSubmitLayerScoreEvent(IEventBase obj) { if (obj is SubmitLayerScoreEvent) { SubmitLayerScoreEvent ls = (SubmitLayerScoreEvent)obj; if (ls.layerID > 0 && ls.layerID <= NoOfLayers) { scores[ls.layerID - 1].correctAns = ls.correctAns; scores[ls.layerID - 1].bonusPoints = ls.BonusScore; scores[ls.layerID - 1].TotalPoints = ls.score; scores[ls.layerID - 1].TimeTaken = ls.timeTaken; screen = UIScreenType.Layer1; switch (ls.layerID) { case 1: screen = UIScreenType.Layer2; break; case 2: screen = UIScreenType.Layer3; break; case 3: screen = UIScreenType.Layer4; break; case 4: screen = UIScreenType.YourScore; break; } sendShowScreen = true; } } }
public UIScreenBase SetTransitionScreen(UIScreenType screenType, UIScreenArgs args) { if (m_transitionScreen != null) { m_transitionScreen.ReleaseResources(); m_transitionScreen.transform.parent = null; m_transitionScreen.gameObject.SetActive(false); GameObject.Destroy(m_transitionScreen.gameObject); } if (screenType == UIScreenType.None) { m_transitionScreen = null; return(null); } m_transitionScreen = LoadScreen(screenType) as UIScreenBase; if (m_transitionScreen == null) { return(null); } IncrementScreenPanelDepth(m_transitionScreen, m_transitionPanelDepth); m_transitionScreen.Initialize(args); return(m_transitionScreen); }
public void OnInstructionsEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.Instructions; //string val = GetString("This is a string for Unity"); //UIManager.SetDebugText(1, "String from JS " + val); }
public void HideAllScreens() { foreach (var s in screens) { currentScreen = UIScreenType.None; s.SetActive(false); } }
/// <summary> /// /// </summary> /// <param name="previousScreen"></param> private void UpdateScreenHistory(UIScreenType screenToRecord) { for (int i = 0; i < _screenHistory.Length - 1; i++) { _screenHistory[i] = _screenHistory[i + 1]; } _screenHistory[_screenHistory.Length - 1] = screenToRecord; }
public void OnSubmitUserCredentialsEvent(IEventBase obj) { if (obj is SubmitUserCredentialsEvent) { SubmitUserCredentialsEvent userCred = (SubmitUserCredentialsEvent)obj; this.userName = userCred.userName; this.companyName = userCred.companyName; sendShowScreen = true; screen = UIScreenType.MainMenu; } }
public void HideScreens(UIScreenType screenType) { foreach (var s in screens) { if (s.GetComponent <UIScreen>().GetScreenType() == screenType) { currentScreen = UIScreenType.None; s.SetActive(false); } } }
/// <summary> /// /// </summary> /// <param name="screenType"></param> /// <param name="screen"></param> /// <returns></returns> public bool GetScreen(UIScreenType screenType, out UIScreen screen) { for (int i = 0; i < _loadedScreens.Count; i++) { if (_loadedScreens[i].screenType == screenType) { screen = _loadedScreens[i]; return(true); } } screen = null; return(false); }
public UIScreenBase PushScreen(UIScreenType screenType, UIScreenArgs args) { UIScreenBase screen = LoadScreen(screenType); if (screen == null) { return(null); } m_currentPanelDepth = IncrementScreenPanelDepth(screen, m_currentPanelDepth); m_screenStack.Push(screen); screen.Initialize(args); return(screen); }
public void DisplayScreen(UIScreenType screen) { foreach (var s in screens) { if (s.GetComponent <UIScreen>().GetScreenType() == screen) { //s.SetActive(true); s.SetActive(true); currentScreen = screen; } else { s.SetActive(false); } } }
void ShowGameModeDialog (UIScreenType nextScreen) { GameModeDialog d = new GameModeDialog (this, mpq); d.Cancel += delegate () { DismissDialog (); }; d.Activate += delegate (bool expansion) { DismissDialog (); try { Game.Instance.PlayingBroodWar = expansion; GuiUtil.PlaySound (mpq, Builtins.Mousedown2Wav); Game.Instance.SwitchToScreen (nextScreen); } catch (Exception e) { ShowDialog (new OkDialog (this, mpq, e.Message)); } }; ShowDialog (d); }
void ShowGameModeDialog(UIScreenType nextScreen) { GameModeDialog d = new GameModeDialog(this, mpq); d.Cancel += delegate() { DismissDialog(); }; d.Activate += delegate(bool expansion) { DismissDialog(); try { Game.Instance.PlayingBroodWar = expansion; GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav); Game.Instance.SwitchToScreen(nextScreen); } catch (Exception e) { ShowDialog(new OkDialog(this, mpq, e.Message)); } }; ShowDialog(d); }
public void ShowScreen(UIScreenType _screen) { if (currentScreen != _screen) { if (!allScreens.ContainsKey(_screen)) { Debug.LogError("UI Screen missing :: " + _screen.ToString()); return; } if (allScreens.ContainsKey(currentScreen)) { allScreens[currentScreen].SetActive(false); } currentScreen = _screen; allScreens[currentScreen].SetActive(true); } }
/// <summary> /// /// </summary> /// <param name="screenToOpen"></param> public void Open(UIScreenType screenToOpen) { if (screenToOpen == UIScreenType.Previous) { screenToOpen = _screenHistory[_screenHistory.Length - 2]; } UIScreen nextScreen = null; if (!GetScreen(screenToOpen, out nextScreen)) { if (!LoadScreen(screenToOpen)) { throw new Exception("Failed to load screen '" + screenToOpen + "'. Check file path."); } // GetScreen(screenToOpen, out nextScreen); } UIScreen activeScreen = null; if (!GetScreen(_screenHistory[_screenHistory.Length - 1], out activeScreen)) { // If there is no active screen then we might be opening our very first screen. ActivateScreen(nextScreen); } else { // activeScreen.Close(); if (activeScreen.transitionOffTime <= 0) { ChangeScreens(activeScreen, nextScreen); } else { DOVirtual.DelayedCall(activeScreen.transitionOffTime + 0.1f, () => { ChangeScreens(activeScreen, nextScreen); }); } } }
/// <summary> /// /// </summary> /// <param name="screenToLoad"></param> /// <returns>True if the screen is loaded, false otherwise.</returns> public bool LoadScreen(UIScreenType screenToLoad) { UIScreen screen = null; if (GetScreen(screenToLoad, out screen)) { return(true); } screen = Instantiate(Resources.Load <GameObject>("Prefabs/UI/screen_" + screenToLoad.ToString())).GetComponent <UIScreen>( ); if (screen == null) { return(false); } screen.gameObject.SetActive(false); screen.transform.parent = transform; screen.screenRect.sizeDelta = Vector2.zero; screen.transform.localScale = Vector3.one; screen.transform.localPosition = Vector3.zero; _loadedScreens.Add(screen); return(true); }
public void SwitchToScreen (UIScreenType screenType) { int index = (int)screenType; if (screens[index] == null) { switch (screenType) { case UIScreenType.MainMenu: screens[index] = new MainMenu (installedMpq); break; case UIScreenType.Login: screens[index] = new LoginScreen (playingMpq); break; case UIScreenType.Connection: screens[index] = new ConnectionScreen (playingMpq); break; default: throw new Exception (); } } SwitchToScreen (screens[(int)screenType]); }
private void OnMainMenuEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.MainMenu; }
public void OnQuitEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.SignIn; Application.Quit(); }
public void OnPrizeEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.Prizes; }
public void OnPlayGameEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.Layer1; }
public void OnLeaderboardEvent(IEventBase obj) { sendShowScreen = true; screen = UIScreenType.LeaderBoard; }