Example #1
0
        public static Point GetDirection(ConsoleKey _key)
        {
            if (!MoveKeys.Contains(_key))
            {
                return(null);
            }

            var dx = (_key == ConsoleKey.LeftArrow ? -1 : 0) + (_key == ConsoleKey.RightArrow ? 1 : 0);
            var dy = (_key == ConsoleKey.UpArrow ? -1 : 0) + (_key == ConsoleKey.DownArrow ? 1 : 0);

            dx += (_key == ConsoleKey.NumPad4 ? -1 : 0) + (_key == ConsoleKey.NumPad6 ? 1 : 0);

            dx += (_key == ConsoleKey.NumPad7 ? -1 : 0) + (_key == ConsoleKey.NumPad9 ? 1 : 0);
            dx += (_key == ConsoleKey.NumPad1 ? -1 : 0) + (_key == ConsoleKey.NumPad3 ? 1 : 0);

            dx += (_key == ConsoleKey.Home ? -1 : 0) + (_key == ConsoleKey.PageUp ? 1 : 0);
            dx += (_key == ConsoleKey.End ? -1 : 0) + (_key == ConsoleKey.PageDown ? 1 : 0);

            dy += (_key == ConsoleKey.NumPad8 ? -1 : 0) + (_key == ConsoleKey.NumPad2 ? 1 : 0);

            dy += (_key == ConsoleKey.NumPad7 ? -1 : 0) + (_key == ConsoleKey.NumPad1 ? 1 : 0);
            dy += (_key == ConsoleKey.NumPad9 ? -1 : 0) + (_key == ConsoleKey.NumPad3 ? 1 : 0);

            dy += (_key == ConsoleKey.Home ? -1 : 0) + (_key == ConsoleKey.End ? 1 : 0);
            dy += (_key == ConsoleKey.PageUp ? -1 : 0) + (_key == ConsoleKey.PageDown ? 1 : 0);

            return(new Point(dx, dy));
        }
Example #2
0
        public override void OnKeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
        {
            if (IsLocked)
            {
                return;
            }

            if (MoveKeys.Contains(e.Key))
            {
                bMoving    = false;
                SpeedIndex = 0;
            }

            if (MoveKeyDictionary.ContainsKey(e.Key))
            {
                MoveKeyDictionary[e.Key] = false;
            }
        }
Example #3
0
        public override void OnKeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
        {
            if (IsLocked)
            {
                return;
            }

            if (MoveKeys.Contains(e.Key))
            {
                MoveStarted = EyeLocation;
                bMoving     = true;
                UpdateMoveSpeed();
            }

            if (MoveKeyDictionary.ContainsKey(e.Key))
            {
                MoveKeyDictionary[e.Key] = true;
                Move();
            }
        }