// Start is called before the first frame update void Start() { //Initialize everything here but only the first time because static variables if (!firstTimeStartup) { Debug.Log(Application.persistentDataPath); //By default randomizing isn't set. Unless the player wants random themes for each level. randomTheme = false; //Default level skins snakeSkin = SnakeSkins.DEFAULT; levelTheme = Themes.RANDOM; //Initialize unlock skin arrays unlockedSnakeSkins = new bool[(int)SnakeSkins.RANDOM + 1]; unlockedLevelThemes = new bool[(int)Themes.RANDOM + 1]; unlockedSnakeSkins[(int)SnakeSkins.RANDOM] = true; unlockedSnakeSkins[(int)SnakeSkins.DEFAULT] = true; unlockedLevelThemes[(int)Themes.RANDOM] = true; unlockedLevelThemes[(int)Themes.TROPICAL] = true; unlockedLevelThemes[(int)Themes.SNOW] = true; unlockedLevelThemes[(int)Themes.DESERT] = true; //Load in all unlocked skins here (And everything else) GlobalStats.Load(); //Make a list of the unlocked skins for randomization themePool = new List <Themes>(); skinPool = new List <SnakeSkins>(); CreateRandomSkinPoolList(); CheckForRandomization(); GlobalStats.hud.UpdateHUD(); firstTimeStartup = true; UpdatePlayerSkin(); } else { CheckForRandomization(); UpdatePlayerSkin(); } CalculateCosts(); }
//Call this once every level spawns in. public static void CheckForRandomization(bool themesOnly = false) { //Randomize level themes if needed. Snake can turn this off. if ((levelTheme == Themes.RANDOM || randomTheme)) { randomTheme = true; levelTheme = themePool[Random.Range(0, themePool.Count)]; Debug.Log("Themes should be random now."); } //Randomize snake skins if needed if (snakeSkin == SnakeSkins.RANDOM || randomSkin && !themesOnly) { randomSkin = true; snakeSkin = skinPool[Random.Range(0, skinPool.Count)]; Debug.Log("Skins should be random now."); } }