Exemplo n.º 1
0
        public void Update(float time)
        {
            _all.ForEach(t => t.IsFiring = false);
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad8))
            {
                _negZ.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad2))
            {
                _posZ.ForEach(t => t.IsFiring = true);
            }

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad4))
            {
                _negX.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad6))
            {
                _posX.ForEach(t => t.IsFiring = true);
            }

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad1))
            {
                _posRotZ.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad3))
            {
                _negRotZ.ForEach(t => t.IsFiring = true);
            }

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad7))
            {
                _posRotY.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad9))
            {
                _negRotY.ForEach(t => t.IsFiring = true);
            }

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad5))
            {
                _posY.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad0))
            {
                _negY.ForEach(t => t.IsFiring = true);
            }

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.KeypadMinus))
            {
                _negRotX.ForEach(t => t.IsFiring = true);
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.KeypadPlus))
            {
                _posRotX.ForEach(t => t.IsFiring = true);
            }
        }
Exemplo n.º 2
0
        public void Update(float time)
        {
            MoveForce += GameInputTracker.WheelDelta;
            var body = GameObject.GetComponent <DynamicVoxelSpaceBody>();

            if (body.VoxelBody.Exists)
            {
                var force = Vector3.Zero;

                if (GameInputTracker.IsKeyPressed(Key.Keypad6))
                {
                    force += new Vector3(MoveForce, 0, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.Keypad8))
                {
                    force += new Vector3(0, 0, -MoveForce);
                }

                if (GameInputTracker.IsKeyPressed(Key.Keypad4))
                {
                    force += new Vector3(-MoveForce, 0, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.Keypad2))
                {
                    force += new Vector3(0, 0, MoveForce);
                }

                if (GameInputTracker.IsKeyPressed(Key.KeypadPlus))
                {
                    force += new Vector3(0, MoveForce, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.KeypadMinus))
                {
                    force += new Vector3(0, -MoveForce, 0);
                }

                var delta = GameInputTracker.MouseDelta;
                if (delta != Vector2.Zero && (MathF.Abs(delta.X) == 1 || MathF.Abs(delta.Y) == 1))
                {
                    var turn = delta * 0.01f;
                    body.VoxelBody.ApplyAngularImpulse(new Vector3(turn.Y, turn.X, 0));
                }
                else
                {
                    //body.VoxelBody.ApplyAngularImpulse(-body.VoxelBody.Velocity.Angular * 0.1f);
                }

                force = Vector3.Transform(force, GameObject.Transform.WorldOrientation);
                body.VoxelBody.ApplyLinearImpulse(force);
            }
        }
Exemplo n.º 3
0
        public override void Update(double state)
        {
            var intendedDirection = Vector3.Zero;
            var intendedRotation  = Vector3.Zero;

            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad4))
            {
                intendedDirection += -Vector3.UnitX;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad6))
            {
                intendedDirection += Vector3.UnitX;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad8))
            {
                intendedDirection += -Vector3.UnitZ;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad2))
            {
                intendedDirection += Vector3.UnitZ;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.KeypadPlus))
            {
                intendedDirection += Vector3.UnitY;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.KeypadMinus))
            {
                intendedDirection += -Vector3.UnitY;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad7))
            {
                intendedRotation += Vector3.UnitY;
            }
            if (GameInputTracker.IsKeyPressed(Veldrid.Key.Keypad9))
            {
                intendedRotation += -Vector3.UnitY;
            }

            if (intendedDirection != Vector3.Zero || intendedRotation != Vector3.Zero)
            {
                var message = new InputForceApplierMessage()
                {
                    IntendedDirection = intendedDirection,
                    IntendedRotation  = intendedRotation
                };

                _serverChannel.AddBuffered <InputForceApplier, InputForceApplierMessage>(message);
            }
        }
