Inheritance: MonoBehaviour
Beispiel #1
0
    void Start()
    {
        isEnoughMoney   = true;
        messageInterval = 1.5f;

        destroyPowerup = PlayerPrefs.GetInt("destroyPowerup");
        heartPowerup   = PlayerPrefs.GetInt("heartPowerup");
        timerPowerup   = PlayerPrefs.GetInt("timerPowerup");
        coin           = PlayerPrefs.GetInt("Coins");

        if (destroyPowerup == null)
        {
            destroyPowerup = 0;
            PlayerPrefs.SetInt("destroyPowerup", destroyPowerup);
        }

        if (heartPowerup == null)
        {
            heartPowerup = 0;
            PlayerPrefs.SetInt("heartPowerup", heartPowerup);
        }

        if (timerPowerup == null)
        {
            timerPowerup = 0;
            PlayerPrefs.SetInt("timerPowerup", timerPowerup);
        }

        GameObject coinSystem = GameObject.FindGameObjectWithTag("MainCamera");

        c    = (CoinSystemScript)coinSystem.GetComponent("CoinSystemScript");
        coin = c.GetCoin();
    }
Beispiel #2
0
	void Start(){
		isEnoughMoney = true;
		messageInterval = 1.5f;

		destroyPowerup = PlayerPrefs.GetInt("destroyPowerup");
		heartPowerup = PlayerPrefs.GetInt("heartPowerup");
		timerPowerup = PlayerPrefs.GetInt("timerPowerup");
		coin = PlayerPrefs.GetInt("Coins");

		if (destroyPowerup == null) {
			destroyPowerup = 0;
			PlayerPrefs.SetInt("destroyPowerup", destroyPowerup);
		}

		if (heartPowerup == null) {
			heartPowerup = 0;
			PlayerPrefs.SetInt("heartPowerup", heartPowerup);
		}

		if (timerPowerup == null) {
			timerPowerup = 0;
			PlayerPrefs.SetInt("timerPowerup", timerPowerup);
		}

		GameObject coinSystem = GameObject.FindGameObjectWithTag("MainCamera");
		c = (CoinSystemScript)coinSystem.GetComponent("CoinSystemScript");
		coin = c.GetCoin ();
	}
Beispiel #3
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            audio.PlayOneShot(coinSound, 3.0f);
            Destroy(GetComponent("CircleCollider2D"));
            isPickedUp = true;
            GameObject    scoreSystem = GameObject.FindGameObjectWithTag("MainCamera");
            ScoringSystem s           = (ScoringSystem)scoreSystem.GetComponent("ScoringSystem");
            s.IncreaseScore(scoreReward);

            GameObject       coinSystem = GameObject.FindGameObjectWithTag("MainCamera");
            CoinSystemScript c          = (CoinSystemScript)coinSystem.GetComponent("CoinSystemScript");
            c.AddCoin(coinWorth);
        }
    }