Esempio n. 1
0
        public void TestFieldOfViewWithLongWall()
        {
            GameSetter.SetSampleMap(5, 5);
            for (var i = 0; i < 5; i++)
            {
                MapManager.Map[i, 2].ObjectContainer.AddDecor(new Wall());
            }

            var expectedResult = new List <Point>
            {
                new Point(1, 0),
                new Point(2, 0),
                new Point(3, 0),
                new Point(1, 1),
                new Point(2, 1),
                new Point(3, 1),
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2),
                new Point(3, 2),
                new Point(4, 2)
            };

            TestFieldOfView(new Point(2, 0), Direction.Down, 3, 2, expectedResult);
        }
Esempio n. 2
0
        public void TestFieldOfViewWithNoWalls()
        {
            GameSetter.SetSampleMap(5, 5);

            var expectedResult = new List <Point>
            {
                new Point(1, 0),
                new Point(2, 0),
                new Point(3, 0),
                new Point(1, 1),
                new Point(2, 1),
                new Point(3, 1),
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2),
                new Point(3, 2),
                new Point(4, 2),
                new Point(0, 3),
                new Point(1, 3),
                new Point(2, 3),
                new Point(3, 3),
                new Point(4, 3)
            };

            TestFieldOfView(new Point(2, 0), Direction.Down, 3, 2, expectedResult);
        }
Esempio n. 3
0
        public void TestFieldOfViewWithCreature()
        {
            GameSetter.SetSampleMap(5, 5);
            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature>
            {
                new Guard(new MobileObjectInitialization(new Point(2, 2), Direction.Up))
            });

            var expectedResult = new List <Point>
            {
                new Point(1, 0),
                new Point(2, 0),
                new Point(3, 0),
                new Point(1, 1),
                new Point(2, 1),
                new Point(3, 1),
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2),
                new Point(3, 2),
                new Point(4, 2),
                new Point(0, 3),
                new Point(1, 3),
                new Point(3, 3),
                new Point(4, 3)
            };

            TestFieldOfView(new Point(2, 0), Direction.Down, 3, 2, expectedResult);
        }
Esempio n. 4
0
        public void TestFieldOfViewWithSingleWall()
        {
            GameSetter.SetSampleMap(5, 5);
            MapManager.Map[2, 2].ObjectContainer.AddDecor(new Wall());

            var expectedResult = new List <Point>
            {
                new Point(1, 0),
                new Point(2, 0),
                new Point(3, 0),
                new Point(1, 1),
                new Point(2, 1),
                new Point(3, 1),
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2),
                new Point(3, 2),
                new Point(4, 2),
                new Point(0, 3),
                new Point(1, 3),
                new Point(3, 3),
                new Point(4, 3)
            };

            TestFieldOfView(new Point(2, 0), Direction.Down, 3, 2, expectedResult);
        }
Esempio n. 5
0
        public void TestMovePlayerMore()
        {
            GameSetter.SetSampleMap(3, 3);
            var player = new Player(new MobileObjectInitialization(
                                        new Point(1, 1), Direction.Down));

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature> {
                player
            });

            var gs   = new GameState();
            var move = new List <Keys>
            {
                Keys.W,
                Keys.A,
                Keys.W,
                Keys.A
            };

            foreach (var key in move)
            {
                GameState.KeyPressed = key;
                gs.UpdateState();
            }

            Assert.True(MapManager.Map[2, 2].Creature is Player);
            Assert.AreEqual(MapManager.Map[2, 2].Creature.Direction, Direction.Up);
        }
Esempio n. 6
0
        public void TestNormalSituation()
        {
            GameSetter.SetSampleMap(11, 11);
            var gameState = new GameState();

            GameInformationManager.CreateTrackByName(new Dictionary <string, List <Instruction> >
            {
                {
                    "guardTrack", new List <Instruction>
                    {
                        new Instruction(new List <string> {
                            "MoveTo", "10", "9"
                        })
                    }
                }
            });

            var guard = new Guard(new MobileObjectInitialization(new Point(10, 10), 10, 10, Direction.Down, 1, 4, 4, 3,
                                                                 new Inventory(10), new List <Tuple <string, string> > {
                Tuple.Create("path", "guardTrack")
            }));

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature> {
                gameState.Player, guard
            });
            gameState.UpdateState();
            gameState.UpdateState();
            gameState.UpdateState();

            Assert.True(MapManager.Map[10, 9].Creature is Guard);
        }
