private void GetPlayerInput( PlayerIndex playerIndex, InputState input, out PlayerInput playerInput ) { if ( playerIndex < PlayerIndex.One ) { playerAI.GetInput( out playerInput ); } else { playerInput.ButtonAHit = input.IsNewButtonPress( Buttons.A, playerIndex, out playerIndex ); playerInput.ButtonBHit = input.IsNewButtonPress( Buttons.B, playerIndex, out playerIndex ); playerInput.ButtonXHit = input.IsNewButtonPress( Buttons.X, playerIndex, out playerIndex ); playerInput.ButtonYHit = input.IsNewButtonPress( Buttons.Y, playerIndex, out playerIndex ); playerInput.ButtonADown = input.CurrentGamePadStates[(int)playerIndex].IsButtonDown( Buttons.A ); playerInput.ButtonBDown = input.CurrentGamePadStates[(int)playerIndex].IsButtonDown( Buttons.B ); if ( !playerInput.ButtonBDown ) playerInput.ButtonBDown = input.CurrentGamePadStates[(int)playerIndex].IsButtonDown( Buttons.X ); GamePadState gamePadState = input.CurrentGamePadStates[(int)playerIndex]; playerInput.LeftTrigger = gamePadState.Triggers.Left; playerInput.RightTrigger = gamePadState.Triggers.Right; playerInput.LeftBumper = gamePadState.IsButtonDown( Buttons.LeftShoulder ); playerInput.RightBumper = gamePadState.IsButtonDown( Buttons.RightShoulder ); playerInput.LeftStick = gamePadState.ThumbSticks.Left; playerInput.LeftDpad = gamePadState.DPad.Left == ButtonState.Pressed; playerInput.RightDpad = gamePadState.DPad.Right == ButtonState.Pressed; playerInput.DownDpad = gamePadState.DPad.Down == ButtonState.Pressed; } }
public void GetInput( out PlayerInput playerInput ) { //AI SUPERBRAIN GOES HERE playerInput.ButtonAHit = false; playerInput.ButtonADown = false; playerInput.ButtonBHit = false; playerInput.ButtonBDown = false; playerInput.ButtonXHit = false; playerInput.ButtonYHit = ShouldUsePowerup; playerInput.LeftTrigger = 0; playerInput.RightTrigger = 0; playerInput.LeftStick = Vector2.Zero; playerInput.LeftDpad = false; playerInput.DownDpad = false; playerInput.RightDpad = false; playerInput.LeftBumper = false; playerInput.RightBumper = false; // No stage data yet if ( rows.Count == 0 || !player.Screen.CameraIsScrolling ) return; // MOVEMENT //if falling through row // try to align self with hole //else if row has been visible for x seconds // find nearest hole // set target to hole PhysCircle circle = player.BoundingCircle; // determine if falling through hole float rowsTraveled = ( player.Screen.FirstRow - circle.Position.Y ) / player.Screen.RowSpacing; float remainder = rowsTraveled - (float)Math.Floor( rowsTraveled ); if ( remainder > .5f ) remainder = 1f - remainder; float holeDist = ( FloorBlock.Height / 2 + circle.Radius ) / player.Screen.RowSpacing; if ( remainder < holeDist ) { if ( circle.Touching != null ) { playerInput.DownDpad = true; } } else { foreach ( KeyValuePair<float, int> row in rows ) { // TODO: Reaction time delay if ( row.Key < circle.Position.Y ) { Vector2 hole = GetNearestHole( row ); if ( circle.Position.X < hole.X ) playerInput.LeftStick.X = 1; else if ( circle.Position.X > hole.X ) playerInput.LeftStick.X = -1; break; } } } }