Пример #1
0
        public override Interaction DecideInteraction(IEnumerable <UnitInfo> units)
        {
            var candidateUnits = units
                                 .Where((unit) => unit.Id
                                        != this.Id &&
                                        this.UnitClassification
                                        == InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification));

            UnitInfo optimalAttackableUnit = GetOptimalAttackableUnit(candidateUnits);

            foreach (var unit in candidateUnits)
            {
                if (unit.Health < optimalAttackableUnit.Health)
                {
                    optimalAttackableUnit = unit;
                }
            }

            if (optimalAttackableUnit.Id != null)
            {
                return(new Interaction(new UnitInfo(this), optimalAttackableUnit, InteractionType.Infest));
            }

            return(Interaction.PassiveInteraction);
        }
        protected override void ProcessSingleInteraction(Interaction interaction)
        {
            try
            {
                switch (interaction.InteractionType)
                {
                case InteractionType.Attack:
                    Unit targetUnit = this.GetUnit(interaction.TargetUnit);
                    targetUnit.DecreaseBaseHealth(interaction.SourceUnit.Power);
                    break;

                case InteractionType.Infest:
                    Unit targetUnit1 = this.GetUnit(interaction.TargetUnit);
                    if (InfestationRequirements.RequiredClassificationToInfest(targetUnit1.UnitClassification) == interaction.SourceUnit.UnitClassification)
                    {
                        targetUnit1.AddSupplement(new InfestationSpores());
                    }
                    break;

                default:
                    break;
                }
            }
            catch
            {
            }
        }
Пример #3
0
        protected override bool CanAttackUnit(UnitInfo unit)
        {
            bool canInfest = this.Id != unit.Id &&
                             this.UnitClassification ==
                             InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification);

            return(canInfest);
        }
Пример #4
0
 protected override bool CanAttackUnit(UnitInfo unit)
 {
     if (this.Id != unit.Id && InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification).Equals(this.UnitClassification))
     {
         return(true);
     }
     return(false);
 }
Пример #5
0
        protected override bool CanAttackUnit(UnitInfo unit)
        {
            bool attackUnit = false;

            if (this.Id != unit.Id && this.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification))
            {
                attackUnit = true;
            }

            return(attackUnit);
        }
Пример #6
0
        /// <summary>
        /// Return only units which meet the requirements in InfestationRequirements class.
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        protected bool CanInfestUnit(UnitInfo unit)
        {
            bool infestUnit = false;

            if (this.Id != unit.Id)
            {
                if (this.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification))
                {
                    infestUnit = true;
                }
            }
            return(infestUnit);
        }
Пример #7
0
        protected override bool CanAttackUnit(UnitInfo unit)
        {
            bool attackUnit = false;

            if (this.Id != unit.Id)
            {
                if (InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification) == UnitClassification.Biological)
                {
                    attackUnit = true;
                }
            }
            return(attackUnit);
        }
Пример #8
0
 protected override bool CanAttackUnit(UnitInfo unit)
 {
     //	The target Unit can be any unit different than itself
     if (unit.Id != this.Id &&
         (InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification) == this.UnitClassification))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #9
0
        protected override bool CanAttackUnit(UnitInfo unit)
        {
            if (this.Id != unit.Id)
            {
                var unitClassificationRequired = InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification);
                if (this.UnitClassification == unitClassificationRequired)
                {
                    return(true);
                }
            }

            return(base.CanAttackUnit(unit));
        }
Пример #10
0
        public override Interaction DecideInteraction(IEnumerable <UnitInfo> units)
        {
            var theUnitToInfest = units.OrderByDescending(unit => unit.Health).FirstOrDefault(target => !target.Equals(this));

            if (theUnitToInfest.Id != null)
            {
                if (this.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(theUnitToInfest.UnitClassification))
                {
                    return(new Interaction(new UnitInfo(this), theUnitToInfest, InteractionType.Infest));
                }
            }

            return(Interaction.PassiveInteraction);
        }
Пример #11
0
        protected override bool CanAttackUnit(UnitInfo unit)
        {
            bool attackUnit = false;

            if (this.Id != unit.Id)
            {
                UnitClassification thisUnitRequirement = InfestationRequirements.RequiredClassificationToInfest(unit.UnitClassification);

                if (this.UnitClassifications.Equals(typeof(thisUnitRequirement)))
                {
                    attackUnit = true;
                }
            }
            return(attackUnit);
        }
Пример #12
0
        protected override void ProcessSingleInteraction(Interaction interaction)
        {
            switch (interaction.InteractionType)
            {
            case InteractionType.Infest:
                Unit targetUnit = this.GetUnit(interaction.TargetUnit);
                Unit sourceUnit = this.GetUnit(interaction.SourceUnit);
                if (sourceUnit.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(targetUnit.UnitClassification))
                {
                    var infestationSpore = new InfestationSpores();
                    targetUnit.AddSupplement(infestationSpore);
                }

                break;

            default:
                base.ProcessSingleInteraction(interaction);
                break;
            }
        }
Пример #13
0
        public override Interaction DecideInteraction(IEnumerable <UnitInfo> units)
        {
            IEnumerable <UnitInfo> attackableUnits = units.Where((unit) => this.CanAttackUnit(unit)).
                                                     Where(u => u.UnitClassification == InfestationRequirements.RequiredClassificationToInfest(this.UnitClassification));

            UnitInfo optimalAttackableUnit = GetOptimalAttackableUnit(attackableUnits);

            if (optimalAttackableUnit.Id != null)

            {
                return(new Interaction(new UnitInfo(this), optimalAttackableUnit, InteractionType.Attack));
            }

            return(Interaction.PassiveInteraction);
        }