Пример #1
0
    private void handleKeyDown(object sender, KeyEventArgs e)
    {
        /*update key modifier*/
        p_CurrentKeys = e.KeyData;

        if (p_EventHijacker != null)
        {
            p_EventHijacker.OnKeyDown(this, e);
            return;
        }

        if (e.Modifiers != Keys.None)
        {
            return;
        }

        fogFuck(e.KeyCode);

        switch (e.KeyCode)
        {
        /*debug*/
        case Keys.Enter:
            debugPrompt();
            return;

        case Keys.F3:
            p_DebugLabel.Visible = true;
            p_DebugLabel.Enable();
            break;

        /* arrow key pressed?
         * note: by doing it this way, a player can press 2 keys to make the
         * player go diagonal.
         */
        case Keys.Left:
        case Keys.A:
            p_ArrowKeyDown |= ArrowKey.LEFT;
            break;

        case Keys.Right:
        case Keys.D:
            p_ArrowKeyDown |= ArrowKey.RIGHT;
            break;

        case Keys.Up:
        case Keys.W:
            p_ArrowKeyDown |= ArrowKey.UP;
            break;

        case Keys.Down:
        case Keys.S:
            p_ArrowKeyDown |= ArrowKey.DOWN;
            break;
        }

        //if logic is disabled, do not allow arrow keys but
        //the user might have entered debug mode
        if (p_LogicDisabled)
        {
            p_ArrowKeyDown = 0;
            return;
        }

        /*send to all UI elements*/
        int l = p_UIElements.Length;

        for (int c = 0; c < l; c++)
        {
            p_UIElements[c].OnKeyDown(this, e);
        }
    }