Exemple #1
0
        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;
        }
Exemple #2
0
 public Interaction(UnitInfo sourceUnitInfo, UnitInfo targetUnitInfo, InteractionType type)
 {
     this.SourceUnit = sourceUnitInfo;
     this.TargetUnit = targetUnitInfo;
     this.InteractionType = type;
 }
Exemple #3
0
 protected virtual bool CanAttackUnit(UnitInfo unit)
 {
     bool attackUnit = false;
     if (this.Id != unit.Id)
     {
         if (this.Aggression >= unit.Power)
         {
             attackUnit = true;
         }
     }
     return attackUnit;
 }