Esempio n. 1
0
 private void SaveData()
 {
     SPlayerPrefs.SetInt("Attempts_" + lvlCount, lvlAttempts);
     SPlayerPrefs.SetInt("Money", money);
     SPlayerPrefs.SetInt("TotalJumps", TotalJumps);
     SPlayerPrefs.SetInt("Jumps_" + lvlCount, lvlJumps);
     SPlayerPrefs.Save();
 }
Esempio n. 2
0
 private void OnDisable()
 {
     Debug.Log("Save in disable");
     if (progress > SPlayerPrefs.GetFloat("Progress_" + lvlCount))
     {
         Debug.Log("Save " + progress);
         SPlayerPrefs.SetFloat("Progress_" + lvlCount, progress);
         SPlayerPrefs.Save();
     }
 }
Esempio n. 3
0
    void Start()
    {
        jumps     = GameObject.Find("Jumps");
        attempts  = GameObject.Find("Attempts");
        percent   = GameObject.Find("Percentage");
        playOrBuy = GameObject.Find("PlayOrBuy");
        //Min amount of jumps to complete the lvl
        lvlCount = SPlayerPrefs.GetInt("Count");
        //Первые две карты изначально открыты
        SPlayerPrefs.SetInt("Buyed_0", 1);
        SPlayerPrefs.SetInt("Buyed_1", 1);
        SPlayerPrefs.Save();

        if (SPlayerPrefs.HasKey("Jumps_" + lvlCount))
        {
            lvlJumps = SPlayerPrefs.GetInt("Jumps_" + lvlCount);
        }
        else
        {
            SPlayerPrefs.SetInt("Jumps_" + lvlCount, 0);
        }
        if (SPlayerPrefs.HasKey("Attempts_" + lvlCount))
        {
            lvlAttempts = SPlayerPrefs.GetInt("Attempts_" + lvlCount);
        }
        else
        {
            SPlayerPrefs.SetInt("Attempts_" + lvlCount, 0);
        }
        if (SPlayerPrefs.HasKey("Progress_" + lvlCount))
        {
            progress = SPlayerPrefs.GetFloat("Progress_" + lvlCount);
        }
        else
        {
            SPlayerPrefs.SetFloat("Progress_" + lvlCount, 0);
        }
        if (SPlayerPrefs.HasKey("Buyed_" + lvlCount))
        {
            lvlBuyed = SPlayerPrefs.GetInt("Buyed_" + lvlCount);
        }
        else
        {
            SPlayerPrefs.SetInt("Buyed_" + lvlCount, 0);
        }
        if (SPlayerPrefs.HasKey("Money"))
        {
            money = SPlayerPrefs.GetInt("Money");
        }
        else
        {
            SPlayerPrefs.SetInt("Money", 0);
        }
    }
Esempio n. 4
0
 public static void BuyLevel(int cnt)
 {
     if (money >= priceLvl[cnt])
     {
         money -= priceLvl[cnt];
         SPlayerPrefs.SetInt("Money", money);
         SPlayerPrefs.SetInt("Buyed_" + lvlCount, 1);
         lvlBuyed = 1;
         SPlayerPrefs.Save();
     }
 }
Esempio n. 5
0
    private void OnMouseUpAsButton()
    {
        string state;

        if (gameObject == tnt)
        {
            state = SPlayerPrefs.GetString(STATEITEM + direct);
            if (state == "Buy")
            {
                Debug.Log("pez " + direct);
                money = SPlayerPrefs.GetInt("Money");
                if (money >= priceItem[direct])
                {
                    money -= priceItem[direct];
                    SPlayerPrefs.SetInt("Money", money);
                    SPlayerPrefs.SetString(STATEITEM + direct, "Buyed");
                    SPlayerPrefs.Save();
                    textButton.GetComponent <Text>().text = "Buyed";
                }
            }
        }
        else
        {
            //gameObject.GetComponent<Image>().color = Color.red;
            direct = itemCount;
            state  = SPlayerPrefs.GetString(STATEITEM + itemCount);
            Debug.Log(state);
            if (state == "Buyed")
            {
                for (int i = 0; i < priceItem.Length; i++)
                {
                    if (SPlayerPrefs.GetString(STATEITEM + i) == "Selected")
                    {
                        SPlayerPrefs.SetString(STATEITEM + i, "Buyed");
                        break;
                    }
                }
                SPlayerPrefs.SetString(STATEITEM + itemCount, "Selected");
                SPlayerPrefs.SetInt("DigitStateItemIsSelected", itemCount);
                SPlayerPrefs.Save();
                textButton.GetComponent <Text>().text = "Selected";
            }
            else if (state == "Selected")
            {
                textButton.GetComponent <Text>().text = "Selected";
            }
            else if (state == "Buy")
            {
                textButton.GetComponent <Text>().text = "Buy " + priceItem[itemCount];
            }
            Debug.Log("post" + state);
        }
    }
