// Start is called before the first frame update void Start() { decidePricesNames(); txt_selected.SetActive(false); folderPath = Path.Combine(Application.persistentDataPath, user_selection.folderName); bt_purchase.gameObject.SetActive(false); bt_select.gameObject.SetActive(true); user_selection.Load_PlayerPrefs(); //Load from Binary code string dataPath = user_selection.GetPath(user_selection.userno, folderPath); user = user_selection.Load_Binary(dataPath); //Initialize the object_selection_panel EnableSprites(); txt_coincount.text = user_selection.coincount.ToString(); panel_purchasealert.SetActive(false); //Left and Right Buttons for scrollbar LeftButton.onClick.AddListener(Decrement); RightButton.onClick.AddListener(Increment); //Buttons for changing between sprites, notes and bg Sprites.onClick.AddListener(EnableSprites); Notes.onClick.AddListener(EnableNotes); Background.onClick.AddListener(EnableBG); //Listeners for buttons to change image object bt_sprite1.onClick.AddListener(changeimg_sprite1); bt_sprite2.onClick.AddListener(changeimg_sprite2); bt_sprite3.onClick.AddListener(changeimg_sprite3); bt_sprite4.onClick.AddListener(changeimg_sprite4); bt_sprite5.onClick.AddListener(changeimg_sprite5); bt_sprite6.onClick.AddListener(changeimg_sprite6); bt_sprite7.onClick.AddListener(changeimg_sprite7); bt_note1.onClick.AddListener(changeimg_note1); bt_note2.onClick.AddListener(changeimg_note2); bt_note3.onClick.AddListener(changeimg_note3); bt_note4.onClick.AddListener(changeimg_note4); bt_bg1.onClick.AddListener(changeimg_bg1); bt_bg2.onClick.AddListener(changeimg_bg2); bt_bg3.onClick.AddListener(changeimg_bg3); bt_bg4.onClick.AddListener(changeimg_bg4); bt_toHome.onClick.AddListener(navigate_toHome); bt_purchase.onClick.AddListener(purchase_object); bt_select.onClick.AddListener(select_object); txt_hover_sprites.SetActive(false); txt_hover_notes.SetActive(false); txt_hover_bg.SetActive(false); txt_hover_sprite1.SetActive(false); }
public void calcScores() { gameoverpanel.SetActive(true); scorepanel.SetActive(false); //public GameObject gameoverpanel; //public Text myscore; // public Text myhighscore1; if (myAV.avchoice == 0 || myAV.avchoice == 1) { if (myA.score > 150) { myA.score += 100; myscore.text = "Score: " + myA.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myA.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myA.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myA.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myA.score >= highscore2) { highscore2 = myA.score; //myhighscore2.text = "High Score: " + highscore2; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 2) { if (myB.score > 150) { myB.score += 100; myscore.text = "Score: " + myB.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myB.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myB.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myB.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myB.score >= highscore2) { highscore2 = myB.score; //myhighscore2.text = "High Score: " + highscore2; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 3) { if (myC.score > 150) { myC.score += 100; myscore.text = "Score: " + myC.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myC.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myC.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myC.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myC.score >= highscore2) { highscore2 = myC.score; myhighscore2.text = "High Score: " + highscore2; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 4) { if (myD.score > 150) { myD.score += 100; myscore.text = "Score: " + myD.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myD.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myD.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myD.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myD.score >= highscore2) { highscore2 = myD.score; //myhighscore1.text = "High Score: " + highscore1; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 5) { if (myE.score > 150) { myE.score += 100; myscore.text = "Score: " + myE.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myE.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myE.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myE.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myE.score >= highscore2) { highscore2 = myE.score; //myhighscore1.text = "High Score: " + highscore1; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 6) { if (myF.score > 150) { myF.score += 100; myscore.text = "Score: " + myF.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myF.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myF.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myF.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myF.score >= highscore2) { highscore2 = myF.score; //myhighscore1.text = "High Score: " + highscore1; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } else if (myAV.avchoice == 7) { if (myG.score > 150) { myG.score += 100; myscore.text = "Score: " + myG.score; bonus.SetActive(true); } else { myscore.text = "Score: " + myG.score; } mycoins.text = "Coins: " + Mathf.RoundToInt(myG.score / 2); wallet = PlayerPrefs.GetInt("current_coincount"); wallet += Mathf.RoundToInt(myG.score / 2); PlayerPrefs.SetInt("current_coincount", wallet); if (myG.score >= highscore2) { highscore2 = myG.score; //myhighscore1.text = "High Score: " + highscore1; PlayerPrefs.SetInt("current_lvl2highscore", highscore2); } } //Load from Binary code folderPath = Path.Combine(Application.persistentDataPath, user_selection.folderName); int userno = PlayerPrefs.GetInt("current_userno"); string dataPath = user_selection.GetPath(userno, folderPath); user = user_selection.Load_Binary(dataPath); user.coincount = PlayerPrefs.GetInt("current_coincount"); user.lvl1highscore = PlayerPrefs.GetInt("current_lvl1highscore"); user.lvl2highscore = PlayerPrefs.GetInt("current_lvl2highscore"); user.lvl3highscore = PlayerPrefs.GetInt("current_lvl3highscore"); user_selection.Save_Binary(user, userno, folderPath); }