Exemplo n.º 4
0
        public void UpdateFreeMovement(float time)
        {
            FreeMoveSpeed += GameInputTracker.WheelDelta;

            var speed    = FreeMoveSpeed * (GameInputTracker.IsMouseButtonPressed(MouseButton.Right) ? 2 : 1);
            var distance = speed * time;

            if (GameInputTracker.IsKeyPressed(Key.W))
            {
                GameObject.Transform.MoveBy(distance, 0, 0);
            }

            if (GameInputTracker.IsKeyPressed(Key.A))
            {
                GameObject.Transform.MoveBy(0, 0, -distance);
            }

            if (GameInputTracker.IsKeyPressed(Key.S))
            {
                GameObject.Transform.MoveBy(-distance, 0, 0);
            }

            if (GameInputTracker.IsKeyPressed(Key.D))
            {
                GameObject.Transform.MoveBy(0, 0, distance);
            }

            if (GameInputTracker.IsKeyPressed(Key.E))
            {
                GameObject.Transform.RotateBy(0, 0, time * LookSpeed * 100);
            }

            if (GameInputTracker.IsKeyPressed(Key.Q))
            {
                GameObject.Transform.RotateBy(0, 0, -time * LookSpeed * 100);
            }

            if (GameInputTracker.IsKeyPressed(Key.Space))
            {
                GameObject.Transform.MoveBy(0, distance, 0);
            }

            if (GameInputTracker.IsKeyPressed(Key.ShiftLeft))
            {
                GameObject.Transform.MoveBy(0, -distance, 0);
            }

            GameObject.Transform.RotateBy(-GameInputTracker.MouseDelta.X * LookSpeed, -GameInputTracker.MouseDelta.Y * LookSpeed, 0);
        }
Exemplo n.º 5
0
        public void Update(float time)
        {
            if (GameInputTracker.WasKeyDowned(Key.C))
            {
                _character.ToggleCharacter();
            }

            if (_character.HasCharacter)
            {
                UpdateCharacterMovement(time);
            }
            else
            {
                UpdateFreeMovement(time);
            }

            DrawCharacterWindow(time);
        }
Exemplo n.º 6
0
        public void Update(float time)
        {
            MoveForce += GameInputTracker.WheelDelta;
            var body = GameObject.GetComponent <DynamicVoxelSpaceBody>();

            if (body.VoxelBody.Exists)
            {
                var force = Vector3.Zero;

                if (GameInputTracker.IsKeyPressed(Key.Right))
                {
                    force += new Vector3(MoveForce, 0, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.Up))
                {
                    force += new Vector3(0, 0, -MoveForce);
                }

                if (GameInputTracker.IsKeyPressed(Key.Left))
                {
                    force += new Vector3(-MoveForce, 0, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.Down))
                {
                    force += new Vector3(0, 0, MoveForce);
                }

                if (GameInputTracker.IsKeyPressed(Key.P))
                {
                    force += new Vector3(0, MoveForce, 0);
                }

                if (GameInputTracker.IsKeyPressed(Key.L))
                {
                    force += new Vector3(0, -MoveForce, 0);
                }

                force = Vector3.Transform(force, GameObject.Transform.WorldOrientation);
                body.VoxelBody.ApplyLinearImpulse(force);
            }
        }
Exemplo n.º 7
0
        public void UpdateCharacterMovement(float time)
        {
            if (GameInputTracker.IsKeyPressed(Key.W))
            {
                _character.ForwardMovement = ForwardMovement.FORWARD;
            }
            else if (GameInputTracker.IsKeyPressed(Key.S))
            {
                _character.ForwardMovement = ForwardMovement.BACKWARD;
            }
            else
            {
                _character.ForwardMovement = ForwardMovement.NONE;
            }

            if (GameInputTracker.IsKeyPressed(Key.A))
            {
                _character.LateralMovement = LateralMovement.LEFT;
            }
            else if (GameInputTracker.IsKeyPressed(Key.D))
            {
                _character.LateralMovement = LateralMovement.RIGHT;
            }
            else
            {
                _character.LateralMovement = LateralMovement.NONE;
            }

            _character.TryJump = GameInputTracker.WasKeyDowned(Key.Space);

            _character.Sprint = GameInputTracker.IsKeyPressed(Key.ShiftLeft);

            _yaw   += -GameInputTracker.MouseDelta.X * LookSpeed;
            _pitch += -GameInputTracker.MouseDelta.Y * LookSpeed;
            GameObject.Transform.Orientation = Quaternion.CreateFromYawPitchRoll(_yaw, _pitch, 0);
        }