Example #1
0
    // Runs EITHER player 1 or player 2 from whatever
    // index controller you want (provided its still connected!)
    private void RunPlayerFromController( PlayerIndex pNum, Ship playerShip )
    {
        // player can't control when in hyperspace
        if( playerShip.state != ShipState.Hyperspace )
        {
          if( IsPressed( pNum, Buttons.LeftShoulder ) )
        playerShip.TradeShieldForEnergy();

          if( IsPressed( pNum, Buttons.Y ) )
        playerShip.BeginHyperspace();

          if( IsPressed( pNum, Buttons.RightShoulder ) )
        playerShip.TradeEnergyForShield();

          if( IsPressed( pNum, Buttons.DPadLeft ) )
        playerShip.RotateLeft();

          if( IsPressed( pNum, Buttons.B ) )
        playerShip.IncreaseThrust();

          if( IsPressed( pNum, Buttons.DPadRight ) )
        playerShip.RotateRight();

          if( JustPressed( pNum, Buttons.X ) )
        playerShip.ShootPhasors();

          if( IsPressed( pNum, Buttons.RightTrigger ) )
        playerShip.Cloak();

          if( JustPressed( pNum, Buttons.A ) )
        playerShip.ShootTorpedos();
        }
    }