예제 #1
0
 void OnTriggerStay(Collider other)
 {
     if (!gameController.won)
     {
         PlayerController playerController = other.GetComponent <PlayerController>();
         ShieldHealth     shieldHealth     = other.GetComponent <ShieldHealth>();
         if (other.CompareTag("Player") && playerController)
         {
             playerController.onHit(9223372036854775807, true);
         }
         else if (other.CompareTag("Shield") && shieldHealth)
         {
             shieldHealth.takeDamage(9223372036854775807);
         }
     }
 }
예제 #2
0
 void OnTriggerStay(Collider other)
 {
     if (!gameController.won)
     {
         PlayerController playerController = other.GetComponent <PlayerController>();
         ShieldHealth     shieldHealth     = other.GetComponent <ShieldHealth>();
         if (other.CompareTag("Player") && playerController)
         {
             if (!playerController.invulnerable)
             {
                 playerController.onHit(damage, false);
                 if (explosion)
                 {
                     GameObject newExplosion = Instantiate(explosion, transform.position, transform.rotation);
                     if (newExplosion.GetComponent <AudioSource>())
                     {
                         newExplosion.GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("SoundVolume");
                     }
                 }
                 Destroy(gameObject);
             }
         }
         else if (other.CompareTag("Shield") && shieldHealth)
         {
             if (explosion)
             {
                 GameObject newExplosion = Instantiate(explosion, transform.position, transform.rotation);
                 if (newExplosion.GetComponent <AudioSource>())
                 {
                     newExplosion.GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("SoundVolume");
                 }
             }
             shieldHealth.takeDamage(damage);
             Destroy(gameObject);
         }
     }
 }
예제 #3
0
 void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("Enemy"))
     {
         EnemyHealth enemyHealth = other.GetComponent <EnemyHealth>();
         if (enemyHealth)
         {
             enemyHealth.takeDamage(damage);
             if (explosion)
             {
                 GameObject newExplosion = Instantiate(explosion, transform.position, transform.rotation);
                 if (newExplosion.GetComponent <AudioSource>())
                 {
                     newExplosion.GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("SoundVolume");
                 }
             }
             Destroy(gameObject);
         }
     }
     else if (other.CompareTag("Shield"))
     {
         ShieldHealth shieldHealth = other.GetComponent <ShieldHealth>();
         if (shieldHealth)
         {
             shieldHealth.takeDamage(damage);
             if (explosion)
             {
                 GameObject newExplosion = Instantiate(explosion, transform.position, transform.rotation);
                 if (newExplosion.GetComponent <AudioSource>())
                 {
                     newExplosion.GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("SoundVolume");
                 }
             }
             Destroy(gameObject);
         }
     }
 }