public static Being GetNearestEnemy(this Being being) { var enemies = being.Enemies().Where(e => e.IsAlive).ToList(); if (!enemies.Any()) { return(null); } var distance = enemies.Select(z => z.DistanceBetween(being)).Min(); return(enemies.First(z => Math.Abs(z.DistanceBetween(being) - distance) < CodingConstants.Tolerance)); }
protected override bool Execute() { var damage = new DamageInstance(null, AbilityConstants.FrostPoundDamage, DamageTypes.Frost, Being, AbilityTypes.FrostPound); foreach (var enemy in Being.Enemies().Where(e => e.Position.DistanceBetween(Being.Position) < AbilityConstants.FrostPoundRange)) { damage.DamageBeing(enemy); enemy.Buffs.Add(new FrozenBuff(enemy, AbilityConstants.FrostPoundFrozenLength)); } // replenish mana based on bonuses Being.Mana += AbilityConstants.FrostPoundManaCost * (Being.SkillValue(SkillType.FrozenSoul, false) / 100f); return(base.Execute()); }
public bool Attacked() { var rect = Helpers.CreateRect(Being.X + Being.Facing.X * ((Enemy)Being).AttackRange * 0.8f - 10, Being.Y - Being.Facing.Y * ((Enemy)Being).AttackRange * 0.8f - 10, 20, 20); var rect2 = Helpers.CreateRect(Being.X + Being.Facing.X * ((Enemy)Being).AttackRange * 0.2f - 14, Being.Y - Being.Facing.Y * ((Enemy)Being).AttackRange * 0.2f - 14, 28, 28); var hitboxes = GetHitboxes == null ? new List <Rectangle> { rect, rect2 } : GetHitboxes(Being); foreach (var zerd in Being.Enemies()) { if (!zerd.Hitbox().Any(hitbox => hitboxes.Any(hitbox.Intersects))) { continue; } var damageInstance = GetDamage(); damageInstance.DamageBeing(zerd); return(true); } return(false); }