Ejemplo n.º 1
0
  } // End of FireManage

  // On collision.
  private void OnTriggerEnter2D(Collider2D collision)
  {
    // Get projectile.
    ProjectileController projectile=collision.gameObject.GetComponent<ProjectileController>();
    // If collision with projectile.
    if(projectile!=null)
    {
      // Decrease health.
      HealthDown(projectile.DamageGet());
      // Destroy projectile.
      projectile.ProjectileDestroy();
    }
  } // End of OnTriggerEnter2D
Ejemplo n.º 2
0
  } // End of ProjectileLaunch

  // On collision.
  private void OnTriggerEnter2D(Collider2D collision)
  {
    // Get projectile.
    ProjectileController projectile = collision.gameObject.GetComponent<ProjectileController>();
    // If collision with projectile.
    if(projectile!=null)
    {
      // Destroy projectile.
      projectile.ProjectileDestroy();
      // Actualize health.
      this.health-=projectile.DamageGet();
      // If health below 1.
      if(this.health<1)
      {
        // Destroy enemy.
        EnemyDestroy();
      }     
    }
  } // End of OnTriggerEnter2D