Beispiel #1
0
        public static void LevelCompleted(string levelId, LevelDatabase levelDatabase)
        {
            Debug.Log("in Level Completed");
            bool found     = false;
            int  nextIndex = 0;

            for (int i = 0; i < levelDatabase.levelDatabaseEntries.Length; i++)
            {
                LevelDatabaseEntry temp = levelDatabase.levelDatabaseEntries[i];
                if (temp.levelId == levelId)
                {
                    StaticData.LevelInformation = temp;
                    found     = true;
                    nextIndex = i + 1;
                    Debug.Log("Found true");
                }
            }

            if (found)
            {
                PlayerPrefs.SetInt(levelId, 2);
                Debug.Log($"levelDataBaseEntries length = {levelDatabase.levelDatabaseEntries.Length}");
                Debug.Log($"nextIndex = {nextIndex}");
                if (nextIndex < levelDatabase.levelDatabaseEntries.Length)
                {
                    Debug.Log("setting 1 level up to unlocked");
                    PlayerPrefs.SetInt(levelDatabase.levelDatabaseEntries[nextIndex].levelId, 1);
                }
            }
            else
            {
                Debug.LogError("Level completed, but no such level found");
            }
        }
Beispiel #2
0
 public static void StartNewGame(LevelDatabase levelDatabase)
 {
     foreach (LevelDatabaseEntry levelDatabaseEntry in levelDatabase.levelDatabaseEntries)
     {
         PlayerPrefs.DeleteKey(levelDatabaseEntry.levelId);
     }
     PlayerPrefs.SetInt("Tutorial", 0);
     StaticData.LevelInformation = levelDatabase.levelDatabaseEntries[0];
     Debug.Log($"Starting level: {StaticData.LevelInformation.levelId}");
 }