Пример #1
0
        void keyController_KeyControlDisengaged(int control)
        {
            KeyMappings.SimpleGameControls c = (KeyMappings.SimpleGameControls)control;
            var player = (Player)ActiveMap.Player;

            switch (c)
            {
            case KeyMappings.SimpleGameControls.MoveUp:

                break;

            case KeyMappings.SimpleGameControls.MoveDown:

                break;

            case KeyMappings.SimpleGameControls.MoveLeft:
                //player.Velocity /= 2f;
                break;

            case KeyMappings.SimpleGameControls.MoveRight:
                //player.Velocity /= 2f;
                break;

            default:
                break;
            }
        }
Пример #2
0
        void keyController_KeyControlEngaged(int control)
        {
            KeyMappings.SimpleGameControls c = (KeyMappings.SimpleGameControls)control;
            var     player         = (Player)ActiveMap.Player;
            Vector2 mouseDirection = (new Vector2(Mouse.GetState().X, Mouse.GetState().Y)) - player.Position;
            var     rad            = mouseDirection.Length();

            mouseDirection.Normalize();

            switch (c)
            {
            //case KeyMappings.PolarMouseGameControls.MoveIn:
            //    PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * mouseDirection));
            //    break;
            //case KeyMappings.PolarMouseGameControls.MoveOut:
            //    PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, -player.Mass * player.SpeedScale * mouseDirection));
            //    break;
            //case KeyMappings.PolarMouseGameControls.MoveClockwise:
            //    var tangentCW = mouseDirection.RotateInPlace(-(float)Math.PI / 2);
            //    var tangVel = Vector2.Dot(player.Velocity, tangentCW);
            //    player.Velocity = tangentCW * tangVel;
            //    PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * tangentCW));
            //    break;
            //case KeyMappings.PolarMouseGameControls.MoveCounterClockwise:
            //    var tangentCCW = mouseDirection.RotateInPlace((float)Math.PI / 2);
            //    var tangVelCCW = Vector2.Dot(player.Velocity, tangentCCW);
            //    player.Velocity = tangentCCW * tangVelCCW;
            //    PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * tangentCCW));
            //    break;

            case KeyMappings.SimpleGameControls.MoveUp:
                PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * -Vector2.UnitY));
                break;

            case KeyMappings.SimpleGameControls.MoveDown:
                PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * Vector2.UnitY));
                break;

            case KeyMappings.SimpleGameControls.MoveLeft:
                PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * -Vector2.UnitX));
                break;

            case KeyMappings.SimpleGameControls.MoveRight:
                PhysicsManager.AddInstantaneousForce(new InstantaneousForce((IRigidBody)player, player.Mass * player.SpeedScale * Vector2.UnitX));
                break;

            default:
                break;
            }
        }