Beispiel #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        RedLaser    redLaser    = collider.gameObject.GetComponent <RedLaser> ();
        CoinScript  coin        = collider.gameObject.GetComponent <CoinScript> ();
        CoinsKeeper coinsKeeper = GameObject.Find("zCoins").GetComponent <CoinsKeeper>();

        if (redLaser)
        {
            health -= redLaser.RedDamage();
            redLaser.Hit();
            if (animator.enabled == false)
            {
                animator.enabled = true;
            }
            animator.Play("PlayerHitAnim");
            if (health <= 0)
            {
                Instantiate(playerExplosion, transform.position, Quaternion.identity);
                Destroy(motorLight);
                Destroy(gameObject);
                gameController.GameOver();
            }
        }
        else if (coin)
        {
            zCoins += coin.CoinValue();
            coinsKeeper.CoinsKeeperText(zCoins);
        }
        else
        {
            Instantiate(playerExplosion, transform.position, Quaternion.identity);
            Destroy(motorLight);
            Destroy(gameObject);
            gameController.GameOver();
        }
    }