private void Damage(Collision collision) { HealthSystem healthSystem = collision.gameObject.GetComponent <HealthSystem>(); if (healthSystem) { healthSystem.TakeDamage(damageCaused); } Destroy(gameObject, DESTROY_DELAY); }
private void DealAoeDamage() { Collider[] hits = Physics.OverlapSphere(gameObject.transform.position, (config as WhirlwindConfig).GetRadius()); foreach (Collider hit in hits) { HealthSystem enemyHealth = hit.gameObject.GetComponent <HealthSystem>(); if (enemyHealth) { enemyHealth.TakeDamage((config as WhirlwindConfig).GetDamage()); } } }
public override void Use(GameObject target = null) { HealthSystem health = target.GetComponent <HealthSystem>(); if (health) { health.TakeDamage((config as PowerAttackConfig).GetExtraDamage()); } PlayParticleEffect(); PlayAbilitySound(); PlayAnimation(); }
private void DealRadialDamage(GameObject target) { float damageToDeal = (config as AreaEffectConfig).GetDamageToEachTarget(); RaycastHit[] targetsHit = Physics.SphereCastAll( transform.position, (config as AreaEffectConfig).GetEffectRadius(), Vector3.up, (config as AreaEffectConfig).GetEffectRadius() ); foreach (var targetHit in targetsHit) { HealthSystem hitDamageable = targetHit.collider.gameObject.GetComponent <HealthSystem>(); bool hitPlayer = targetHit.collider.gameObject.GetComponent <PlayerControl>(); if (!hitPlayer && hitDamageable != null) { hitDamageable.TakeDamage(damageToDeal); } } }
void OnCollisionEnter(Collision collision) { GameObject target = collision.gameObject; HealthSystem healthSystem = target.GetComponent <HealthSystem>(); SlowMotion slowMotion = Camera.main.GetComponent <SlowMotion>(); if (healthSystem) { healthSystem.TakeDamage(damageToDeal); slowMotion.SlowTime(); ParticleUtility.PlayParticleEffect( target.transform, particleEffectPrefab, target.transform.position, ParticleUtility.PARTICLE_STD_Y_OFFSET ); } Destroy(gameObject); }
private void DealRadialDamage() { float radius = (config as AreaAttackConfig).GetRadius(); RaycastHit[] raycastHits = Physics.SphereCastAll( transform.position, radius, Vector3.up, radius ); foreach (RaycastHit hit in raycastHits) { if (hit.collider.gameObject != gameObject) { HealthSystem damagable = hit.collider.gameObject.GetComponent <HealthSystem>(); if (damagable != null) { float damageToDeal = (config as AreaAttackConfig).GetDamageToEachTarget(); damagable.TakeDamage(damageToDeal); } } } }
IEnumerator DamageAfterDelay(float damageDelay) { yield return(new WaitForSeconds(damageDelay)); currentTarget.TakeDamage(CalculateHitProbability(characterStats.GetDamage(), currentTarget)); }