public void OnHit(GameObject attacker) { if (attacker.TryGetComponent <Damage>(out Damage damage)) { _lifeSystems.TakeDamage(damage.kineticDamage, damage.energyDamage); } }
public override void Reason() { //Check distance to the capital ship if (Vector3.Distance(controller.transform.position, controller.CapitalShip.transform.position) < controller.WaypointDistance) { if (!reachedShip) { //Do reaching capitol ship things reachedShip = true; Debug.Log("reached the ship"); DrdRandomShooty.manager.Heal(); foreach (Collider c in thisGO.GetComponentsInChildren <Collider>()) { c.enabled = false; } } waitToDestroy += Time.deltaTime; if (waitToDestroy > 10.0f) { health.TakeDamage(Mathf.Infinity, Mathf.Infinity); } } //If dead transition to dead if (controller.Health.IsDead) { controller.PerformTransition(Transition.NoHealth); } }
/// <summary> /// Kills all enemeis in the area /// </summary> public void KillEnemies() { foreach (Transform enemy in currentArea.enemies) { HealthAndShields healthAndShields = enemy.GetComponentInChildren <HealthAndShields>(); if (healthAndShields) { healthAndShields.TakeDamage(Mathf.Infinity, Mathf.Infinity); } } }