public void ExecuteDoNotChangeWhenPolicyFail(Direction direction, int x, int y) { SetupPlayer(direction, x, y); policy.Check(Arg.Any <int>(), Arg.Any <int>()).Returns(false); movement.Execute(); policy.Received(1).Check(Arg.Any <int>(), Arg.Any <int>()); AssertPosition(x, y); }
public void InputControl() { // invoker if (mainPlayer.IsDead) { return; } float movementSpeed = 5; float moveDistance = movementSpeed; float movementX = 0; float movementY = 0; List <Obstacle> collidableObstacles = tileMapFacade.GetTileMap().GetCloseObstacles(mainPlayer.Position); if (Keyboard.IsKeyPressed(Keyboard.Key.W)) { if (!mainPlayer.CheckMovementCollision(0, -moveDistance, collidableObstacles)) { buttonW.Execute(mainPlayer, -moveDistance); //movementY -= moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.S)) { if (!mainPlayer.CheckMovementCollision(0, moveDistance, collidableObstacles)) { buttonS.Execute(mainPlayer, moveDistance); //movementY += moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.D)) { if (!mainPlayer.CheckMovementCollision(moveDistance, 0, collidableObstacles)) { buttonD.Execute(mainPlayer, moveDistance); //movementX += moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.A)) { if (!mainPlayer.CheckMovementCollision(-moveDistance, 0, collidableObstacles)) { buttonA.Execute(mainPlayer, -moveDistance); // movementX -= moveDistance; } } mainPlayer.Translate(movementX, movementY); // move? }
public void Control() // Command invoker { float movementSpeed = 5; float moveDistance = movementSpeed; float movementX = 0; float movementY = 0; List <Obstacle> collidableObstacles = _tilemap.GetTileMap().GetCloseObstacles(_player.Position); if (Keyboard.IsKeyPressed(Keyboard.Key.W)) { if (!_player.CheckMovementCollision(0, -moveDistance, collidableObstacles)) { buttonW.Execute(_player, -moveDistance); //movementY -= moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.S)) { if (!_player.CheckMovementCollision(0, moveDistance, collidableObstacles)) { buttonS.Execute(_player, moveDistance); //movementY += moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.D)) { if (!_player.CheckMovementCollision(moveDistance, 0, collidableObstacles)) { buttonD.Execute(_player, moveDistance); //movementX += moveDistance; } } if (Keyboard.IsKeyPressed(Keyboard.Key.A)) { if (!_player.CheckMovementCollision(-moveDistance, 0, collidableObstacles)) { buttonA.Execute(_player, -moveDistance); // movementX -= moveDistance; } } _player.Translate(movementX, movementY); // move? }
public void HandleM() { Movement.Execute(); }