Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (shotCoins == true)
        {
            if (other.gameObject.tag == "CannonBallPlayer")
            {
                AudioSource.PlayClipAtPoint(sound, transform.position);
                gameManager.InitScore(coinValue);
                Instantiate(pickupParticle, this.transform.position, Quaternion.Euler(-90, 0, 0));
                Destroy(this.gameObject);
            }
        }

        if (other.gameObject.name == "Player")
        {
            AudioSource.PlayClipAtPoint(sound, transform.position);
            gameManager.InitScore(coinValue);
            manager.checkForBoost();
            Instantiate(pickupParticle, this.transform.position, Quaternion.Euler(-90, 0, 0));
            //manager.coinPicked = true;
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "CannonBallPlayer")
        {
            hp--;
            if (hp == 0)
            {
                int randomValue = Random.Range(1, 9);

                if (randomValue == 1)
                {
                    Instantiate <GameObject>(movmentPowerUp, this.transform.position, Quaternion.identity);
                }
                if (randomValue == 2)
                {
                    Instantiate <GameObject>(cannonUpgrade, this.transform.position, Quaternion.identity);
                }
                if (randomValue == 3)
                {
                    Instantiate <GameObject>(biggerCoin, this.transform.position, Quaternion.identity);
                }
                if (randomValue == 4)
                {
                    Instantiate <GameObject>(shotCoin, this.transform.position, Quaternion.identity);
                }

                gM.InitScore(300);
                Instantiate(scoreParticle, this.transform.position, Quaternion.Euler(-90, 0, 0));
                for (int indez = 0; indez < cannons.Length; indez++)
                {
                    Destroy(cannons[indez].gameObject);
                }
                deathAnimation.enabled = true;
            }
        }
    }