private bool IsAlignedToLadder()
{
int playerOffset = ((int)position.X % Tile.Width) - Tile.Center;
if (Math.Abs(playerOffset) <= LadderAlignment &&
level.GetTileCollisionBelowPlayer(new Vector2(
this.position.X,
this.position.Y + 1)) == TileCollision.Ladder ||
level.GetTileCollisionBelowPlayer(new Vector2(
this.position.X,
this.position.Y - 1)) == TileCollision.Ladder)
{
// Align the player with the middle of the tile
position.X -= playerOffset;
return true;
}
else
{
return false;
}
}