// return -1 if x is better target, 1 otherwise public int Compare(CombatScoreItem x, CombatScoreItem y) { var xArmorType = x.Target.CombatObject.Stats.Base.Armor; var yArmorType = y.Target.CombatObject.Stats.Base.Armor; if (x.Score == y.Score && (xArmorType == ArmorType.Building3 || yArmorType == ArmorType.Building3)) { if (xArmorType == ArmorType.Building3 && yArmorType == ArmorType.Building3) { var xDistance = tileLocator.RadiusDistance(attacker.Location(), attacker.Size, x.Target.CombatObject.Location(), x.Target.CombatObject.Size); var yDistance = tileLocator.RadiusDistance(attacker.Location(), attacker.Size, y.Target.CombatObject.Location(), y.Target.CombatObject.Size); return(xDistance.CompareTo(yDistance)); } return(xArmorType == ArmorType.Building3 ? 1 : -1); } return(x.Score.CompareTo(y.Score) * -1); }
public override bool InRange(ICombatObject obj) { if (obj.ClassType == BattleClass.Unit) { return(tileLocator.IsOverlapping(obj.Location(), obj.Size, obj.AttackRadius(), Structure.PrimaryPosition, Structure.Size, Structure.Stats.Base.Radius)); } throw new Exception(string.Format("Why is a structure trying to kill a unit of type {0}?", obj.GetType().FullName)); }
public override bool InRange(ICombatObject obj) { switch (obj.ClassType) { case BattleClass.Unit: return(true); case BattleClass.Structure: return(tileLocator.IsOverlapping(Location(), Size, AttackRadius(), obj.Location(), obj.Size, obj.AttackRadius())); default: throw new Exception(string.Format("Why is an attack combat unit trying to kill a unit of type {0}?", obj.GetType().FullName)); } }