void OnDestroy() { if (target != null) { target.ApplyDamage(damage); } }
public Vector2 HandleBullet(Vector2 EndPoint, RaycastHit2D[] RCH, Collider2D[] IgnoreColliders) { foreach (RaycastHit2D Hit in RCH) { if (Hit.collider != null) { if (IgnoreColliders.Contains(Hit.collider)) { continue; } IDamagable Char = Hit.collider.GetComponent <IDamagable>(); if (Char != null) { bool stop = Char.StopsBullet; Char.ApplyDamage(WeaponConfiguration.Damage); if (stop) { return(Hit.point); } } } } return(EndPoint); }
/// <summary> /// Checks for an IDamagable on the target GameObject, then attempts to call its ApplyDamage method. /// If an IDamagable isn't found, returns false. /// </summary> /// <param name="damageTarget"> The Target to look for an IDamagable on.</param> /// <param name="e"> Damage Event Arguments.</param> /// <returns></returns> public virtual bool TryDealDamage(GameObject damageTarget, Damage.DamageEventArgs e) { if (!CanDealDamage) { return(false); } if (e.DamageValue <= 0) { return(false); } IDamagable damagable = damageTarget.GetComponent <IDamagable>(); if (damagable != null) { if (this.faction == damagable.GetFaction()) { return(false); } damagable.ApplyDamage(this, e); OnDealDamage(this, e); return(true); } // No IDamagable Found - Return false. return(false); }
private void OnTriggerEnter2D(Collider2D other) { IDamagable component = (IDamagable)other.GetComponent(typeof(IDamagable)); if (component != null && !other.CompareTag(TagContainer.Player_Tag)) { component.ApplyDamage(10); } }
private void OnCollisionEnter2D(Collision2D other) { IDamagable component = other.gameObject.GetComponent <IDamagable>(); if (component != null) { Destroy(other.gameObject); component.ApplyDamage(); } }
private void ApplyDamage(IDamagable damagable) { if (damagable is Shield) { (damagable as Shield).ApplyDamage(_damage, _blastRadius); } else { damagable.ApplyDamage(_damage); } }
private void OnTriggerEnter2D(Collider2D other) { IDamagable component = (IDamagable)other.GetComponent(typeof(IDamagable)); if (component != null && !other.CompareTag(TagContainer.Player_Tag)) { component.ApplyDamage(1); Destroy(gameObject); } else if (other.CompareTag(TagContainer.Top_Border)) { Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { IDamagable component = other.GetComponent <IDamagable>(); if (component != null) { Destroy(other.gameObject); component.ApplyDamage(); } if (other.CompareTag(TagContainer.BOMB_TAG)) { Bomb tmp = other.gameObject.GetComponent <Bomb>(); tmp.ApplyDamage(); } if (other.CompareTag(TagContainer.PORTAL_TAG)) { CustomEventSystem.PortalExplosionAction(transform.position); } }
void Update() { damageThis.ApplyDamage(damagePerSecond * Time.deltaTime); }
public static void ApplyDamage(IDamager damager, IDamagable damagable) { damagable.ApplyDamage(damager.GetDamage(), new Vector2(0, 0)); }
public static void ApplyDamage(IDamager damager, IDamagable damagable, Vector2 velocity) { damagable.ApplyDamage(damager.GetDamage(), velocity); }