Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        //when a coin is collected add points to the players score
        //send a message to the console
        //destroy the coin
        //and play the coin sound
        // this is applied to all 3 types of coins

        if (coll.gameObject.tag == "Bronze Coin")
        {
            pStats.addPoints(10);
            Debug.Log("Picked up bronze coin");
            Destroy(coll.gameObject);
            audio.PlayOneShot(coinSound);
        }

        if (coll.gameObject.tag == "Gold Coin")
        {
            pStats.addPoints(100);
            Debug.Log("Picked up gold coin");
            Destroy(coll.gameObject);
            audio.PlayOneShot(coinSound);
        }

        if (coll.gameObject.tag == "Silver Coin")
        {
            pStats.addPoints(20);
            Debug.Log("Picked up silver coin");
            Destroy(coll.gameObject);
            audio.PlayOneShot(coinSound);
        }

        //if hit by an enemy bullet take 10 damage
        if (coll.gameObject.tag == "Dangerous")
        {
            audio.PlayOneShot(bulletSound);
            pStats.takeDamage(10f);
            Destroy(coll.gameObject);
        }
    }