void OnTriggerExit(Collider other) { GameObject target; Retarget retarget = other.GetComponent <Retarget>(); if (retarget != null) { target = retarget.target; } else { target = other.gameObject; } this.targeting.Remove(target); }
void OnTriggerEnter(Collider other) { GameObject target; Retarget retarget = other.GetComponent <Retarget>(); if (retarget != null) { target = retarget.target; } else { target = other.gameObject; } targeting.Add(target); GameObject toAttack = targeting.findClosestUnit(this.transform.position); baseScript.TargetEnemy(toAttack); }
private void HitTarget() { if (!this.isActiveAndEnabled) { return; } if (Target != null) { Retarget retarget = Target.GetComponent <Retarget>(); GameObject actualTarget = (retarget == null) ? Target : retarget.damageable; IDamageable targetScript = actualTarget.GetComponent <IDamageable>(); if (targetScript == null) { targetScript = actualTarget.GetComponentInParent <IDamageable>(); } targetScript.receiveDamage(this.Damage); } Destroy(this.gameObject); }