Exemplo n.º 1
0
    public void SetGameState(EState state)
    {
        GameState = state;

        switch (state)
        {
        case EState.Reset:
            Player.ResetData();

            foreach (var child in GhostList)
            {
                child.ResetData();
            }

            SetGameState(EState.Prepare);
            break;

        case EState.Prepare:
            CurrentStage.SetActiveReadyText(true);
            AudioManager.Instance.PlaySound(EBgmId.StartMusic);
            AudioManager.Instance.SetVolume(0.5f);
            StartCoroutine(CountDownPrepareTime());
            break;

        case EState.Play:
            AudioManager.Instance.SetVolume(1.0f);
            AudioManager.Instance.PlayRandomBgm();
            AudioManager.Instance.PlayGhostSound(true);
            CurrentStage.SetActiveReadyText(false);
            break;

        case EState.PacManDie:
            Player.Die();
            lifeCount--;
            StageUIManager.Instance.SetLifeCount(lifeCount);
            StartCoroutine(CountDownResetTime());
            break;

        case EState.GameOver:
            AudioManager.Instance.StopBgm();
            StartCoroutine(StartGameOverAnimation());
            break;

        case EState.StageOver:
            AudioManager.Instance.StopBgm();
            AudioManager.Instance.PlayGhostSound(false);
            fruitIndex++;
            StartCoroutine(CountDownStageOverTime());
            ScoreManager.Instance.SaveCurrentScore();
            break;
        }
    }