protected virtual UnitInfo GetOptimalAttackableUnit(IEnumerable<UnitInfo> attackableUnits) { //This method finds the unit with the least power and attacks it UnitInfo optimalAttackableUnit = new UnitInfo(null, UnitClassification.Unknown, 0, int.MaxValue, 0); foreach (var unit in attackableUnits) { if (unit.Power < optimalAttackableUnit.Power) { optimalAttackableUnit = unit; } } return optimalAttackableUnit; }
public Interaction(UnitInfo sourceUnitInfo, UnitInfo targetUnitInfo, InteractionType type) { this.SourceUnit = sourceUnitInfo; this.TargetUnit = targetUnitInfo; this.InteractionType = type; }
protected virtual bool CanAttackUnit(UnitInfo unit) { bool attackUnit = false; if (this.Id != unit.Id) { if (this.Aggression >= unit.Power) { attackUnit = true; } } return attackUnit; }