Example #1
0
        public void KeyboardTick()
        {
            foreach (int key in ActiveScene.GetRegisteredKeyPressKeys())
            {
                bool down = false;
                Engine.RunOnUIThread(() =>
                {
                    down = Keyboard.IsKeyDown((Key)key);
                });
                if (down)
                {
                    ActiveScene.RunKeyCallback(KeyAction.KeyPress, key);
                }
            }
            bool   none            = true;
            bool   aDown           = false;
            bool   wDown           = false;
            bool   sDown           = false;
            bool   dDown           = false;
            double shiftMultiplier = 1.0d;

            Engine.RunOnUIThread(() =>
            {
                wDown           = Keyboard.IsKeyDown(Key.W);
                aDown           = Keyboard.IsKeyDown(Key.A);
                sDown           = Keyboard.IsKeyDown(Key.S);
                dDown           = Keyboard.IsKeyDown(Key.D);
                shiftMultiplier = Keyboard.IsKeyDown(Key.LeftShift) ? 2.0d : shiftMultiplier;
            });
            if (wDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(Engine.Renderer.Camera.Direction * (float)(_defaultSpeed * _wA * shiftMultiplier));
                none = false;
            }
            if (aDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(-Engine.Renderer.Camera.Right * (float)(_defaultSpeed * _aA * shiftMultiplier));
                none = false;
            }
            if (sDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(-Engine.Renderer.Camera.Direction * (float)(_defaultSpeed * _sA * shiftMultiplier));
                none = false;
            }
            if (dDown)
            {
                ActiveScene.Context.ActiveWorld.Camera.move(Engine.Renderer.Camera.Right * (float)(_defaultSpeed * _dA * shiftMultiplier));
                none = false;
            }
            if (none)
            {
                _wA = 1;
                _aA = 1;
                _sA = 1;
                _dA = 1;
            }
        }