Ejemplo n.º 1
0
 public static void beatLevel(int i)
 {
     if (i <= MaxLevel)
     {
         PlayerPrefs.SetInt("Level " + i, 1);
         print("coins is " + PlayerStats.Coins);
         winp.setCoins(PlayerStats.Coins);
         print("score is " + PlayerStats.Score);
         winp.setScore(PlayerStats.Score);
         if (PlayerPrefs.GetInt("Level " + i + " coins", 0) < PlayerStats.Coins)
         {
             PlayerPrefs.SetInt("Level " + i + " coins", PlayerStats.Coins);
             winp.setBestCoins(PlayerStats.Coins);
         }
         else
         {
             winp.setBestCoins(PlayerPrefs.GetInt("Level " + i + " coins", 0));
         }
         if (PlayerPrefs.GetInt("Level " + i + " score", 0) < PlayerStats.Score)
         {
             PlayerPrefs.SetInt("Level " + i + " score", PlayerStats.Score);
             winp.setHighscore(PlayerStats.Score);
         }
         else
         {
             winp.setHighscore(PlayerPrefs.GetInt("Level " + i + " score", 0));
         }
     }
 }
Ejemplo n.º 2
0
    public void createWinPanel()
    {
        isLevel1Complated = true;
        PlayerPrefs.SetInt("isLevel1Complated", 1);
        PlayerPrefs.Save();
        //Знайти батьківський елемент
        GameObject parent = UICamera.first.transform.parent.gameObject;
        //Створити Prefab
        GameObject obj = NGUITools.AddChild(parent, winPanelPrefab);
        //Отримати доступ до компоненту (щоб передати параметри)
        WinPanel win = obj.GetComponent <WinPanel>();

        win.setCoins(this.coins);
        win.setFruits(this.fruits, 1);
        win.setCrystal(this.crystalPanel.getObtainedCrystal(), 1);
        Time.timeScale  = 0;
        collectedCoins += coins;
        PlayerPrefs.SetInt("collectedCoins", collectedCoins);

        if (isLevel1CrysralsCollected)
        {
            PlayerPrefs.SetInt("isLevel1CrysralsCollected", 1);
        }
        PlayerPrefs.Save();
    }