Esempio n. 6
0
    //Логика уничтожения объектов на сцене
    public void destroyScene()
    {
        StartCoroutine(createPlayerExplosion(gameObject));

        //Запись лучшего счета
        if (SPlayerPrefs.GetFloat("Score") < GameObject.Find("Score").GetComponent <ScoreCounter>().score)
        {
            SPlayerPrefs.SetFloat("Score", GameObject.Find("Score").GetComponent <ScoreCounter>().score);
            SPlayerPrefs.Save();
        }

        Destroy(gameObject);

        GameObject[] heads       = GameObject.FindGameObjectsWithTag("EnemyHead");
        GameObject[] headSprites = GameObject.FindGameObjectsWithTag("HeadSprite");
        GameObject[] backs       = GameObject.FindGameObjectsWithTag("Back");
        GameObject[] tails       = GameObject.FindGameObjectsWithTag("Tail");

        foreach (GameObject head in heads)
        {
            StartCoroutine(createExplosion(head));
            Destroy(head);
        }

        foreach (GameObject headSprite in headSprites)
        {
            Destroy(headSprite);
        }

        foreach (GameObject back in backs)
        {
            StartCoroutine(createExplosion(back));
            Destroy(back);
        }

        foreach (GameObject tail in tails)
        {
            StartCoroutine(createExplosion(tail));
            Destroy(tail);
        }

        EnemyHead.speed = 0;

        GameStatus.gameStatus = "GameOver";
    }
Esempio n. 7
0
    //private string state = "init";

    void Start()
    {
        textButton = GameObject.Find("TextButton");
        tnt        = GameObject.Find("TntButton");
        if (!SPlayerPrefs.HasKey("Money"))
        {
            SPlayerPrefs.SetInt("Money", 0);
        }
        money = SPlayerPrefs.GetInt("Money");
        //SPlayerPrefs.SetString(STATEITEM + "1", "Buy");
        if (gameObject != tnt)
        {
            visualStateSelected = transform.GetChild(1).gameObject;
            visualStateLock     = transform.GetChild(2).gameObject;

            itemCount = 0;
            while (gameObject.name != ("Item" + itemCount))
            {
                if (itemCount++ > 31)
                {
                    break;
                }
            }

            if (flagOnceInitFirstItem)
            {
                flagOnceInitFirstItem = false;
                if (!SPlayerPrefs.HasKey(STATEITEM + "0"))
                {
                    SPlayerPrefs.SetString(STATEITEM + "0", "Selected");
                    SPlayerPrefs.Save();
                }
            }

            if (!SPlayerPrefs.HasKey(STATEITEM + itemCount))
            {
                SPlayerPrefs.SetString(STATEITEM + itemCount, "Buy");
            }
            if (itemCount == 10)
            {
                gameObject.GetComponent <Image>().color = Color.yellow;
            }
        }
    }
Esempio n. 8
0
 private void HandleShowResult(ShowResult result)
 {
     if (result == ShowResult.Finished)
     {
         Debug.Log("Video completed - Offer a reward to the player");
         vendorText.GetComponent <Text>().text = vendorSuccessText;
         SPlayerPrefs.SetInt("Money", SPlayerPrefs.GetInt("Money") + Random.Range(10, 90));
         SPlayerPrefs.Save();
     }
     else if (result == ShowResult.Skipped)
     {
         Debug.LogWarning("Video was skipped - Do NOT reward the player");
         vendorText.GetComponent <Text>().text = vendorErrorText;
     }
     else if (result == ShowResult.Failed)
     {
         Debug.LogError("Video failed to show");
         vendorText.GetComponent <Text>().text = vendorErrorText;
     }
 }
Esempio n. 9
0
 private void EditCount(int value)
 {
     SPlayerPrefs.SetInt("Count", value);
     SPlayerPrefs.Save();
 }