void Start() { // If a high score exist in player prefs, put it in if (PlayerPrefs.HasKey("highscore")) { highscore = PlayerPrefs.GetInt("highscore"); } if (PlayerPrefs.HasKey("player")) { playerStoreID = PlayerPrefs.GetInt("player"); } //Checks player purchases starting from the 3rd element (0 based numerical ID) //If more **FREE** characters are added, add a if check in the for loop and update the else clause if (PlayerPrefs.HasKey("playerPurchase2")) { purchaseListPlayer.Add(1); purchaseListPlayer.Add(1); //Subtract 2 in the loop to remove first 2 characters //Adds 2 playerpref name to prevent saving over character 0 and 1 for (int i = 0; i < storePlayerSprites.Length - 2; ++i) { purchaseListPlayer.Add(PlayerPrefs.GetInt("playerPurchase" + (2 + i).ToString())); } } else //Otherwise, adds 1,1 and 0 for the rest { purchaseListPlayer.Add(1); purchaseListPlayer.Add(1); for (int i = 0; i < storePlayerSprites.Length - 2; ++i) { purchaseListPlayer.Add(0); } } UIObj[4].GetComponent <Image>().sprite = storePlayerSprites[playerStoreID]; if (PlayerPrefs.HasKey("soundVol")) { soundVol = PlayerPrefs.GetFloat("soundVol"); bgmVol = PlayerPrefs.GetFloat("bgmVol"); UIObj[9].GetComponent <Slider>().value = bgmVol; UIObj[10].GetComponent <Slider>().value = soundVol; } else { soundVol = 0.5f; bgmVol = 0.2f; } // Set player gender if (playerStoreID == 0) { player.GetComponent <Player>().SetGender(true); } else { player.GetComponent <Player>().SetGender(false); } MainMenuBGM.Play(); }
//Handles all UI transistions public void UI(int id) { switch (id) { case -2: UIObj[2].SetActive(true); UIObj[3].SetActive(false); break; case -1: UIObj[0].SetActive(true); UIObj[1].SetActive(false); UIObj[2].SetActive(false); break; case 0: UIObj[0].SetActive(false); gameStart(); MainMenuBGM.Stop(); GameBGM.Play(); break; case 1: UIObj[0].SetActive(false); UIObj[1].SetActive(true); break; case 2: UIObj[0].SetActive(false); UIObj[2].SetActive(true); break; case 3: Application.Quit(); break; case 4: UIObj[2].SetActive(false); UIObj[3].SetActive(true); break; case 5: UIObj[0].SetActive(true); player.SetActive(false); monster.SetActive(false); UIObj[6].GetComponent <Animator>().Play("UIMoveDown"); foreach (GameObject i in GameObject.FindGameObjectsWithTag("obstacle")) { Destroy(i); } GameBGM.Stop(); MainMenuBGM.Play(); break; case 6: UIObj[6].GetComponent <Animator>().Play("UIMoveDown"); gameStart(); break; } UIButtonPress.Play(); }