Example #1
0
        public void VerifyThatListOfItemsIsSuitablyAdjustedWhenGameObjectMovesFromAnAdditionalOccupiedSpaceToAnotherOccupiedSpace()
        {
            var instructions = new[]
                {
                new PlayerController.TimedInstruction(TimeSpan.Zero, new PlayerController.Instruction(Direction.Right, FiringState.None, FiringState.None)),
                new PlayerController.TimedInstruction(TimeSpan.FromMilliseconds(100), new PlayerController.Instruction(Direction.Right, FiringState.None, FiringState.None))
                };

            var pc = new PlayerController(instructions);
            var wl = new WorldLoaderForTest();
            var g = new Game1(pc, wl);
            g.Components.Add(new SuppressDrawComponent(g));
            g.LoadLevel("pg");
            var w = g.World;
            w.AddGrave(new TilePos(0, 0));

            while (!pc.HasFinishedQueue || w.IsAnythingMoving())
                {
                g.Tick();
                }

            var list = w.GameObjects.GetItemsOnTile(new TilePos(0, 0)).ToList();
            Assert.IsNotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Grave);

            list = w.GameObjects.GetItemsOnTile(new TilePos(1, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(2, list.Count);
            Assert.IsTrue(list[0] is Grave);
            Assert.IsTrue(list[1] is Player);
        }
Example #2
0
        public void TestPlayerShootsAdjacentBoulder()
        {
            var instructions = new[]
                {
                new PlayerController.TimedInstruction(TimeSpan.Zero, new PlayerController.Instruction(Direction.None, FiringState.Pulse, FiringState.None)),
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.DoNothingInstruction())
                };

            var pc = new PlayerController(instructions);
            var wl = new WorldLoaderForTest();
            var g = new Game1(pc, wl);
            g.Components.Add(new SuppressDrawComponent(g));
            g.LoadLevel("# bp ");
            var w = g.World;

            while (!pc.HasFinishedQueue || w.IsAnythingMoving())
                {
                g.Tick();
                }

            var list = w.GameObjects.GetItemsOnTile(new TilePos(1, 0)).ToList();
            Assert.IsNotEmpty(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);
        }
Example #3
0
        public void TestPlayerCannotShootBoulder2()
        {
            var instructions = new[]
                {
                new PlayerController.TimedInstruction(TimeSpan.Zero, new PlayerController.Instruction(Direction.None, FiringState.Pulse, FiringState.None)),
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.DoNothingInstruction())
                };

            var pc = new PlayerController(instructions);
            var wl = new WorldLoaderForTest();
            var g = new Game1(pc, wl);
            g.Components.Add(new SuppressDrawComponent(g));
            g.LoadLevel("# bbp ");
            var w = g.World;

            while (!pc.HasFinishedQueue)
                {
                g.Tick();
                }

            Assert.IsFalse(w.GameObjects.DoesShotExist());
        }
        public void TestPlayerBouncesOneBoulderAndEndsUpPushingAnother()
        {
            var instructions = new[]
                {
                new PlayerController.TimedInstruction(TimeSpan.Zero, new PlayerController.Instruction(Direction.Left, FiringState.None, FiringState.None)),
                new PlayerController.TimedInstruction(TimeSpan.FromMilliseconds(200), PlayerController.Instruction.DoNothingInstruction())
                };

            var pc = new PlayerController(instructions);
            var wl = new WorldLoaderForTest();
            var g = new Game1(pc, wl);
            g.Components.Add(new SuppressDrawComponent(g));
            g.LoadLevel("#bpb #");
            var w = g.World;

            while (!pc.HasFinishedQueue || w.IsAnythingMoving())
                {
                g.Tick();
                }

            var list = w.GameObjects.GetItemsOnTile(new TilePos(1, 0)).ToList();
            Assert.NotNull(list);
            Assert.IsEmpty(list);

            list = w.GameObjects.GetItemsOnTile(new TilePos(2, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);

            list = w.GameObjects.GetItemsOnTile(new TilePos(3, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Player);

            list = w.GameObjects.GetItemsOnTile(new TilePos(4, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);
        }
Example #5
0
        public void VerifyThatTheListOfItemsMovesWhenGameObjectMovesToAnAdjacentEmptySpace()
        {
            var instructions = new[]
                {
                new PlayerController.TimedInstruction(TimeSpan.Zero, new PlayerController.Instruction(Direction.Right, FiringState.None, FiringState.None)),
                new PlayerController.TimedInstruction(TimeSpan.FromMilliseconds(100), new PlayerController.Instruction(Direction.Right, FiringState.None, FiringState.None))
                };

            var pc = new PlayerController(instructions);
            var wl = new WorldLoaderForTest();
            var g = new Game1(pc, wl);
            g.Components.Add(new SuppressDrawComponent(g));
            g.LoadLevel("p ");
            var w = g.World;

            while (!pc.HasFinishedQueue || w.IsAnythingMoving())
                {
                g.Tick();
                }

            Assert.IsEmpty(w.GameObjects.GetItemsOnTile(new TilePos(0, 0)));
            var list = w.GameObjects.GetItemsOnTile(new TilePos(1, 0)).ToList();
            Assert.IsNotEmpty(list);
            Assert.IsTrue(list.SequenceEqual(new List<StaticItem> {w.Player}));
        }