Exemple #1
0
        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));
        }
Exemple #2
0
 public void TestIsOverlappingAllPointsWithCache(uint x1,
                                                 uint y1,
                                                 byte r1,
                                                 uint x2,
                                                 uint y2,
                                                 byte r2,
                                                 bool overlapping,
                                                 byte distance)
 {
     cacheForTestIsOverlappingWithCache.IsOverlapping(new Position(x1, y1), 1, r1, new Position(x2, y2), 1, r2)
     .Should()
     .Be(overlapping);
 }
Exemple #3
0
        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));
            }
        }
Exemple #4
0
 private IEnumerable <IStructure> GetStructuresInRadius(IEnumerable <IStructure> structures, ITroopObject troopObject)
 {
     return(structures.Where(structure => tileLocator.IsOverlapping(troopObject.PrimaryPosition, troopObject.Size, troopObject.Stats.AttackRadius,
                                                                    structure.PrimaryPosition, structure.Size, structure.Stats.Base.Radius)));
 }