コード例 #1
0
        public void OnCountdownFinished()
        {
            m_currentState      = DCCurrentState.gameplay;
            m_blockInteractions = false;

            m_pausePlayEvent.Raise(false);
            //Debug.Log("playing");
        }
コード例 #2
0
 public void OnGamePaused(bool isPaused)
 {
     //Debug.Log("pause=" + isPaused);
     if (isPaused)
     {
         m_currentState      = DCCurrentState.pause;
         m_blockInteractions = true;
         m_pausePlayEvent.Raise(isPaused);
         Debug.Log("attempting to pause");
     }
     else
     {
         m_currentState = DCCurrentState.countdown;
         m_startCountdownEvent.Raise();
     }
 }
コード例 #3
0
        private IEnumerator GameWon()
        {
            Debug.Log("game won!");
            m_currentState      = DCCurrentState.gameWon;
            m_blockInteractions = true;
            m_pausePlayEvent.Raise(true);
            m_requestPauseGameEvent.Raise(true);
            m_enterTransitionEvent.Raise();
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            m_exitTransitionEvent.Raise();

            //show you won UI
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            m_blockInteractions = false;
        }
コード例 #4
0
        private IEnumerator GameLost()
        {
            Debug.Log("game lost!");
            m_currentState      = DCCurrentState.gameLost;
            m_blockInteractions = true;
            yield return(new WaitForSeconds(2f));    //pause to allow death animations

            m_requestPauseGameEvent.Raise(true);
            m_pausePlayEvent.Raise(true);
            m_enterTransitionEvent.Raise();
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            m_exitTransitionEvent.Raise();

            //show you lost UI
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            m_blockInteractions = false;
        }
コード例 #5
0
        public void OnAnyKeyDown()
        {
            if (m_currentState == DCCurrentState.levelIntro && !m_blockInteractions)
            {
                m_currentState = DCCurrentState.countdown;
                m_closeLevelIntroEvent.Raise();
                m_unitPlacer.PlaceUnits();
                m_startCountdownEvent.Raise();
            }

            if (!m_blockInteractions && (m_currentState == DCCurrentState.gameWon || m_currentState == DCCurrentState.gameLost))
            {
                //transitions and UI etc
                StartCoroutine(LoadFirstLevel());
                //reset scoring etc.
            }

            //only for debugging
            if (m_currentState == DCCurrentState.gameplay)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    Debug.Log("1 pressed: go to win state");
                    OnGameWon();
                }
                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    Debug.Log("2 pressed: go to lose state");
                    OnGameLost();
                }
                if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    Debug.Log("3 pressed: lost a life");    //this will be notified via a void event
                    OnLifeLost();
                }
                if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    Debug.Log("4 pressed: level complete");    //this will be notified via a void event
                    OnLevelComplete();
                }
            }
        }
コード例 #6
0
        private IEnumerator LoadFirstLevel()
        {
            //pause and transition
            m_currentState      = DCCurrentState.loadingLevel;
            m_blockInteractions = true;
            m_pausePlayEvent.Raise(true);
            m_requestPauseGameEvent.Raise(true);
            m_enterTransitionEvent.Raise();
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            //load level
            m_levels.SetupFirstLevel(m_terrainGen);
            m_unitPlacer.SetLevelAsset(m_levels.CurrentLevel());
            yield return(new WaitForSeconds(1f));

            m_exitTransitionEvent.Raise();
            yield return(new WaitForSeconds(m_transitionDuration.Value));

            //show intro
            m_requestIntroUIEvent.Raise(m_levels.CurrentLevel());
            m_currentState      = DCCurrentState.levelIntro;
            m_blockInteractions = false;
        }