Exemplo n.º 1
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Right)
     {
         RightMove.Start();
     }
     if (e.KeyCode == Keys.Left)
     {
         LeftMove.Start();
     }
     if (e.KeyCode == Keys.Up)
     {
         UpMove.Start();
     }
     if (e.KeyCode == Keys.Down)
     {
         DownMove.Start();
     }
     if (e.KeyCode == Keys.Space)
     {
         if (canFire == true)
         {
             lasers[0].Location = new Point(player.Location.X + 20, player.Location.Y - 0);
             MoveLaser.Start();
         }
     }
 }
Exemplo n.º 2
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     RightMove.Stop();
     LeftMove.Stop();
     UpMove.Stop();
     DownMove.Stop();
     // canFire = false;
 }
Exemplo n.º 3
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     MainPlayer.Image = RotateImage((Bitmap)imgMainPlayer[1], angle);
     if (e.KeyCode == Keys.Left)
     {
         LeftRotate.Start();
     }
     if (e.KeyCode == Keys.Right)
     {
         RightRotate.Start();
     }
     if (e.KeyCode == Keys.Up)
     {
         UpMove.Start();
     }
     if (e.KeyCode == Keys.Down)
     {
         DownMove.Start();
     }
 }
Exemplo n.º 4
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left)
     {
         LeftRotate.Stop();
     }
     if (e.KeyCode == Keys.Right)
     {
         RightRotate.Stop();
     }
     if (e.KeyCode == Keys.Up)
     {
         UpMove.Stop();
     }
     if (e.KeyCode == Keys.Down)
     {
         DownMove.Stop();
     }
     if (UpMove.Enabled == false && DownMove.Enabled == false && LeftRotate.Enabled == false & RightRotate.Enabled == false)
     {
         MainPlayer.Image = RotateImage((Bitmap)imgMainPlayer[0], angle);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///     Check keyboard input and fire events according to what was pressed.
        /// </summary>
        private void CheckInput()
        {
            if (TMBAW_Game.CurrentGameMode == GameMode.None)
            {
                return;
            }

            if (TMBAW_Game.Dialog.IsActive)
            {
                return;
            }

            if (StoryTracker.InCutscene || GameWorld.IsInCutsceneMode)
            {
                return;
            }

            if (DialogueSystem.IsShowingDialogue)
            {
                return;
            }

            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                return;
            }

            if (IsPunchPressed() && !_attackIsPressed)
            {
                PlayerScript.TimeSinceLastPunch.Reset();
            }

            if (!PlayerScript.IsDoingAction)
            {
                if (TMBAW_Game.CurrentGameMode == GameMode.Play)
                {
                    if (IsRewindPressed())
                    {
                        RewindAction?.Invoke();
                    }
                }
                if (IsMoveLeftPressed())
                {
                    LeftMove?.Invoke();
                }
                if (IsMoveRightPressed())
                {
                    RightMove?.Invoke();
                }
                if (IsMoveDownPressed())
                {
                    if (GameWorld.WorldData.IsTopDown)
                    {
                        DownMove?.Invoke();
                    }
                    else
                    {
                        DuckAction?.Invoke();
                    }
                }
                else
                {
                    DuckActionStop?.Invoke();
                }
                if (IsInteractPressed())
                {
                    if (GameWorld.WorldData.IsTopDown)
                    {
                        UpMove?.Invoke();
                    }
                    else
                    {
                        InteractAction?.Invoke();
                    }
                }

                if (!IsMoveDownPressed() && !IsInteractPressed())
                {
                    ReleaseUpAndDownAction?.Invoke();
                }

                if (IsPunchPressed())
                {
                    if (!_attackIsPressed)
                    {
                        //FireWeaponAction?.Invoke();
                        _attackIsPressed = true;
                    }
                }
                else
                {
                    _attackIsPressed = false;
                }

                if (IsWeaponFirePressed())
                {
                    FireWeaponAction?.Invoke();
                }

                if (InputSystem.WasKeyReleased(Keys.Space) && IsJumpButtonPressed())
                {
                    JumpAction?.Invoke();
                    //_jumpButtonIsPressed = true;
                }
                //else
                //{
                //    _jumpButtonIsPressed = false;
                //}
                if (IsSprintButtonPressed())
                {
                    FastRunActive?.Invoke();
                }
                else
                {
                    FastRunInactive?.Invoke();
                }
            }


            StillUpdate?.Invoke();

            if (InputSystem.IsAnyInputPressed())
            {
                NotIdle?.Invoke();
            }
        }