public void RecursiveAttack(Enemy attackEnemy, List <Enemy> enemies) { attackEnemy.DealDamage(damage); enemies.Add(attackEnemy); // Perform overlap sphere around current attack enemy Collider[] hits = Physics.OverlapSphere(attackEnemy.transform.position, electicityRange); foreach (var hit in hits) { // Is hit an Enemy and hasn't been hit yet Enemy hitEnemy = hit.GetComponent <Enemy>(); if (hitEnemy && !enemies.Contains(hitEnemy)) { Ray enemyRay = new Ray(); enemyRay.direction = hitEnemy.transform.position - attackEnemy.transform.position; enemyRay.origin = attackEnemy.transform.position; RaycastHit hitObject; if (Physics.Raycast(enemyRay, out hitObject)) { Enemy en = hitObject.collider.GetComponent <Enemy>(); if (en == hitEnemy) { RecursiveAttack(hitEnemy, enemies); } } } } }
public override void Attack(Enemy e) { // Enable the line line.enabled = true; // Deal damage to enemy e.DealDamage(damage); }
void OnTriggerEnter(Collider col) { Enemy e = col.GetComponent <Enemy>(); if (e != null) { e.DealDamage(damage); Destroy(gameObject); } if (col.name == "Ground") { Destroy(this); } }
private void OnTriggerEnter(Collider col) { //Let e = col's Enemy component (get Enemy script) Enemy e = col.GetComponent <Enemy>(); //If e != null if (e != null) { //Call e.DealDamage(damage) e.DealDamage(damage); //Destroy self Destroy(gameObject); } //If col's name == "Wall" if (col.tag == "Wall") { //Destroy the projectile Destroy(gameObject); } }
void OnTriggerEnter(Collider col) { // LET e = col's Enemy component Enemy e = col.GetComponent <Enemy>(); // IF e != null if (e != null) { // CALL e.DealDamage(damage) e.DealDamage(damage); // Destroy gameObject Destroy(gameObject); } // IF col's name == "Ground" if (col.name == "Ground") { // Destroy the projectile Destroy(gameObject); } }
public override void Attack(Enemy e) { line.enabled = true; e.DealDamage(damage); }
public override void Attack(Enemy e) { e.DealDamage(damage); anim.SetBool("IsFiring", true); }
public override void Attack(Enemy e) { e.DealDamage(damage); }
public override void Attack(Enemy e) { line.enabled = true; e.DealDamage(damage); StartCoroutine(DisableLine()); }