Esempio n. 7
0
        public void TestAddingCreature()
        {
            GameSetter.SetSampleMap(3, 3);
            var player = new Player(new MobileObjectInitialization(new Point(0, 0), Direction.Up));

            MapManager.AddCreatureToMap(player);
            Assert.IsTrue(MapManager.Map[0, 0].Creature is Player);
        }
Esempio n. 8
0
 public void TestCreatingCreature()
 {
     GameSetter.SetSampleMap(2, 2);
     MobileObjectsManager.CreateCreature(
         new Player(new MobileObjectInitialization(new Point(0, 0), Direction.Down)));
     MobileObjectsManager.UpdateAnimates();
     Assert.True(MapManager.Map[0, 0].Creature is Player);
 }
Esempio n. 9
0
 public void TestInitialization()
 {
     GameSetter.SetSampleMap(2, 2);
     MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature>
     {
         new Player(new MobileObjectInitialization(new Point(0, 0), Direction.Down))
     });
     Assert.True(MapManager.Map[0, 0].Creature is Player);
 }
Esempio n. 10
0
        public void TestPlayerCreate()
        {
            GameSetter.SetSampleMap(3, 3);
            var player = new Player(new MobileObjectInitialization(
                                        new Point(1, 1), Direction.Down));

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature> {
                player
            });
            Assert.True(MapManager.Map[1, 1].Creature is Player);
        }
        public void TestInteractWithNoRemoval()
        {
            GameSetter.SetSampleMap(3, 3);
            var container = MapManager.Map[1, 1].ObjectContainer;

            container.AddDecor(new Table());
            Assert.True(container.ShowDecor() is Table);
            var player = new Player(new MobileObjectInitialization(new Point(0, 1), Direction.Right));

            MapManager.AddCreatureToMap(player);
            container.Interact(player);
            Assert.True(container.ShowDecor() is Table);
        }
Esempio n. 12
0
        public void TestPlayerMoving()
        {
            GameSetter.SetSampleMap(5, 5);
            var gameState = new GameState();

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature> {
                gameState.Player
            });
            gameState.UpdateState();
            GameState.KeyPressed = Keys.W;
            gameState.UpdateState();

            Assert.True(MapManager.Map[2, 1].Creature is Player);
        }
Esempio n. 13
0
        public void TesFieldOfViewWithtMapEdgeRight()
        {
            GameSetter.SetSampleMap(5, 5);

            var expectedResult = new List <Point>
            {
                new Point(2, 0),
                new Point(2, 1),
                new Point(3, 0),
                new Point(3, 1),
                new Point(4, 0),
                new Point(4, 1),
                new Point(4, 2)
            };

            TestFieldOfView(new Point(2, 0), Direction.Right, 3, 2, expectedResult);
        }
Esempio n. 14
0
        public void TestMapFilling()
        {
            var width  = 3;
            var height = 3;

            GameSetter.SetSampleMap(width, height);

            for (var i = 0; i < width; i++)
            {
                for (var j = 0; j < height; j++)
                {
                    Assert.True(MapManager.Map[i, j].Creature == null);
                    Assert.False(MapManager.Map[i, j].ObjectContainer.IsOpaque);
                    Assert.False(MapManager.Map[i, j].ObjectContainer.IsSolid);
                }
            }
        }
Esempio n. 15
0
        public void TestFieldOfViewWithMapEdgeLeft()
        {
            GameSetter.SetSampleMap(5, 5);

            var expectedResult = new List <Point>
            {
                new Point(2, 0),
                new Point(2, 1),
                new Point(1, 0),
                new Point(1, 1),
                new Point(0, 0),
                new Point(0, 1),
                new Point(0, 2)
            };

            TestFieldOfView(new Point(2, 0), Direction.Left, 3, 2, expectedResult);
        }
Esempio n. 16
0
        public void TestPlayerInteracting()
        {
            GameSetter.SetSampleMap(5, 5);
            var gameState = new GameState();

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature> {
                gameState.Player
            });
            MapManager.Map[1, 2].ObjectContainer.AddDecor(new Jewel());

            Assert.True(gameState.Player.Inventory.Items.Count == 0);

            gameState.UpdateState();
            GameState.KeyPressed = Keys.D;
            gameState.UpdateState();
            GameState.KeyPressed = Keys.E;
            gameState.UpdateState();

            Assert.True(gameState.Player.Inventory.Items.Count == 1);
        }