Example #1
0
    //?
    //? F R O M
    //? T H E
    //? G H A S T L Y
    //? E Y R I E S
    //? I
    //? C A N
    //? S E E
    //? T O
    //? T H E
    //? E N D S
    //? O F
    //? T H E
    //? W O R LD
    //? A N D
    //? F R O M
    //? T H I S
    //? V A N T A G E
    //? P O I NT
    //? I
    //? D E C L A R E
    //? W I T H
    //? U T T E R
    //? C E R T A I N T Y
    //? T H A T
    //? T H I S
    //? O N E
    //? I S
    //? I N
    //? T H E
    //? B A G
    //? .
    //?
    // Update is called once per frame
    void Update()
    {
        //if the top of the stack is the peek of this transform's parent's parent
        if (UIManager.Instance.menuStatus.Peek() == this.transform.parent.parent.gameObject)
        {
            CheckForStickReset();
            if (_eventSystem.enabled)
            {
                //if the event systems currently selected object is my assigned buttons parent, do the things according to my type.
                if (_eventSystem.currentSelectedGameObject.transform.parent == _button.transform.parent)
                {
                    m_Arrows.SetActive(true);
                    m_fTimeSelected += Time.deltaTime;
                    m_OuterGlow.SetActive(true);
                    switch (m_pickType)
                    {
                    case PickType.GAMEMODEPICK:
                        #region

                        GameManagerc.Instance.m_gameMode = Gamemode_type.LAST_MAN_STANDING_DEATHMATCH + m_iGamemodeIndex;
                        //check for right input
                        //If Dpad right, increment through the array
                        //If dpad left, decrement through the array
                        //wrap around if at the bounds of array
                        if ((DpadHorizontalTest() > 0) || StickMovement[1])
                        {
                            m_animator.SetTrigger("ButtonChangeRight");
                            StickMovement[1] = false;
                            if (m_iGamemodeIndex == (int)Gamemode_type.HEAD_HUNTERS)
                            {
                                m_iGamemodeIndex = 0;
                            }
                            else
                            {
                                m_iGamemodeIndex++;
                            }

                            m_GamemodeSelected = Gamemode_type.LAST_MAN_STANDING_DEATHMATCH + m_iGamemodeIndex;
                        }
                        else if ((DpadHorizontalTest() < 0) || StickMovement[0])
                        {
                            m_animator.SetTrigger("ButtonChangeLeft");
                            StickMovement[0] = false;
                            if (m_iGamemodeIndex == 0)
                            {
                                m_iGamemodeIndex = (int)Gamemode_type.HEAD_HUNTERS;
                            }
                            else
                            {
                                m_iGamemodeIndex--;
                            }

                            m_GamemodeSelected = Gamemode_type.LAST_MAN_STANDING_DEATHMATCH + m_iGamemodeIndex;
                        }
                        break;

                        #endregion
                    case PickType.MAPPICK:
                        #region
                    {
                        _mapSprite.sprite = mapSprites[m_iMapPickIndex];
                        GameManagerc.Instance.MapToLoad = MapObjects[m_iMapPickIndex];
                        if ((DpadHorizontalTest() > 0) || StickMovement[1])
                        {
                            m_animator.SetTrigger("ButtonChangeRight");
                            StickMovement[1] = false;
                            if (m_iMapPickIndex == mapSprites.Length - 1)
                            {
                                m_iMapPickIndex = 0;
                            }
                            else
                            {
                                m_iMapPickIndex++;
                            }
                        }
                        else if ((DpadHorizontalTest() < 0) || StickMovement[0])
                        {
                            m_animator.SetTrigger("ButtonChangeLeft");
                            StickMovement[0] = false;

                            if (m_iMapPickIndex == 0)
                            {
                                m_iMapPickIndex = mapSprites.Length - 1;
                            }
                            else
                            {
                                m_iMapPickIndex--;
                            }
                        }
                    }
                    break;

                        #endregion
                    case PickType.GAMEMODESETTINGS:
                        #region
                        if ((DpadHorizontalTest() > 0) || StickMovement[1])
                        {
                            m_animator.SetTrigger("ButtonChangeRight");
                            StickMovement[1] = false;
                            if (m_iPointWinIndex == mPointsToWin.Length - 1)
                            {
                                m_iPointWinIndex = 0;
                            }
                            else
                            {
                                m_iPointWinIndex++;
                            }
                        }
                        else if ((DpadHorizontalTest() < 0) || StickMovement[0])
                        {
                            m_animator.SetTrigger("ButtonChangeLeft");
                            StickMovement[0] = false;

                            if (m_iPointWinIndex == 0)
                            {
                                m_iPointWinIndex = mPointsToWin.Length - 1;
                            }
                            else
                            {
                                m_iPointWinIndex--;
                            }
                        }
                        _SettingsValue.text = mPointsToWin[m_iPointWinIndex].ToString("0");
                        GameManagerc.Instance.m_iPointsNeeded = (int)mPointsToWin[m_iPointWinIndex];
                        GameManagerc.Instance.m_iPointsIndex  = m_iPointWinIndex;
                        #endregion
                        break;
                    }
                }
                else
                {
                    m_Arrows.SetActive(false);
                    m_fTimeSelected = 0;
                    m_OuterGlow.SetActive(false);
                }
            }

            //update button sprite according to pick type
            switch (m_pickType)
            {
            case PickType.GAMEMODEPICK:
                switch (m_GamemodeSelected)
                {
                case Gamemode_type.LAST_MAN_STANDING_DEATHMATCH:
                    ButtonImage.sprite = GamemodeSprites[0];
                    break;

                case Gamemode_type.HEAD_HUNTERS:
                    ButtonImage.sprite = GamemodeSprites[1];
                    //transform.parent.Find("PointsToWin_Selection").Find("PointsToWin_Button").GetChild(0).GetComponent<Image>().sprite = GetXToWinSprite[1];
                    break;

                //case Gamemode_type.DEATHMATCH_POINTS:
                //    _buttonText.text = "Gamemode: MaxKills Deathmatch";
                //    break;
                //case Gamemode_type.DEATHMATCH_TIMED:
                //    _button.GetComponentInChildren<Text>().text = "Gamemode: Timed Deathmatch";
                //    break;
                //case Gamemode_type.CAPTURE_THE_FLAG:
                //    _button.GetComponentInChildren<Text>().text = "Gamemode: Capture the flag";
                //    break;
                default:
                    break;
                }
                //GameManagerc.Instance.m_iPointsNeeded = mPointsToWin[m_iPointWinIndex];
                break;

            case PickType.MAPPICK:
                _mapSprite.sprite = mapSprites[m_iMapPickIndex];
                break;

            case PickType.GAMEMODESETTINGS:
                switch (GameManagerc.Instance.m_gameMode)
                {
                case Gamemode_type.LAST_MAN_STANDING_DEATHMATCH:
                    this.transform.Find("PointsToWin_Button").GetChild(0).GetComponent <Image>().sprite = GetXToWinSprite[0];
                    break;

                case Gamemode_type.HEAD_HUNTERS:
                    this.transform.Find("PointsToWin_Button").GetChild(0).GetComponent <Image>().sprite = GetXToWinSprite[1];
                    break;

                default:
                    break;
                }
                break;
            }

            for (int i = 0; i < (int)PlayerIndex.Four; i++)
            {
                //if any of the controllers have an input, dont reset the sticks
                if (XCI.GetAxis(XboxAxis.LeftStickX, XboxController.First + i) != 0)
                {
                    ResetSticks = false;
                    i           = int.MaxValue;
                    break;
                }
                else
                {
                    ResetSticks = true;
                }
            }
        }
    }
