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);
        }
Esempio n. 2
0
 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);
        }
Esempio n. 4
0
        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]);
        }
Esempio n. 5
0
    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);
        }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 public void HideAllScreens()
 {
     foreach (var s in screens)
     {
         currentScreen = UIScreenType.None;
         s.SetActive(false);
     }
 }
Esempio n. 9
0
    /// <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;
    }
Esempio n. 10
0
 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;
     }
 }
Esempio n. 11
0
 public void HideScreens(UIScreenType screenType)
 {
     foreach (var s in screens)
     {
         if (s.GetComponent <UIScreen>().GetScreenType() == screenType)
         {
             currentScreen = UIScreenType.None;
             s.SetActive(false);
         }
     }
 }
Esempio n. 12
0
    /// <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);
        }
Esempio n. 14
0
 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);
         }
     }
 }
Esempio n. 15
0
		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);
		}
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
    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);
        }
    }
Esempio n. 18
0
    /// <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); });
            }
        }
    }
Esempio n. 19
0
    /// <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);
    }
Esempio n. 20
0
		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]);
		}
Esempio n. 21
0
 private void OnMainMenuEvent(IEventBase obj)
 {
     sendShowScreen = true;
     screen         = UIScreenType.MainMenu;
 }
Esempio n. 22
0
 public void OnQuitEvent(IEventBase obj)
 {
     sendShowScreen = true;
     screen         = UIScreenType.SignIn;
     Application.Quit();
 }
Esempio n. 23
0
 public void OnPrizeEvent(IEventBase obj)
 {
     sendShowScreen = true;
     screen         = UIScreenType.Prizes;
 }
Esempio n. 24
0
 public void OnPlayGameEvent(IEventBase obj)
 {
     sendShowScreen = true;
     screen         = UIScreenType.Layer1;
 }
Esempio n. 25
0
 public void OnLeaderboardEvent(IEventBase obj)
 {
     sendShowScreen = true;
     screen         = UIScreenType.LeaderBoard;
 }