Ejemplo n.º 1
0
    public void UnlockChosen(GameObject skin)
    {
        Image texture = skin.GetComponent <Image>();

        if (skin.transform.GetChild(0).GetComponent <Text>().text != "UNLOCKED")
        {
            string valueStr = skin.transform.GetChild(0).GetComponent <Text>().text;
            valueStr = valueStr.Substring(0, valueStr.Length - 6);
            int value = System.Convert.ToInt32(valueStr);
            if (coin.getCoins() < value)
            {
                print("Insufficient coin amount");
                return;
            }
            string unlockedPlanets = PlayerPrefs.GetString("unlocked_planets");
            unlockedPlanets = unlockedPlanets + "," + texture.mainTexture.name;
            PlayerPrefs.SetString("unlocked_planets", unlockedPlanets);
            coin.changeCoins(-value);
            coin_value.text = "" + coin.getCoins();
            skin.transform.GetChild(0).GetComponent <Text>().text = "UNLOCKED";
        }
        ;
        PlayerPrefs.SetString("planet_texture", texture.mainTexture.name);
        notifySelect(PlayerPrefs.GetString("planet_texture"));
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     coin = gameObject.AddComponent <coins>();
     //coin.changeCoins(9999);
     //PlayerPrefs.SetString("unlocked_planets","");
     coin_value.text = "" + coin.getCoins();
     showUnlockedSkins();
     notifySelect(PlayerPrefs.GetString("planet_texture"));
 }