Beispiel #1
0
 public void HandleKeyDown(int player_index, KeyPressed key)
 {
     if (!KeysDown.Contains(key))
     {
         KeysDown.Add(key);
     }
 }
Beispiel #2
0
        void form_KeyDown(object sender, KeyEventArgs e)
        {
            Keys key = e.KeyData & ~Keys.Shift;

            if (KeysDown.Contains(key) == false)
            {
                KeysPressed.Add(key);
                KeysDown.Add(key);
            }
        }
Beispiel #3
0
 public void Device_KeyboardInput(object sender, KeyboardInputEventArgs e)
 {
     if (e.State == KeyState.Pressed)
     {
         if (KeysDown.Contains(e.Key) == false)
         {
             KeysPressed.Add(e.Key);
             KeysDown.Add(e.Key);
         }
     }
     else if (e.State == KeyState.Released)
     {
         KeysReleased.Add(e.Key);
         KeysDown.Remove(e.Key);
     }
 }
Beispiel #4
0
        // Add a key to the list
        public void HandleKeyDown(int player_index, KeyPressed key)
        {
            state.HandleKeyDownInput(player_index, key);

            //Debug.WriteLine("KeyPressed = " + key);
            if (!KeysDown.Contains(key))
            {
                KeysDown.Add(key);
            }

            //-----dbleTap-----
            if (dbleTapCounter == 2)
            {
                dbleTapCounter = 0;
            }
            if (dbleTapCounter == 0)
            {
                dbleTapTimer = dbleTapTime;
            }
            dbleTapCounter++;

            //-----Combo detection-----

            if (state.canCombo) // if this state can combo
            {
                // which item?
                switch (key)
                {
                // Switch to first item
                case (KeyPressed.Attack1):
                    if (items[0] != null)
                    {
                        state.ChangeState(items[0].GetState(0, this, key));     // A button
                    }
                    break;

                // switch to second
                case (KeyPressed.Attack2):
                    if (items[1] != null)
                    {
                        state.ChangeState(items[1].GetState(1, this, key));     // B button
                    }
                    break;

                // switch to third
                case (KeyPressed.Attack3):
                    if (items[2] != null)
                    {
                        state.ChangeState(items[2].GetState(2, this, key));     // X button
                    }
                    break;

                // switch to fourth
                case (KeyPressed.Attack4):
                    if (items[3] != null)
                    {
                        state.ChangeState(items[3].GetState(3, this, key));     // Y button
                    }
                    break;
                }
            }



            // Add the new key, there will always be 3 keys in comboKeys.
            comboKeys.Add(key);
            if (comboKeys.Count > 3)
            {
                comboKeys.RemoveAt(0);
            }
            // This is cleared in the update after the timer is 0

            // Are we in a combo sequence? (Subequent keys pressed within a time limit)
            if (comboTimer > 0 && comboKeys.Count == 3)
            {
                CheckForCombo();
            }

            comboTimer = comboTime; // reset combo timer

            // (Debug) Print the key list

            /*string s = "";
             * for(int i = 0; i < comboKeys.Count; i++)
             * {
             *  s +=  comboKeys[i].ToString() + " ";
             * }*/
            //Debug.WriteLine("Keys: " + s);
        }
Beispiel #5
0
    public void Update()
    {
        mouseDown = false;
        mouseUp   = false;
        mouseStay = false;

        if (Input.touchSupported)
        {
            for (var i = 0; i < Input.touchCount; i++)
            {
                var touch = Input.GetTouch(i);

                switch (touch.phase)
                {
                case TouchPhase.Began:
                    mouseDown = true;
                    break;

                case TouchPhase.Moved:
                case TouchPhase.Stationary:
                    mouseStay = true;
                    break;

                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                    mouseUp = true;
                    break;
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                mouseDown = true;
            }
            if (Input.GetMouseButton(0))
            {
                mouseStay = true;
            }
            if (Input.GetMouseButtonUp(0))
            {
                mouseUp = true;
            }

            var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            MousePositionWorldUnits = new Vector2(mousePosition.x, mousePosition.y);
        }

        KeysDown.Clear();
        KeysUp.Clear();
        KeysStay.Clear();

        foreach (KeyCode keycode in Enum.GetValues(typeof(KeyCode)))
        {
            if (Input.GetKeyDown(keycode))
            {
                KeysDown.Add(keycode);
            }
            if (Input.GetKey(keycode))
            {
                KeysStay.Add(keycode);
            }
            if (Input.GetKeyUp(keycode))
            {
                KeysStay.Add(keycode);
            }
        }
    }
 private void GameOnKeyDown(object sender, KeyboardKeyEventArgs keyboardKeyEventArgs)
 {
     KeysDown.Add(keyboardKeyEventArgs.Key);
 }