public void WallGenerator_TripleSides_AreCorrect()
        {
            _layer = new FacilityLayer(5, 5);
            PutFloor(0, 0);
            PutFloor(0, 1);
            PutFloor(1, 0);
            PutFloor(0, 3);
            PutFloor(0, 4);
            PutFloor(1, 4);
            PutFloor(2, 2);
            PutFloor(3, 0);
            PutFloor(4, 0);
            PutFloor(4, 1);
            PutFloor(3, 4);
            PutFloor(4, 3);
            PutFloor(4, 4);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(12);
            AssertWallEquals("138", 2, 1);
            AssertWallEquals("167", 1, 2);
            AssertWallEquals("279", 2, 3);
            AssertWallEquals("349", 3, 2);
        }
 public void Init()
 {
     _world       = new InMemoryWorld();
     _map         = new FacilityMap(_world);
     _sampleLayer = new FacilityLayer();
     _sampleSpace = new FacilitySpace();
 }
        public void WallGenerator_DoubleWallSidesAndCorners_AreCorrect()
        {
            _layer = new FacilityLayer(5, 5);
            PutFloorRow(0);
            PutFloor(0, 1);
            PutFloor(4, 1);
            PutFloor(0, 2);
            PutFloor(2, 2);
            PutFloor(4, 2);
            PutFloor(0, 3);
            PutFloor(4, 3);
            PutFloorRow(4);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(8);
            AssertWallEquals("123479", 1, 1);
            AssertWallEquals("1238", 2, 1);
            AssertWallEquals("123679", 3, 1);
            AssertWallEquals("3469", 3, 2);
            AssertWallEquals("136789", 3, 3);
            AssertWallEquals("2789", 2, 3);
            AssertWallEquals("134789", 1, 3);
            AssertWallEquals("1467", 1, 2);
        }
 public void Init()
 {
     ObjectLayer = ObjectLayer.GroundPlaceable;
     _map        = new FacilityMap(new InMemoryWorld());
     _layer      = new FacilityLayer(2, 2);
     _map.Add(_layer);
 }
 private List <XY> GetWallLocations(FacilityLayer layer)
 {
     return(layer.Where(IsFloor)
            .SelectMany(y => layer.GetNeighbors(y.Location).Where(x => !IsFloor(x)))
            .Select(z => z.Location)
            .Distinct().ToList());
 }
 private List <int> GetNearbyFloorLocations(FacilityLayer layer, XY location)
 {
     return(layer.GetNeighbors(location)
            .Where(IsFloor)
            .Select(x => GetSpaceNumber(x.Location, location))
            .OrderBy(x => x).ToList());
 }
        public void Init()
        {
            _routeProposal = new PatrolRouteProposal(_map, new XYZ(0, 0, 0), path => { });
            var builder = new LayerBuilder(3, 3);

            builder.PutFloor(new XY(0, 0), new XY(2, 2));
            _map.Add(_layer = builder.Build());
        }
        private FacilityMap CreateEmptyMap()
        {
            var map = new FacilityMap(new InMemoryWorld());

            _layer = new FacilityLayer(3, 3);
            map.Add(_layer);
            return(map);
        }
Esempio n. 9
0
        public void FacilityLayer_RemoveValuable_ValuableRemoved()
        {
            var layer = new FacilityLayer(3, 3);

            layer[0, 0].Put(_sampleLowerValuable);

            layer.Remove(_sampleLowerValuable);

            Assert.AreEqual(new FacilityObject(), layer[0, 0].LowerObject);
        }
        public void FacilityMap_GetThirdLayerSpace_CanGetSpace()
        {
            var thirdFloor = new FacilityLayer();

            thirdFloor.Put(13, 19, _sampleSpace);

            _map.Add(_sampleLayer);
            _map.Add(_sampleLayer);
            _map.Add(thirdFloor);

            Assert.AreEqual(_sampleSpace, _map[13, 19, 2]);
        }
        public void Init()
        {
            _thief = new Thief(this, _map);
            _thief.Subscribe(this);
            var builder = new LayerBuilder(3, 3);

            builder.PutFloor(new XY(0, 0), new XY(2, 2));
            AddPortals(builder);
            _map.Add(_layer = builder.Build());
            _upFacingContainer.Put(_upFacingValuable);
            _rightFacingContainer.Put(_valuable2);
        }
