Пример #1
0
    public void NextLevel()
    {
        if (!endLevelSoundPlayed)
        {
            if (SoundManager.Instance != null)
            {
                SoundManager.Instance.ObjectSounds[0].PlayAudioClip(5);
            }
            endLevelSoundPlayed = true;
        }

        if (LevelLoader.HasMoreLevels)
        {
            NPCController.SolutionTypes solution = MontyController.GetSolution();
            switch (solution)
            {
            case NPCController.SolutionTypes.Confrontation:
                LevelLoader.CurrentPlayThrough.IncreaseGoodQuestionsAfterLevelEnded(1);
                gameStats.IncreaseConfrontation(gameStats.levelDifficulty.ToString());
                break;

            case NPCController.SolutionTypes.Ignore:
            case NPCController.SolutionTypes.Flight:
                LevelLoader.CurrentPlayThrough.IncreaseBadQuestionsAfterLevelEnded(1);
                gameStats.IncreaseIgnoreFlight(gameStats.levelDifficulty.ToString());
                break;

            case NPCController.SolutionTypes.Fight:
                LevelLoader.CurrentPlayThrough.IncreaseBadQuestionsAfterLevelEnded(1);
                gameStats.IncreaseFight(gameStats.levelDifficulty.ToString());
                break;
            }

            gameStats.Save();
            LevelLoader.LoadNextLevel();
        }
        else if (SceneManager.GetActiveScene().name == "Tutorial")
        {
            SceneManager.LoadScene("MainMenuScene");
            endLevelSoundPlayed = false;
        }
        else if (!playthroughEnded)
        {
            NPCController.SolutionTypes solution = MontyController.GetSolution();
            switch (solution)
            {
            case NPCController.SolutionTypes.Confrontation:
                LevelLoader.CurrentPlayThrough.IncreaseGoodQuestionsAfterLevelEnded(1);
                gameStats.IncreaseConfrontation(gameStats.levelDifficulty.ToString());
                break;

            case NPCController.SolutionTypes.Ignore:
            case NPCController.SolutionTypes.Flight:
                LevelLoader.CurrentPlayThrough.IncreaseBadQuestionsAfterLevelEnded(1);
                gameStats.IncreaseIgnoreFlight(gameStats.levelDifficulty.ToString());
                break;

            case NPCController.SolutionTypes.Fight:
                LevelLoader.CurrentPlayThrough.IncreaseBadQuestionsAfterLevelEnded(1);
                gameStats.IncreaseFight(gameStats.levelDifficulty.ToString());
                break;
            }

            RewardsText rewardsText = endGamePrefab.GetComponentInChildren <RewardsText>();
            if (rewardsText != null)
            {
                rewardsText.SetText();
            }

            if (LevelLoader.CurrentPlayThrough.GoodQuestionsPlaythrough == LevelLoader.DEFAULT_LEVEL_AMOUNT)
            {
                GameStats.Instance.IncreaseDifficulty();
            }
            if (LevelLoader.CurrentPlayThrough.BadQuestionsPlaythrough >= minQuestionsToDecreaseDifficulty)
            {
                GameStats.Instance.DecreaseDifficulty();
            }

            LevelLoader.EndPlaythrough();
            playthroughEnded = true;
            endGamePrefab.SetActive(true);
            endLevelSoundPlayed = false;
            gameStats.EndPlaythrough(DateTime.Now);
            gameStats.Save();
        }
    }