Пример #1
0
    //TODO: Move this part to GUIManager for consistence of code
    void OnGUI()
    {
        if (!isPause)
        {
            foreach (GameObject item in pauseItems)
            {
                //if (item.activeInHierarchy)
                item.SetActive(false);
            }
        }
        else
        {
            foreach (GameObject item in pauseItems)
            {
                //if(!item.activeInHierarchy)
                item.SetActive(true);
            }

            if (guiHelper.GetButtonPress("SoundButton"))
            {
                guiHelper.SetButtonPress("SoundButton", false);

                isSoundEnable = !isSoundEnable;
                if (isSoundEnable)
                {
                    guiHelper.ChangeButtonTexture("SoundButton", 0);
                    // reopen or play background music
                    if (InGameAudioManager.Instance.BackgroundCheck() == false) // no background created
                    {
                        InGameAudioManager.Instance.PlayBackground(transform.position, 0.5f);
                    }
                    else
                    {
                        InGameAudioManager.Instance.ContinuePlayBackgroudMusic();
                    }
                }
                else
                {
                    guiHelper.ChangeButtonTexture("SoundButton", 1);
                    // pause background
                    if (InGameAudioManager.Instance.BackgroundCheck() == true)
                    {
                        InGameAudioManager.Instance.PauseBackgroundMusic();
                    }
                }
            }

            if (guiHelper.GetButtonPress("QuitButton"))
            {
                guiHelper.SetButtonPress("QuitButton", false);
                MultiplayerManager.Instance.LeaveRoom(2);
                Application.LoadLevel("lobby");
            }

            if (guiHelper.GetButtonPress("RespawnButton"))
            {
                guiHelper.SetButtonPress("RespawnButton", false);
                isPause = false;
                if (testMultiplayer != null)
                {
                    player.transform.position = new Vector3(MultiplayerManager.Instance.MyPlayer.team * 2, 2, 0);
                }
                else
                {
                    player.transform.position = new Vector3(0, 2, 0);
                }
                player.GetComponent <PlayerMovement>().ResetAllStates();
            }

            if (guiHelper.GetButtonPress("ResumeButton"))
            {
                guiHelper.SetButtonPress("ResumeButton", false);
                isPause = false;
            }
        }

        /*
         * if (!guiHelper.guiUpdated)
         * {
         *  ColoredGUISkin.Instance.UpdateGuiColors(guiHelper.primaryColor, guiHelper.secondaryColor);
         *  guiHelper.guiUpdated = true;
         * }
         */
        if (gameEnd == 0)
        {
            foreach (GameObject item in endgameItems)
            {
                item.SetActive(false);
            }
        }
        //Display for end game
        else if (gameEnd != 0)
        {
            // Close pause menu if it's opening,
            // set its active value maybe better than set bool value
            isPause = false;
            //Display result popup
            DisplayResult();
        }
    }