Beispiel #1
0
    //-- once the bullet collider has been hit
    void OnTriggerEnter2D(Collider2D other)
    {
        //-- if the object hit is an enemy destorys the enemy and moves the bullet off screen
        if (other.gameObject.tag == "Enemy")
        {
            // RRR
            enemyManager.KilledEnemy();

            collider2D.enabled = false;
            StartCoroutine("BulletHitEnemy", other.transform);
            StartCoroutine("MoveBulletToHome");
        }

        //-- if the object hit is the boundary then moves the bullet off screen
        else if (other.gameObject.tag == "Boundary")
        {
            if (PlayerStats.isAlive)
            {
                AudioSource.PlayClipAtPoint(playerHitAudio, Vector3.zero);
                playerControls.ShakeCam();

                if (PlayerStats.LoseHealth() <= 0)
                {
                    sceneFader.StartCoroutine("FadeToGameMenu");
                }
                else
                {
                    sceneFader.DoFadeDamage();
                }
            }

            // RRR
            collider2D.enabled = false;
            StartCoroutine("MoveBulletToHome");
        }

        //-- if the object hit is a healthy cell, destroy the healthy cell and send this bullet home
        if (other.gameObject.tag == "Healthy")
        {
            collider2D.enabled       = false;
            other.collider2D.enabled = false;
            StartCoroutine("BulletHitHealthyCell", other.transform);
            StartCoroutine("MoveBulletToHome");
        }
    }
Beispiel #2
0
    //-- once the enemy collider has been hit
    void OnTriggerEnter2D(Collider2D other)
    {
        //-- if the object hit is the Player puts the enemy back to off screen
        if (other.gameObject.tag == "Player")
        {
            this.gameObject.transform.position = EnemyManager.enemyHome;
            speed = 0;

            if (PlayerStats.isAlive)
            {
                AudioSource.PlayClipAtPoint(playerHitAudio, Vector3.zero);
                playerControls.ShakeCam();

                if (PlayerStats.LoseHealth() <= 0)
                {
                    sceneFader.StartCoroutine("FadeToGameMenu");
                }
                else
                {
                    sceneFader.DoFadeDamage();
                }
            }
        }
    }