Exemplo n.º 1
0
        /** <summary> Initializes the gamepad listener. </summary> */
        public static void Initialize()
        {
            // States
            buttons			= new InputControl[4, NumButtons];
            sticks			= new AnalogStick[4, NumSticks];
            triggers		= new Trigger[4, NumTriggers];
            disabled		= false;

            // Setup
            for (int i = 0; i < 4; i++) {
            for (int j = 0; j < NumButtons; j++)
                buttons[i, j] = new InputControl();
            for (int j = 0; j < NumSticks; j++)
                sticks[i, j] = new AnalogStick();
            for (int j = 0; j < NumTriggers; j++)
                triggers[i, j] = new Trigger();

            buttons[i, (int)Buttons.LeftStickRight]		= sticks[i, (int)Buttons.LeftStick].Right;
            buttons[i, (int)Buttons.LeftStickDown]		= sticks[i, (int)Buttons.LeftStick].Down;
            buttons[i, (int)Buttons.LeftStickLeft]		= sticks[i, (int)Buttons.LeftStick].Left;
            buttons[i, (int)Buttons.LeftStickUp]		= sticks[i, (int)Buttons.LeftStick].Up;

            buttons[i, (int)Buttons.RightStickRight]	= sticks[i, (int)Buttons.RightStick].Right;
            buttons[i, (int)Buttons.RightStickDown]		= sticks[i, (int)Buttons.RightStick].Down;
            buttons[i, (int)Buttons.RightStickLeft]		= sticks[i, (int)Buttons.RightStick].Left;
            buttons[i, (int)Buttons.RightStickUp]		= sticks[i, (int)Buttons.RightStick].Up;

            buttons[i, (int)Buttons.DPadRight]			= sticks[i, (int)Buttons.DPad].Right;
            buttons[i, (int)Buttons.DPadDown]			= sticks[i, (int)Buttons.DPad].Down;
            buttons[i, (int)Buttons.DPadLeft]			= sticks[i, (int)Buttons.DPad].Left;
            buttons[i, (int)Buttons.DPadUp]				= sticks[i, (int)Buttons.DPad].Up;
            sticks[i, (int)Buttons.DPad].DirectionDeadZone	= Vector2F.Zero;

            buttons[i, (int)Buttons.LeftTriggerButton]	= triggers[i, (int)Buttons.LeftTrigger].Button;
            buttons[i, (int)Buttons.RightTriggerButton]	= triggers[i, (int)Buttons.RightTrigger].Button;
            }
        }
Exemplo n.º 2
0
        private Vector2F velocityPrev; // The player's velocity on the previous frame.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public PlayerMoveComponent(Player player)
        {
            this.player = player;

            // Default settings.
            autoAccelerate			= false;
            moveSpeedScale			= 1.0f;
            moveCondition			= PlayerMoveCondition.FreeMovement;
            canLedgeJump			= true;
            canJump					= true;
            isStrafing				= false;

            // Internal.
            allowMovementControl	= true;
            moveAxes				= new bool[] { false, false };
            motion					= Vector2F.Zero;
            isMoving				= false;
            velocityPrev			= Vector2F.Zero;
            moveAngle				= Angles.South;
            mode					= new PlayerMotionType();

            // Controls.
            analogMode		= false;
            analogStick		= GamePad.GetStick(Buttons.LeftStick);
            analogAngle		= 0.0f;
            moveButtons		= new InputControl[4];
            moveButtons[Directions.Up]		= Controls.Up;
            moveButtons[Directions.Down]	= Controls.Down;
            moveButtons[Directions.Left]	= Controls.Left;
            moveButtons[Directions.Right]	= Controls.Right;

            // Normal movement.
            moveModeNormal = new PlayerMotionType();
            moveModeNormal.MoveSpeed			= 1.0f;
            moveModeNormal.CanLedgeJump			= true;
            moveModeNormal.CanRoomChange		= true;

            // Slow movement.
            moveModeSlow = new PlayerMotionType();
            moveModeSlow.MoveSpeed				= 0.5f;
            moveModeSlow.CanLedgeJump			= true;
            moveModeSlow.CanRoomChange			= true;

            // Ice movement.
            moveModeIce = new PlayerMotionType();
            moveModeIce.MoveSpeed				= 1.0f;
            moveModeIce.CanLedgeJump			= true;
            moveModeIce.CanRoomChange			= true;
            moveModeIce.IsSlippery				= true;
            moveModeIce.Acceleration			= 0.02f;
            moveModeIce.Deceleration			= 0.05f;
            moveModeIce.MinSpeed				= 0.05f;
            moveModeIce.DirectionSnapCount		= 32;

            // Air/jump movement.
            moveModeAir = new PlayerMotionType();
            moveModeAir.IsStrafing				= true;
            moveModeAir.MoveSpeed				= 1.0f;
            moveModeAir.CanLedgeJump			= false;
            moveModeAir.CanRoomChange			= false;
            moveModeAir.IsSlippery				= true;
            moveModeAir.Acceleration			= 0.1f;
            moveModeAir.Deceleration			= 0.0f;
            moveModeAir.MinSpeed				= 0.05f;
            moveModeAir.DirectionSnapCount		= 8;//32;

            // Water/swim movement.
            moveModeWater = new PlayerMotionType();
            moveModeWater.MoveSpeed				= 0.5f;
            moveModeWater.CanLedgeJump			= true;
            moveModeWater.CanRoomChange			= true;
            moveModeWater.IsSlippery			= true;
            moveModeWater.Acceleration			= 0.08f;
            moveModeWater.Deceleration			= 0.05f;
            moveModeWater.MinSpeed				= 0.05f;
            moveModeWater.DirectionSnapCount	= 32;

            mode = moveModeNormal;
        }
