예제 #1
0
 public void ResetProgress()
 {
     GamePrefController.ClearCoinsForLevels(levels.options.Count);
     UpdateCollectedCoinsIcons(levels.value);
     totalCoins          = GamePrefController.GetTotalCoinsForLevels(levels.options.Count);
     totalCoinsText.text = totalCoins.ToString();
 }
    public void LoadNextLevel()
    {
        int totalCoins     = GamePrefController.GetTotalCoinsForLevels(SceneManager.sceneCountInBuildSettings);
        int nextSceneIndex = SceneManager.GetActiveScene().buildIndex;

        do
        {
            nextSceneIndex++;
        } while (GamePrefController.LoadLevelRequrement(nextSceneIndex) > totalCoins && nextSceneIndex < SceneManager.sceneCountInBuildSettings);
        if (nextSceneIndex >= SceneManager.sceneCountInBuildSettings)
        {
            LoadMainMenuScene();
        }
        else
        {
            SceneManager.LoadScene(nextSceneIndex);
        }
        Time.timeScale = 1;
    }
예제 #3
0
    void Start()
    {
        levels.ClearOptions();
        scenes = new List <string>();

#if UNITY_EDITOR
        foreach (UnityEditor.EditorBuildSettingsScene scene in UnityEditor.EditorBuildSettings.scenes)
        {
            if (scene.enabled && scene.path != SceneManager.GetActiveScene().path)
            {
                scenes.Add(System.IO.Path.GetFileNameWithoutExtension(scene.path));
            }
        }
#endif

#if !UNITY_EDITOR
        scenes.Add("Level 1");
        scenes.Add("Level 2");
        scenes.Add("Level 3");
        scenes.Add("Level 4");
        scenes.Add("Jetpack level 1");
        scenes.Add("Jetpack level 2");
        scenes.Add("Bonus level");
        scenes.Add("Jetpack bounus level");
        scenes.Add("Secret level");
#endif

        levels.AddOptions(scenes);
        levels.value = 0;
        UpdateCollectedCoinsIcons(levels.value);
        UpdateCoinsStatsForLevel(levels.value);
        totalCoins          = GamePrefController.GetTotalCoinsForLevels(levels.options.Count);
        totalCoinsText.text = totalCoins.ToString();

        if (levelsRequrement != null)
        {
            for (int i = 0; i < levelsRequrement.Length; i++)
            {
                GamePrefController.SaveLevelRequrement(i + 1, levelsRequrement[i]);
            }
        }
    }