Esempio n. 12
0
        public void FacilityLayer_IterateSmallLayer_IteratesCorrectly()
        {
            var iterator = new FacilityLayer(2, 2);

            var spaces = iterator.ToList();

            Assert.AreEqual(4, spaces.Count);
            Assert.IsTrue(spaces.Any(x => x.Location.Equals(new XY(0, 0))));
            Assert.IsTrue(spaces.Any(x => x.Location.Equals(new XY(1, 0))));
            Assert.IsTrue(spaces.Any(x => x.Location.Equals(new XY(0, 1))));
            Assert.IsTrue(spaces.Any(x => x.Location.Equals(new XY(1, 1))));
        }
Esempio n. 13
0
        public void FacilityLayer_TwoPortals_PortalsCorrect()
        {
            var layer = new FacilityLayer(2, 1);

            layer[0, 0].UpperObject = _sampleUpperPortal;
            layer[1, 0].UpperObject = _sampleGroundPortal;

            var portals = layer.Portals.ToList();

            Assert.AreEqual(2, portals.Count());
            Assert.IsTrue(portals.Any(x => x.Obj.Equals(_sampleUpperPortal)));
            Assert.IsTrue(portals.Any(x => x.Obj.Equals(_sampleGroundPortal)));
        }
Esempio n. 14
0
        public void FacilityLayer_MultipleValuables_ValuablesCorrect()
        {
            var layer = new FacilityLayer(3, 3);

            layer[0, 0].Put(_sampleLowerValuable);
            layer[1, 0].Put(_sampleLowerValuable);
            layer[1, 2].Put(_sampleLowerValuable);
            layer[2, 2].Put(_sampleLowerValuable);

            var valuables = layer.OrientedValuables;

            Assert.AreEqual(4, valuables.Count());
        }
        public void WallGenerator_Quad_IsCorrect()
        {
            _layer = new FacilityLayer(3, 3);
            PutFloor(0, 0);
            PutFloor(0, 2);
            PutFloor(2, 0);
            PutFloor(2, 2);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(5);
            AssertWallEquals("1379", 1, 1);
        }
        public void WallGenerator_Pillar_IsCorrect()
        {
            _layer = new FacilityLayer(3, 3);
            PutFloorRow(0);
            PutFloor(0, 1);
            PutFloor(2, 1);
            PutFloorRow(2);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(1);
            AssertWallEquals("12346789", 1, 1);
        }
Esempio n. 17
0
        public void FacilityLayer_RemoveLinkedObject_ObjectRemovedFromBothSpots()
        {
            var layer = new FacilityLayer(3, 3);

            _sampleLowerValuable.LinkTo(_sampleLowerValuable2);
            layer[0, 0].Put(_sampleLowerValuable);
            layer[0, 1].Put(_sampleLowerValuable2);

            layer.Remove(_sampleLowerValuable);

            Assert.AreEqual(new FacilityObject(), layer[0, 0].LowerObject);
            Assert.AreEqual(new FacilityObject(), layer[0, 1].LowerObject);
        }
        public void WallGenerator_Sides_AreCorrect()
        {
            _layer = new FacilityLayer(3, 3);
            PutFloor(1, 1);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(8);
            AssertWallEquals("6", 0, 1);
            AssertWallEquals("8", 1, 0);
            AssertWallEquals("4", 2, 1);
            AssertWallEquals("2", 1, 2);
        }
        public void WallGenerator_InnerCorners_AreCorrect()
        {
            _layer = new FacilityLayer(3, 3);
            PutFloor(1, 1);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(8);
            AssertWallEquals("9", 0, 0);
            AssertWallEquals("7", 2, 0);
            AssertWallEquals("3", 0, 2);
            AssertWallEquals("1", 2, 2);
        }
Esempio n. 20
0
        public void FacilityLayer_TwoValuables_ValuablesCorrect()
        {
            var layer = new FacilityLayer(1, 1);

            layer[0, 0].LowerObject = _sampleLowerValuable;
            layer[0, 0].UpperObject = _sampleUpperValuable;

            var valuables = layer.OrientedValuables.ToList();

            Assert.AreEqual(2, valuables.Count());
            Assert.IsTrue(valuables.Any(x => x.Obj.Equals(_sampleLowerValuable)));
            Assert.IsTrue(valuables.Any(x => x.Obj.Equals(_sampleUpperValuable)));
        }
