Ejemplo n.º 1
0
 private void ProcessHit(DemageDealer demageDealer)
 {
     health -= demageDealer.getDemage();
     demageDealer.Hit();
     if (health <= 0)
     {
         Destroy(gameObject);
         AudioSource.PlayClipAtPoint(DeathSound, transform.position);
     }
 }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DemageDealer demageDealer = other.GetComponent <DemageDealer>();

        if (!demageDealer)
        {
            return;
        }
        HandleHit(demageDealer);
    }
Ejemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DemageDealer demageDealer = collision.GetComponent <DemageDealer>();

        if (!demageDealer)
        {
            return;
        }
        ProcessHit(demageDealer);
    }
Ejemplo n.º 4
0
 private void HandleHit(DemageDealer demageDealer)
 {
     health -= demageDealer.getDemage();
     demageDealer.Hit();
     if (health <= 0)
     {
         GameObject explosion = Instantiate(explosionVFX, transform.position, transform.rotation);
         Destroy(explosion, durationOfExplosion);
         Destroy(gameObject);
         AudioSource.PlayClipAtPoint(explosionSound, transform.position);
     }
 }