Beispiel #1
0
        public void Init_And_GetProperties_Success()
        {
            IMapEngine mapEngine = TestMapEngineFactory.InitMapEngine();

            Assert.IsNotNull(mapEngine.Map.Tiles);
            Assert.IsTrue(mapEngine.Map.Width == 2 && mapEngine.Map.Height == 1);
        }
        public void GetFullFrame_WithTiles()
        {
            var mapEngine = TestMapEngineFactory.InitMapEngine();

            var eyeSight = new ActiveBodyEyesight(mapEngine);

            var player = new PlayerBody(new ShapeCircle(3, new Point(2, 1)),
                                        new Vector(1, 1), null, null, 0, 0, "Bob", 100, 1);

            mapEngine.AddBody(player);

            var frame = eyeSight.GetFrame(player.Id, null);

            Assert.IsTrue(frame.Bodies != null && frame.Map != null);
        }
Beispiel #3
0
        public void MoveBodyBetweenTiles_Success()
        {
            IMapEngine mapEngine = TestMapEngineFactory.InitMapEngine();

            var player = new PlayerBody(new ShapeCircle(3, new Point(2, 1)),
                                        new Vector(1, 1), null, null, 0, 0, "Bob", 100, 1);

            mapEngine.AddBody(player);
            Assert.IsTrue(mapEngine.Map.Tiles[0][0].Bodies.ElementAt(0).Value == player);

            //update player position
            player.Shape.Position = new Point(mapEngine.Map.CellSize + 1, 1);

            //update map
            mapEngine.UpdateActiveBody(player);
            Assert.IsTrue(mapEngine.Map.Tiles[0][1].Bodies.ElementAt(0).Value == player);
        }
Beispiel #4
0
        public void GetBodiesForCollission_Success()
        {
            IMapEngine mapEngine = TestMapEngineFactory.InitMapEngine();

            var player1 = new PlayerBody(new ShapeCircle(3, new Point(2, 1)),
                                         new Vector(1, 1), null, null, 0, 0, "Bob", 100, 1);
            var player2 = new PlayerBody(new ShapeCircle(3, new Point(22, 12)),
                                         new Vector(1, 1), null, null, 0, 0, "Bob", 100, 1);

            mapEngine.AddBody(player1);
            mapEngine.AddBody(player2);

            Assert.IsTrue(mapEngine.Map.Tiles[0][0].Bodies.ElementAt(1).Value == player1 && mapEngine.Map.Tiles[0][0].Bodies.ElementAt(0).Value == player2);

            //update map
            var bodiesForCollision = mapEngine.GetBodiesForCollision(player1);

            Assert.IsTrue(bodiesForCollision.Count() == 1);
        }
        public void New_NPC_Should_Be_Added()
        {
            //Arrange
            IMapEngine mapEngine      = TestMapEngineFactory.InitMapEngine();
            var        mechanigEngine = Substitute.For <IMechanicEngine>();

            mechanigEngine.Bodies.Count.Returns(v => 0);
            mechanigEngine.Map.Tiles.Returns(v => mapEngine.Map.Tiles);

            var bodyBuilder = Substitute.For <IBodyBuilder>();

            bodyBuilder.BuildNPCAI(Arg.Any <IMechanicEngine>()).Returns(v => new NPCAI(null, null, 1, 1, 1, 1));

            var npcGenerator = new NPCGenerationService(mechanigEngine, bodyBuilder, 1);

            //Act
            npcGenerator.Update();

            //Assert
            mechanigEngine.Received().AddBody(Arg.Any <ActiveBody>());
        }