public void StationaryMelee() { Board board = new Board(BoardCommon.GRID_12X8); Combatant attacker = new Combatant("Attacker", board, new Point(5, 4)); Combatant defender = new Combatant("Defender", board, new Point(7, 4)); board.AddPawn(attacker); board.AddPawn(defender); attacker.Health = 10; defender.Health = 10; attacker.BaseStats = new Stats() { Attack = 10, Stamina = 10 }; MeleeAttackSkill attack = new MeleeAttackSkill(attacker, new Point[] { Point.Right, 2 * Point.Right }) { ActionPoints = 3 }; attack.SetDirection(CardinalDirection.East); attacker.AddSkill(attack); attack.Fire(); board.BeginTurn(); Assert.AreEqual(10, attacker.ActionPoints); board.Turn(); Assert.AreEqual(0, defender.Health); Assert.AreEqual(7, attacker.ActionPoints); }
public void ApproachMeleeRange() { Board board = new Board( new int[,] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }); Combatant attacker = new Combatant("Attacker", board, new Point(1, 7)); Combatant defender = new Combatant("Defender", board, new Point(10, 1)); board.AddPawn(attacker); board.AddPawn(defender); attacker.Health = 10; defender.Health = 10; attacker.BaseStats = new Stats() { Attack = 10, Stamina = 25 }; attacker.AddPawnToView(defender); MeleeAttackSkill attack = new MeleeAttackSkill(attacker, new Point[] { Point.Right, 2 * Point.Right }) { ActionPoints = 3 }; attacker.AddSkill(attack); WalkSkill walk = new WalkSkill(attacker); attacker.AddSkill(walk); LostGen.Decision.ApproachMeleeRange approach = new LostGen.Decision.ApproachMeleeRange(attacker); approach.Target = defender; approach.Setup(); approach.Run(); board.BeginTurn(); Assert.AreEqual(25, attacker.ActionPoints); board.Turn(); Assert.AreEqual(new Point(10, 3), attacker.Position); }
public void CollisionTest() { // Arrange Board board = new Board(BoardCommon.GRID_12X8); Point pos1 = new Point(board.Width / 2, board.Height / 2); // Center of board Point pos2 = pos1 + (3 * Point.Right); // Two tiles to the right of center List<Point> footprint = new List<Point>(new Point[] { Point.Zero, Point.Up, Point.Down, Point.Left, Point.Right }); Pawn pawn1 = new Pawn("First", board, pos1, footprint, true, true, true); Pawn pawn2 = new Pawn("Second", board, pos2, footprint, true, true, true); board.AddPawn(pawn1); board.AddPawn(pawn2); bool p1Triggered = false; bool p2Triggered = false; Pawn.CollisionDelegate p1Collisions = delegate (Pawn source, Pawn other) { p1Triggered = true; Assert.AreSame(source, pawn1); Assert.AreSame(other, pawn2); }; Pawn.CollisionDelegate p2Collisions = delegate (Pawn source, Pawn other) { p2Triggered = true; Assert.AreSame(source, pawn2); Assert.AreSame(other, pawn1); }; pawn1.CollisionEntered += p1Collisions; pawn2.CollisionEntered += p2Collisions; // Act pawn1.Position = pawn1.Position + Point.Right; // Assert Assert.IsTrue(p1Triggered, "Pawn 1's OnCollisionEnter was not triggered"); Assert.IsTrue(p2Triggered, "Pawn 2's OnCollisionEnter was not triggered"); }
// Use this for initialization public void Awake() { Board = new Board(new int[,] { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }); Character chara = Characters.GetCharacter(1); Combatant playerCombatant = chara.CreateCombatant(Board, new Point(1, 14)); playerCombatant.Team = new Team(1, 1, 0, 2); WalkSkill walk = playerCombatant.GetSkill<WalkSkill>(); chara = Characters.GetCharacter(2); Combatant enemy = chara.CreateCombatant(Board, new Point(18, 1)); enemy.Team = new Team(2, 2, 0, 1); _enemyAI = new LostGen.CharacterController(enemy); enemy.AddPawnToView(playerCombatant); Board.AddPawn(playerCombatant); Board.AddPawn(enemy); PlayerController = PlayerController ?? GetComponentInChildren<PlayerController>(); PlayerController.AddCombatant(playerCombatant); PlayerController.AddCombatant(enemy); }
public void MoveIntoWall() { Board board = new Board(BoardCommon.GRID_12X8); Pawn pawn = new Pawn("Mover", board, Point.One, null, true, true); board.AddPawn(pawn); Point expectedPosition = new Point(2, 1); bool moveRight = pawn.Offset(Point.Right); Point position1 = pawn.Position; bool moveUp = pawn.Offset(Point.Up); Point position2 = pawn.Position; Assert.IsTrue(moveRight, "Offset returned false when moving right"); Assert.AreEqual(expectedPosition, position1, "Pawn failed to move right to open tile"); Assert.IsFalse(moveUp, "Offset returned true when moving up into a wall"); Assert.AreEqual(expectedPosition, position2, "Pawn failed to stay on one goddamn place"); }
private void ArrangeBoard(int[,] grid, Point start, Point end, out Board board, out Combatant pawn) { board = new Board(grid); pawn = new Combatant("Walker", board, Point.One); Stats stats = new Stats() { Stamina = 100 }; pawn.BaseStats = stats; board.AddPawn(pawn); WalkSkill walk = new WalkSkill(pawn); pawn.AddSkill(walk); walk.SetTarget(end); board.BeginTurn(); }
public void MoveSolidPawnIntoSolidPawn() { Board board = new Board(BoardCommon.GRID_12X8); Point pos1 = new Point(6, 4); Point pos2 = new Point(8, 4); Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true); Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true); board.AddPawn(pawn1); board.AddPawn(pawn2); Point expectedPosition = new Point(7, 4); bool firstMove = pawn2.Offset(Point.Left); Point firstPosition = pawn2.Position; bool secondMove = pawn2.Offset(Point.Left); Point secondPosition = pawn2.Position; Assert.IsTrue(firstMove, "Pawn was not able to move left one tile"); Assert.IsFalse(secondMove, "Pawn somehow passed through another solid pawn"); Assert.AreEqual(expectedPosition, firstPosition, "Pawn could not move to free tile"); Assert.AreEqual(expectedPosition, secondPosition, "Pawn somehow passed through another solid pawn"); }
public void SolidPawnsMoveIntoSharedCell() { Board board = new Board(BoardCommon.GRID_12X8); Point pos1 = new Point(6, 4); Point pos2 = new Point(8, 4); Point pos3 = new Point(7, 4); Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true); Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true); board.AddPawn(pawn1); board.AddPawn(pawn2); Assert.IsTrue(pawn1.Offset(Point.Right),"Pawn tried to move from " + pos1 + " to " + pos3 + " but was blocked by something"); Assert.IsFalse(pawn2.Offset(Point.Left), "Pawn moved from " + pos2 + " to " + pos3 + " when it should've been blocked"); Assert.AreEqual(pos3, pawn1.Position, "Pawn was not able to move from " + pos1 + " to " + pos3); Assert.AreEqual(pos2, pawn2.Position, "Pawn was able to move from " + pos3 + " to " + pos2); }
public void SolidPawnsMoveIntoEachOther() { Board board = new Board(BoardCommon.GRID_12X8); Point pos1 = new Point(6, 4); Point pos2 = new Point(7, 4); Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true); Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true); board.AddPawn(pawn1); board.AddPawn(pawn2); Assert.IsFalse(pawn1.Offset(Point.Right)); Assert.IsFalse(pawn2.Offset(Point.Left)); Assert.AreEqual(pos1, pawn1.Position); Assert.AreEqual(pos2, pawn2.Position); }