/// <summary>
 /// Method, which processes keyboards events (key up and key down).
 /// </summary>
 /// <param name="source">Source of event. Not used.</param>
 /// <param name="args">Arguments of event. Uses to determine, is key up or down</param>
 public void KeyEventHandler(Object source, KeyboardKeyEventArgs args)
 {
     PlayerKeyEventArgs p_args = new PlayerKeyEventArgs(Keyboard.GetState().IsKeyUp(args.Key));
     if (args.Key == keys.UpKey)
         OnUpCommand(p_args);
     if (args.Key == keys.DownKey)
         OnDownCommand(p_args);
     if (args.Key == keys.LeftKey)
         OnLeftCommand(p_args);
     if (args.Key == keys.RightKey)
         OnRightCommand(p_args);
     if (args.Key == keys.ShootKey)
         OnShootCommand(p_args);
 }
Example #2
0
 protected virtual void OnUpCommand(PlayerKeyEventArgs args)
 {
     if (UpCommand != null)
         UpCommand(this, args);
 }
Example #3
0
 protected virtual void OnShootCommand(PlayerKeyEventArgs args)
 {
     if (ShootCommand != null)
         ShootCommand(this, args);
 }
Example #4
0
 protected virtual void OnRightCommand(PlayerKeyEventArgs args)
 {
     if (RightCommand != null)
         RightCommand(this, args);
 }
Example #5
0
 protected virtual void OnLeftCommand(PlayerKeyEventArgs args)
 {
     if (LeftCommand != null)
         LeftCommand(this, args);
 }
Example #6
0
 protected virtual void OnDownCommand(PlayerKeyEventArgs args)
 {
     if (DownCommand != null)
         DownCommand(this, args);
 }
Example #7
0
 private void UpCommandHandler(Object source, PlayerKeyEventArgs args)
 {
     IsUpState = args.KeyReleased;
 }