Exemplo n.º 3
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        // Initializes the controls for the game
        public static void Initialize()
        {
            Controls.arrows = new MultiGameButton[4];
            Controls.arrows[Directions.Up]		= new MultiGameButton(new GameButton(Keys.Up), new GameButton(Buttons.LeftStickUp));
            Controls.arrows[Directions.Down]	= new MultiGameButton(new GameButton(Keys.Down), new GameButton(Buttons.LeftStickDown));
            Controls.arrows[Directions.Left]	= new MultiGameButton(new GameButton(Keys.Left), new GameButton(Buttons.LeftStickLeft));
            Controls.arrows[Directions.Right]	= new MultiGameButton(new GameButton(Keys.Right), new GameButton(Buttons.LeftStickRight));

            Controls.analogMovement	= GamePad.GetStick(Buttons.LeftStick);

            Controls.a				= new MultiGameButton(new GameButton(Keys.X), new GameButton(Buttons.A));
            Controls.b				= new MultiGameButton(new GameButton(Keys.Z), new GameButton(Buttons.B));
            Controls.x				= new MultiGameButton(new GameButton(Keys.S), new GameButton(Buttons.X));
            Controls.y				= new MultiGameButton(new GameButton(Keys.A), new GameButton(Buttons.Y));

            Controls.start			= new MultiGameButton(new GameButton(Keys.Enter), new GameButton(Buttons.Start));
            Controls.select			= new MultiGameButton(new GameButton(Keys.Backslash), new GameButton(Buttons.Back));
        }
        private Vector2F velocityPrev; // The player's velocity on the previous frame.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public PlayerMoveComponent(Player player)
        {
            this.player = player;

            // Default settings.
            autoAccelerate			= false;
            moveSpeedScale			= 1.0f;
            moveCondition			= PlayerMoveCondition.FreeMovement;
            canLedgeJump			= true;
            canJump					= true;
            canPush					= true;
            canUseWarpPoint			= true;
            isStrafing				= false;
            isSprinting				= false;
            sprintTimer				= 0;
            sprintSpeedScale		= 1.5f;

            // Internal.
            allowMovementControl	= true;
            moveAxes				= new bool[] { false, false };
            motion					= Vector2F.Zero;
            isMoving				= false;
            velocityPrev			= Vector2F.Zero;
            moveAngle				= Angles.South;
            mode					= new PlayerMotionType();
            jumpStartTile			= -Point2I.One;
            isCapeDeployed			= false;
            doomedToFallInHole		= false;
            holeTile				= null;
            holeDoomTimer			= 0;
            holeSlipVelocity		= Vector2F.Zero;
            fallingInHole			= false;
            isOnColorBarrier		= false;
            isOnSideScrollLadder	= false;
            climbCollisionBox		= new Rectangle2F(-1, -7, 2, 9);

            // Controls.
            analogMode		= false;
            analogStick		= GamePad.GetStick(Buttons.LeftStick);
            analogAngle		= 0.0f;
            moveButtons		= new InputControl[4];
            moveButtons[Directions.Up]		= Controls.Up;
            moveButtons[Directions.Down]	= Controls.Down;
            moveButtons[Directions.Left]	= Controls.Left;
            moveButtons[Directions.Right]	= Controls.Right;

            // Normal movement.
            moveModeNormal = new PlayerMotionType();
            moveModeNormal.MoveSpeed			= 1.0f;
            moveModeNormal.CanLedgeJump			= true;
            moveModeNormal.CanRoomChange		= true;

            // Slow movement.
            moveModeSlow = new PlayerMotionType(moveModeNormal);
            moveModeSlow.MoveSpeed = 0.5f;

            // Grass movement.
            moveModeGrass = new PlayerMotionType(moveModeNormal);
            moveModeGrass.MoveSpeed = 0.75f;

            // Ice movement.
            moveModeIce = new PlayerMotionType();
            moveModeIce.MoveSpeed				= 1.0f;
            moveModeIce.CanLedgeJump			= true;
            moveModeIce.CanRoomChange			= true;
            moveModeIce.IsSlippery				= true;
            moveModeIce.Acceleration			= 0.02f;
            moveModeIce.Deceleration			= 0.05f;
            moveModeIce.MinSpeed				= 0.05f;
            moveModeIce.DirectionSnapCount		= 32;

            // Air/jump movement.
            moveModeAir = new PlayerMotionType();
            moveModeAir.IsStrafing				= true;
            moveModeAir.MoveSpeed				= 1.0f;
            moveModeAir.CanLedgeJump			= false;
            moveModeAir.CanRoomChange			= false;
            moveModeAir.IsSlippery				= true;
            moveModeAir.Acceleration			= 0.1f;
            moveModeAir.Deceleration			= 0.0f;
            moveModeAir.MinSpeed				= 0.05f;
            moveModeAir.DirectionSnapCount		= 8;//32;

            // Water/swim movement.
            moveModeWater = new PlayerMotionType();
            moveModeWater.MoveSpeed				= 0.5f;
            moveModeWater.CanLedgeJump			= true;
            moveModeWater.CanRoomChange			= true;
            moveModeWater.IsSlippery			= true;
            moveModeWater.Acceleration			= 0.08f;
            moveModeWater.Deceleration			= 0.05f;
            moveModeWater.MinSpeed				= 0.05f;
            moveModeWater.DirectionSnapCount	= 32;

            mode = moveModeNormal;
        }