Example #1
0
        private void Update()
        {
            if (m_isGoinNext)
            {
                return;
            }

            m_indicator.SetActive(m_charactersReady != null && m_charactersReady.Where(c => c.activeInHierarchy).ToArray().Length > 0);

            switch (m_state)
            {
            case EndLevelState.NotReady:
                break;

            case EndLevelState.Ready:
                CharController currentController = CharactersManager.I.GetCurrentController();
                if (Input.GetButtonDown("LeaderQuit") && m_charactersReady != null && m_charactersReady.Count <= 5 && m_charactersReady.FirstOrDefault(c => GameObject.ReferenceEquals(c, currentController.gameObject)))
                {
                    GameManager.SavePlayerType(currentController.PlayerType);

                    if (currentController.PlayerType == PlayerTypesFlag.Leader)
                    {
                        leaderSaved = true;
                        GameManager.DisplayLeaderSaved();
                    }

                    StartCoroutine(FadePerso(currentController.gameObject, 1.0f));

                    if (m_endLevelSource)
                    {
                        m_endLevelSource.Play();
                    }

                    if ((GameManager.PlayerTypesToSpawn == GameManager.PlayerHereAtStart || CharactersManager.I.characters.Count == GameManager.NbPlayerTypesToSpawn) && !m_isGoinNext)     // everyone saved
                    {
                        m_isGoinNext = true;
                        GameManager.NextLevel();
                        return;
                    }

                    if (!m_isGoinNext)
                    {
                        CharactersManager.I.NextCharacter();
                    }
                }
                if (Input.GetButtonDown("Submit") && leaderSaved && !m_isGoinNext)
                {
                    //print("foo 2");
                    m_isGoinNext = true;
                    GameManager.NextLevel();
                }
                break;

            case EndLevelState.Quit:

                break;

            default:
                break;
            }
        }