Exemple #1
0
        /*public void HealDamage()
         * {
         *      healthSlider.value = currentHealth;
         * }*/


        public void Death()
        {
            // Set the death flag so this function won't be called again.
            isDead = true;

            // Turn off any remaining shooting effects.
            //playerShooting.DisableEffects ();

            // Tell the animator that the player is dead.
            //anim.SetTrigger ("Die");

            // Set the audiosource to play the death clip and play it (this will stop the hurt sound from playing).
            //playerAudio.clip = deathClip;
            //playerAudio.Play ();

            // Turn off the movement and shooting scripts.
            playerController.enabled = false;
            //playerShooting.enabled = false;

            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();

            Destroy(other.gameObject);
            Destroy(gameObject);
        }
Exemple #2
0
        void OnTriggerEnter(Collider other)          //this creates an explosion when the enemy gets hit
        {
            if (other.gameObject.layer == LayerMask.NameToLayer("Projectile") && other.tag != "Enemy")
            {
                // Play the hurt sound effect.
                enemyAudio.Play();

                Instantiate(playerExplosion, transform.position, transform.rotation);

                if (other.tag == "Nu")                 //when getting hit by their own bullet
                {
                    currentHealth -= 1;
                }
                else                                                  //when it's you shooting them
                {
                    currentHealth -= 1 + Done_PlayerController.power; //figures out how much damage is taken
                }

                if (currentHealth <= 0)                 //runs death code if HP hits zero
                {
                    Death();
                }
            }

            if (other.tag == "Player")
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver();
            }
            else
            {
                return;
            }
        }
Exemple #3
0
        void OnTriggerEnter(Collider other)
        {
            if (other.tag == "Boundary" || other.tag == "Enemy")
            {
                return;
            }

            if (explosion != null)
            {
                Instantiate(explosion, transform.position, transform.rotation);
            }

            if (other.tag == "Player")
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                gameController.GameOver();
            }

            gameController.AddScore(scoreValue);
            Destroy(other.gameObject);
            Destroy(gameObject);
        }