private void shootRocket(Map map)
{
if (mCurrentState == State.Walking)
{
//Check if there are any invisible rockets in the list
bool createNewRocket = true;
Vector2 rocketDirection;
if (mDirection.X == MOVE_LEFT)
{
rocketDirection = new Vector2(MOVE_LEFT, 0);
}
else
{
rocketDirection = new Vector2(MOVE_RIGHT, 0);
}
Vector2 rocketStartPosition =
map.screenToWorld(new Vector2(mPosition.X + rocketDirection.X * X_FRAME_WIDTH + X_ROCKET_OFFSET,
mPosition.Y + Y_ROCKET_OFFSET));
Vector2 rocketSpeed = new Vector2(ROCKET_SPEED, 0);
foreach (Rocket aRocket in mRockets)
{
if (!aRocket.visible)
{
createNewRocket = false;
aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
break;
}
}
if (createNewRocket)
{
Rocket aRocket = new Rocket();
aRocket.LoadContent(mContentManager);
aRocket.Fire(rocketStartPosition, rocketSpeed, rocketDirection);
mRockets.Add(aRocket);
}
}
}