예제 #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"));
    }
예제 #2
0
    public void DestroyAsteroid()
    {
        if (anim.enabled == false)
        {
            anim.enabled = true;
        }
        Text inc;

        inc = Instantiate(coin_increment) as Text;
        if (isMoving)
        { //stops audio playing multiple times if clicking continues once destroyed
            AudioManager.instance.PlaySound(asteroidExplosion, transform.position);
        }
        transform.Rotate(0, 0, 0, Space.Self);
        anim.SetTrigger("Active");
        isMoving = false;
        Destroy(this.gameObject, 1.0f);
        coin.changeCoins(1);
        inc.GetComponent <visual_increment>().showIncrement(this.gameObject.transform.position);
    }