void Damage(Targetable enemy) { if (enemy != null) { enemy.TakeDamage(damage, enemy.position, alignmentProvider); } }
public virtual void OnRemove() { // If scene is in progress if (isQuitting == false) { // Find all colliders in specified radius //Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, radius); Collider[] cols = Physics.OverlapSphere(transform.position, radius); foreach (Collider col in cols) { // If target can receive damage Targetable damageTaker = col.gameObject.GetComponent <Targetable>(); if (damageTaker != null) { // Target takes damage equal bullet damage * AOE Damage Rate damageTaker.TakeDamage((int)(Mathf.Ceil(aoeDamageRate * (float)bullet.GetDamage())), col.transform.position, alignmentProvider); } } if (explosion != null) { // Create explosion visual effect Destroy(Instantiate <GameObject>(explosion, transform.position, transform.rotation), explosionDuration); } } }
// Create damage to enemy. protected void DealDamage() { if (target == null) { return; } target.TakeDamage(damager.damage, target.position, damager.alignmentProvider); }
private void OnTriggerEnter(Collider other) { Targetable targetable = other.transform.GetComponent <Targetable>(); if (targetable) { targetable.TakeDamage(damageOnHit); } }
/// <summary> /// Damage targets on trigger enter /// </summary> /// <param name="other">Other.</param> void OnTriggerEnter2D(Collider2D other) { // If target can receive damage Targetable damageTaker = other.GetComponent <Targetable> (); if (damageTaker != null) { damageTaker.TakeDamage(damage, other.transform.position, alignmentProvider); } }
private void OnCollisionEnter(Collision collision) { Targetable targetable = collision.transform.GetComponent <Targetable>(); if (targetable) { targetable.TakeDamage(damage); } // TODO effect Destroy(gameObject); }
public override void Use(Unit Owner, Targetable Target) { DamagePacket MeleeDamagePacked = new DamagePacket(Damage * Owner.DamageMultiplier, DamageType); Target.TakeDamage(MeleeDamagePacked, (bool bKilled) => { if (bKilled) { Debug.Log("Killed enemy"); } }); bReady = false; }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Enemy") { m_Enemy = other.gameObject.GetComponent <Targetable>(); m_Enemy.TakeDamage(m_Damager.damage, m_Enemy.position, m_Damager.alignmentProvider); var pfx = Poolable.TryGetPoolable <ParticleSystem>(collisionParticles.gameObject); pfx.transform.position = other.transform.position; pfx.Play(); } }
public void ApplyEffect(Targetable target) { Dictionary <Modifier, ParameterModiferValue> effectParameters = GetEffectValue(activeEffect, target); foreach (KeyValuePair <Modifier, ParameterModiferValue> parameter in effectParameters) { if (parameter.Key == Modifier.Damage) { target.TakeDamage(parameter.Value.value, target.transform.position, LevelManager.instance.playerAlignment.GetInterface()); } else { ActiveUnit activeUnit = target as ActiveUnit; ParameterModifier param = new ParameterModifier(parameter.Value.value, parameter.Value.modType); activeUnit.parameters.UpdateParameter(parameter.Key, param, this.gameObject); } } }
/// <summary> /// The actual attack of the hitscan attack. /// Early returns from the method if the there is no enemy to attack. /// </summary> protected void DealDamage() { Poolable.TryPool(gameObject); if (m_Enemy == null) { return; } // effects ParticleSystem pfxPrefab = m_Damager.collisionParticles; var attackEffect = Poolable.TryGetPoolable <ParticleSystem>(pfxPrefab.gameObject); attackEffect.transform.position = m_Enemy.position; attackEffect.Play(); m_Enemy.TakeDamage(m_Damager.damage, m_Enemy.position, m_Damager.alignmentProvider); m_PauseTimer = true; }
private void OnTriggerEnter(Collider other) { Targetable TargetHit = other.gameObject.GetComponent <Targetable>(); if (TargetHit != null) { if (TargetHit.Allegiance != Owner.Allegiance) { TargetHit.TakeDamage(DamagePacket, (bool bKilled) => { if (bKilled) { Debug.Log("Projectile killed"); } }); Destroy(gameObject); } } }
/// <summary> /// Make damage specified by delays and amount. /// </summary> /// <returns>The coroutine.</returns> private IEnumerator DamageCoroutine() { foreach (float delay in delaysBeforeDamage) { yield return(new WaitForSeconds(delay)); // Search for targets Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, radius); foreach (Collider2D col in hits) { if (col.CompareTag("Enemy") == true) { Targetable damageTaker = col.GetComponent <Targetable>(); if (damageTaker != null) { damageTaker.TakeDamage(damage, transform.position, alignmentProvider); } } } } Destroy(gameObject); }