Example #2
0
    /// <summary>
    /// used to reutn to the character selection screen
    /// </summary>
    public void GoToStart()
    {
        Time.timeScale = 1;
        if (!screenTransition)
        {
            screenTransition = FindObjectOfType <ScreenTransition>();
        }
        for (int i = 0; i < screenTransition.transform.childCount; i++)
        {
            screenTransition.transform.GetChild(i).GetComponent <Image>().enabled = true;
        }
        if (FindObjectOfType <ScreenTransition>())
        {
            FindObjectOfType <ScreenTransition>().CloseDoor();
        }
        CameraControl.mInstance.enabled = false;
        Destroy(CameraControl.mInstance);
        //CameraControl.mInstance.m_Targets.Clear();
        //clear the players list
        for (int i = 0; i < InGamePlayers.Count; i++)
        {
            InGamePlayers[i].Clear();
            InGamePlayers[i].gameObject.SetActive(false);
            Destroy(InGamePlayers[i].gameObject, 1);
        }
        InGamePlayers = new List <PlayerStatus>();

        //Quite literally a deconstrucotr
        PlayerWins.Clear();
        PlayerWins = new Dictionary <PlayerStatus, int>();
        InGamePlayers.Clear();
        InGamePlayers = new List <PlayerStatus>();
        m_gameMode    = Gamemode_type.LAST_MAN_STANDING_DEATHMATCH;
        //FindObjectOfType<ScreenTransition>().CloseDoor();
        mInstance               = null;
        FinishUIPanel           = null;
        m_bRoundOver            = false;
        MapToLoad               = null;
        PointSprite             = null;
        PointContainers         = null;
        PointsPanel             = null;
        InGameScreenAnimator    = null;
        mbFinishedShowingScores = false;
        //  MenuPanel.SetActive(true);
        //mbLoadedIntoGame = false;
        mbInstanceIsMe = false;
        //mbFinishedPanelShown = false;
        mbMapLoaded         = false;
        m_bGamePaused       = false;
        m_bFirstTimeLoading = true;
        m_bDoReadyKill      = true;
        m_bDoGlitch         = true;
        //UIManager.Instance.gameObject.SetActive(false);
        ControllerManager.Instance.gameObject.SetActive(false);
        CharacterSelectionManager.Instance.gameObject.SetActive(false);

        //PlayerUIArray.Instance.gameObject.SetActive(false);

        UINavigation.Instance.gameObject.SetActive(false);
        //Destroy the singleton objects

        ///Destroy(PlayerUIArray.Instance.gameObject);
        Destroy(GameAudioPicker.Instance);
        Destroy(UINavigation.Instance);
        Destroy(CharacterSelectionManager.Instance);
        Destroy(ControllerManager.Instance);
        //Destroy(UIManager.Instance);
        Destroy(GameAudioPicker.Instance.gameObject);
        GetComponent <MusicFader>().FadeOut();
        StartCoroutine(ReturnToMenu());
        //Destroy(GameManagerc.Instance);
        //Destroy(this.gameObject);
    }