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); }
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); }
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); }
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})); }
public void TestPlayerCannotBouncesOneBoulderBecauseAnotherBoulderBehindCannotMove() { var pc = new PlayerController(); var wl = new WorldLoaderForTest(); var g = new Game1(pc, wl); g.Components.Add(new SuppressDrawComponent(g)); g.LoadLevel("#bpb#"); var w = g.World; Assert.IsFalse(w.Player.CanMoveInDirection(Direction.Left)); var boulder1 = (Boulder) w.GameObjects.GetItemsOnTile(new TilePos(1, 0)).ElementAt(0); boulder1.PushOrBounce(w.Player, Direction.Left); Assert.AreEqual(Direction.None, w.Player.Direction); Assert.AreEqual(Direction.None, boulder1.Direction); }