Esempio n. 21
0
        public void FacilityLayer_MultiplePortals_PortalsCorrect()
        {
            var layer = new FacilityLayer(3, 3);

            layer[0, 0].Put(_sampleUpperPortal);
            layer[1, 0].Put(_sampleUpperPortal);
            layer[1, 2].Put(_sampleUpperPortal);
            layer[2, 2].Put(_sampleUpperPortal);

            var portals = layer.Portals;

            Assert.AreEqual(4, portals.Count());
        }
        private FacilityLayer CreateFacilityLayer()
        {
            var layer = new FacilityLayer(3, 3);

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    layer.Put(x, y, CreateFloor());
                }
            }
            return(layer);
        }
        public void WallGenerator_DiagonalCorners_AreCorrect()
        {
            _layer = new FacilityLayer(6, 3);
            PutFloor(0, 2);
            PutFloor(2, 0);
            PutFloor(3, 0);
            PutFloor(5, 2);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(10);
            AssertWallEquals("37", 1, 1);
            AssertWallEquals("19", 4, 1);
        }
        public void WallGenerator_OuterCorners_AreCorrect()
        {
            _layer = new FacilityLayer(3, 3);
            PutFloorColumn(1);
            PutFloorRow(1);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(4);
            AssertWallEquals("68", 0, 0);
            AssertWallEquals("26", 0, 2);
            AssertWallEquals("48", 2, 0);
            AssertWallEquals("24", 2, 2);
        }
        public void WallGenerator_TripleCorners_AreCorrect()
        {
            _layer = new FacilityLayer(5, 5);
            PutFloor(0, 2);
            PutFloor(2, 0);
            PutFloor(2, 2);
            PutFloor(2, 4);
            PutFloor(4, 2);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(16);
            AssertWallEquals("379", 1, 1);
            AssertWallEquals("179", 3, 1);
            AssertWallEquals("139", 1, 3);
            AssertWallEquals("137", 3, 3);
        }
        public void WallGenerator_SidePlusRightCorners_AreCorrect()
        {
            _layer = new FacilityLayer(5, 5);
            PutFloor(0, 1);
            PutFloor(1, 4);
            PutFloor(2, 2);
            PutFloor(3, 0);
            PutFloor(4, 3);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(20);
            AssertWallEquals("38", 2, 1);
            AssertWallEquals("16", 1, 2);
            AssertWallEquals("49", 3, 2);
            AssertWallEquals("27", 2, 3);
        }
Esempio n. 27
0
 public void Init()
 {
     _layer               = new FacilityLayer();
     _sampleSpace         = new FacilitySpace();
     _sampleLowerValuable = new ValuableFacilityObject {
         Type = "CouchLeft", ObjectLayer = ObjectLayer.LowerObject
     };
     _sampleLowerValuable2 = new ValuableFacilityObject {
         Type = "CouchRight", ObjectLayer = ObjectLayer.LowerObject
     };
     _sampleUpperValuable = new ValuableFacilityObject {
         Type = "Wallet", ObjectLayer = ObjectLayer.UpperObject
     };
     _sampleGroundPortal = new FacilityPortal {
         Type = "Manhole", ObjectLayer = ObjectLayer.Ground
     };
     _sampleUpperPortal = new FacilityPortal {
         Type = "Door", ObjectLayer = ObjectLayer.UpperObject
     };
 }
        public void WallGenerator_DoubleWallEndsAndSideJunctions_AreCorrect()
        {
            _layer = new FacilityLayer(5, 5);
            PutFloor(1, 1);
            PutFloor(1, 3);
            PutFloor(2, 2);
            PutFloor(3, 1);
            PutFloor(3, 3);

            _wallGenerator.GenerateWalls(_layer);

            AssertWallCountIs(20);
            AssertWallEquals("79", 2, 0);
            AssertWallEquals("468", 2, 1);
            AssertWallEquals("39", 0, 2);
            AssertWallEquals("268", 1, 2);
            AssertWallEquals("13", 2, 4);
            AssertWallEquals("246", 2, 3);
            AssertWallEquals("17", 4, 2);
            AssertWallEquals("248", 3, 2);
        }
 private void InitGrid(int width, int height)
 {
     _layer = new FacilityLayer(width, height);
     _grid  = new ExpandedPathfindingGrid(_layer);
 }
Esempio n. 30
0
 public Smart2DPathFinder(FacilityLayer layer) : this(new TwoDPathFinder(new ExpandedPathfindingGrid(layer)))
 {
 }