void Update() { if (Input.GetKey(KeyCode.W)) { moveUp = new MoveUpCommand(this.transform, _speed); moveUp.Execute(); CommandManger_2.Instance.AddCommand(moveUp); } else if (Input.GetKey(KeyCode.S)) { moveDown = new MoveDownCommand(this.transform, _speed); moveDown.Execute(); CommandManger_2.Instance.AddCommand(moveDown); } else if (Input.GetKey(KeyCode.A)) { moveLeft = new MoveLeftCommand(this.transform, _speed); moveLeft.Execute(); CommandManger_2.Instance.AddCommand(moveLeft); } else if (Input.GetKey(KeyCode.D)) { moveRight = new MoveRightCommand(this.transform, _speed); moveRight.Execute(); CommandManger_2.Instance.AddCommand(moveRight); } }
void Update() { if (Input.GetKey(upKey)) { moveUp = new MoveUpCommand(this.transform, _speed); moveUp.Execute(); CommandManager.Instance.AddBuffer(moveUp); } else if (Input.GetKey(downKey)) { moveDown = new MoveDownCommand(this.transform, _speed); moveDown.Execute(); CommandManager.Instance.AddBuffer(moveDown); } else if (Input.GetKey(rightKey)) { moveRight = new MoveRightCommand(this.transform, _speed); moveRight.Execute(); CommandManager.Instance.AddBuffer(moveRight); } if (Input.GetKey(leftKey)) { moveLeft = new MoveLeftCommand(this.transform, _speed); moveLeft.Execute(); CommandManager.Instance.AddBuffer(moveLeft); } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Z)) { // Move up command moveUp = new MoveUpCommand(this.transform, this._speed); moveUp.Execute(); MoveCommandManager.Instance.AddCommand(moveUp); } else if (Input.GetKey(KeyCode.S)) { // Move down command moveDown = new MoveDownCommand(this.transform, this._speed); moveDown.Execute(); MoveCommandManager.Instance.AddCommand(moveDown); } else if (Input.GetKey(KeyCode.Q)) { // Move left command moveLeft = new MoveLeftCommand(this.transform, this._speed); moveLeft.Execute(); MoveCommandManager.Instance.AddCommand(moveLeft); } else if (Input.GetKey(KeyCode.D)) { // Move right command moveRight = new MoveRightCommand(this.transform, this._speed); moveRight.Execute(); MoveCommandManager.Instance.AddCommand(moveRight); } }
public void MoveLeftCommand_When_NewDesk_Then_NoMoving() { var desk = _helper.GenerateDesk(4); var moveCommand = new MoveLeftCommand(desk); bool res = moveCommand.Execute(); Assert.False(res); }
public void MoveLeftCommand_When_NewDesk_Then_DeskDoesntChange() { var newDesk = _helper.GenerateDesk(4); var desk = _helper.GenerateDesk(4); var moveCommand = new MoveLeftCommand(desk); moveCommand.Execute(); Assert.Equal(newDesk.GetDesk(), desk.GetDesk()); }
public void HoverCommand_ShouldExecuteClientMoveLeft() { // arrange moveLeftCommand = new MoveLeftCommand(DroneClientMock.Object); // act moveLeftCommand.Execute(); // assert DroneClientMock.Verify(x => x.MoveLeft(), Times.Once); }
public bool Update() { if (Math.Abs(Peach.Location.X - GoalLocation.X) < 5) { Peach.IdleTransition(); foreach (IEntity entity in Collections.Instance.GetLevelRef().Entities) // explode all remaining brick blocks on ceiling { if (entity is GlassBlock glassBlock) { int count = glassBlock.ContainedItems.Count; glassBlock.ExplodeBrickBlockTransition(); for (int i = Constants.ZERO; i < count; i++) { ExplodingBlock child = (ExplodingBlock)glassBlock.ContainedItems[i]; // must do following for all four exploding blocks child.Visible = true; if (i == 1) { child.Sprite.Velocity = new Vector2(-300, -300); // make the blocks go in different directions } else if (i == 2) { child.Sprite.Velocity = new Vector2(300, 300); } else if (i == 3) { child.Sprite.Velocity = new Vector2(300, -300); } else if (i == 4) { child.Sprite.Velocity = new Vector2(-300, 300); } child.ExplodingBlockTransition(); } } } return(true); } else { if (Peach.Location.X > GoalLocation.X) { ICommand moveLeft = new MoveLeftCommand(Peach); moveLeft.Execute(); } else { ICommand moveRight = new MoveRightCommand(Peach); moveRight.Execute(); } } return(false); }
public void ShouldInvokeMoveLeftAndSetStateToHandled() { var slnControl = new Mock <ISolutionExplorerControl>(); slnControl.Setup(x => x.MoveLeft()); var command = new MoveLeftCommand(slnControl.Object); var context = new Context(); var result = command.Execute(context, Keys.H); Assert.Equal(CommandState.Handled, result.State); slnControl.VerifyAll(); }
public void TestCommandMoveLeft() { // Arrange int originalLocationX = fakeGameComponent.X; Command moveLeft = new MoveLeftCommand(); int finalLocationX; // The amount the game object should move in one command int expectedMoveAmount = 1; // Act moveLeft.Execute(fakeGameComponent); finalLocationX = fakeGameComponent.X; // Assert Assert.AreEqual(finalLocationX, originalLocationX - expectedMoveAmount); }
private void Update() { if (!_isPaused) { if (Input.GetKey(KeyCode.LeftArrow)) { var command = new MoveLeftCommand(rb, _playerSpeed, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKeyUp(KeyCode.LeftArrow)) { var command = new StopCommand(rb, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKey(KeyCode.RightArrow)) { var command = new MoveRightCommand(rb, _playerSpeed, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKeyUp(KeyCode.RightArrow)) { var command = new StopCommand(rb, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } commandLagTime += Time.deltaTime; } }