public void KeyCheck <TBoard>(BoardKeyEventArgs <TBoard> e) where TBoard : Board <TBoard> { foreach (ControllableImageFrames frame in imageFramesList) { if (e.IsKeyDown(frame.Keyy)) { Dispatcher.Invoke((Action) delegate() { Source = frame.Image.Source; }); break; } else { Dispatcher.Invoke((Action) delegate() { Source = StaticImage.Source; }); } } }
protected internal virtual void PerformKey(object sender, BoardKeyEventArgs <TBoard> e) { ImageToDisplay.KeyCheck(e); //Debug.WriteLine("Key pressed"); }
protected internal override void BoardKeyDownMapperBind(object sender, BoardKeyEventArgs <MonkeyBoard> e) { // mechanism to make wall jumping smoother IsWallClinging = false; // left wall jumped cooldown mechanism if (HasLeftWallJumped) { leftWallJumpCooldown++; } if (leftWallJumpCooldown == LeftWallJumpCooldownLimit) { HasLeftWallJumped = false; leftWallJumpCooldown = 0; } // right wall jumped cooldown mechanism if (HasRightWallJumped) { rightWallJumpCooldown++; } if (rightWallJumpCooldown == RightWallJumpCooldownLimit) { HasRightWallJumped = false; rightWallJumpCooldown = 0; } if (IsOnGround()) { // resets all wall jumping IsWallJumping = false; HasLeftWallJumped = false; HasRightWallJumped = false; moveInAirCooldown = 0; leftWallJumpCooldown = 0; rightWallJumpCooldown = 0; } else if (IsWallJumping) { moveInAirCooldown++; if (moveInAirCooldown == MoveInAirCooldownLimit) { IsWallJumping = false; moveInAirCooldown = 0; } } if (e.IsKeyDown(Key.Right) && !IsWallJumping) { //System.Diagnostics.Debug.WriteLine("Right key is pressed."); AddMovement(new MoveLeftRight(Board.CalculateFineness(MovementValue))); } if (e.IsKeyDown(Key.Left) && !IsWallJumping) { //System.Diagnostics.Debug.WriteLine("Left key is pressed."); AddMovement(new MoveLeftRight(-Board.CalculateFineness(MovementValue))); } if (e.IsKeyDown(Key.B)) { if (weaponCooldown == 0) { if (weaponsLimit-- < 1) { return; } weaponCooldown = weaponCooldownLimit; Rocket r = new RocketRight(); r.SetPosition(this.X + 1, this.Y); r.Board = Board; } } if (e.IsKeyDown(Key.V)) { if (weaponCooldown == 0) { if (weaponsLimit-- < 1) { return; } weaponCooldown = weaponCooldownLimit; Rocket r = new RocketLeft(); r.SetPosition(this.X - 1, this.Y); r.Board = Board; } } // beginner form #region Beginner Form if (e.IsKeyPressedOnce(Key.LeftShift) || e.IsKeyPressedOnce(Key.Space)) { if (IsOnGround()) { // ground jumping jumpSound.Play(); AddMovement(new Jump(-Board.CalculateFineness(JumpHeightValue))); } else if (!IsOnGround() && !HasLeftWallJumped && IsNextToWallJumpTile() == AdjacentStatus.TileOnLeft) { if (e.IsKeyDown(Key.Up)) { AddMovement(new Jump(-Board.CalculateFineness(VerticalWallJumpHeightValue))); AddMovement(new ReboundOffWall(Board.CalculateFineness(VerticalReboundValue), DecayFactorVerticalWallJump)); } else { AddMovement(new Jump(-Board.CalculateFineness(LateralWallJumpHeightValue))); AddMovement(new ReboundOffWall(Board.CalculateFineness(LateralReboundValue), DecayFactorLateralWallJump)); } // wall jumping, rebounding left wall jumpSound.Play(); IsWallJumping = true; moveInAirCooldown = 0; HasLeftWallJumped = true; HasRightWallJumped = false; } else if (!IsOnGround() && !HasRightWallJumped && IsNextToWallJumpTile() == AdjacentStatus.TileOnRight) { if (e.IsKeyDown(Key.Up)) { AddMovement(new Jump(-Board.CalculateFineness(VerticalWallJumpHeightValue))); AddMovement(new ReboundOffWall(-Board.CalculateFineness(VerticalReboundValue), DecayFactorVerticalWallJump)); } else { AddMovement(new Jump(-Board.CalculateFineness(LateralWallJumpHeightValue))); AddMovement(new ReboundOffWall(-Board.CalculateFineness(LateralReboundValue), DecayFactorLateralWallJump)); } // wall jumping, rebounding right wall jumpSound.Play(); IsWallJumping = true; moveInAirCooldown = 0; HasRightWallJumped = true; HasLeftWallJumped = false; } } #endregion if ((e.IsKeyDown(Key.Right) && IsNextToWallJumpTile() == AdjacentStatus.TileOnRight) || (e.IsKeyDown(Key.Left) && IsNextToWallJumpTile() == AdjacentStatus.TileOnLeft)) { IsWallClinging = true; } }