private void DrawLevelPanel(SpriteBatch spriteBatch)
{
var i = 0;
var shiftValue = 0;
var drawNumbers = true;
//Find how much to shift to keep everything on screen correctly
while (_mLevelRegions[_mCurrentWorld * 6].Bottom - shiftValue > 15 * (_mLevelPanel.Top + _mLevelPanel.Height) / 16)
shiftValue += _mLevelRegions[_mCurrentWorld * 6].Height;
foreach (var rect in _mLevelRegions)
{
rect.Offset(0, -shiftValue);
//Draws the background box and world title for this world if the current item drawing is the first item in the world
if (i % 6 == 0)
{
//Draws background
var background = new Rectangle(rect.Left, rect.Top, _mLevelPanel.Right - rect.Left, rect.Bottom - rect.Top - (int)((rect.Bottom - rect.Top) * .2f));
spriteBatch.Draw(_mWorldBackground[i / 6][Convert.ToInt32(i / 6 != _mCurrentWorld)], background, Color.White);
//Draws world name background and text
Vector2 worldText = _mFont.MeasureString(_mWorlds[i / 6]);
var textBox = new Rectangle(background.Center.X - _mLongestName / 2 - _mLongestName / 16, (int)(background.Top - worldText.Y - worldText.Y / 16), _mLongestName + _mLongestName / 8, (int)(worldText.Y + worldText.Y / 8));
spriteBatch.Draw(_mWorldTitleBox[i / 6][Convert.ToInt32(i / 6 != _mCurrentWorld)], textBox, Color.White);
spriteBatch.DrawString(_mFont, _mWorlds[i / 6], new Vector2(textBox.Center.X - worldText.X / 2, textBox.Center.Y - worldText.Y / 2), Color.White);
if (TrialMode && i > 6)
{
spriteBatch.Draw(_mLock, background, Color.White);
drawNumbers = false;
worldText = _mFontBig.MeasureString("World Locked: You need to buy the game to play");
spriteBatch.DrawString(_mFontBig, "World Locked: You need to buy the game to play",
new Vector2(background.Center.X - worldText.X / 2, background.Center.Y - worldText.Y / 2), Color.White);
}
//If the world is not unlocked, than cover it up with the lock
else if (!_mLevels[i].Unlocked)
{
spriteBatch.Draw(_mLock, background, Color.White);
drawNumbers = false;
if (i / 6 != 8)
{
worldText = _mFontBig.MeasureString("World Locked: You need " + (i / 6 * 30 - _mStarCount) + " more Stars to Unlock");
spriteBatch.DrawString(_mFontBig, "World Locked: You need " + (i / 6 * 30 - _mStarCount) + " more Stars to Unlock",
new Vector2(background.Center.X - worldText.X / 2, background.Center.Y - worldText.Y / 2), Color.White);
}
else
{
worldText = _mFontBig.MeasureString("World Locked: You need " + (480 - _mStarCount) + " more Stars to Unlock");
spriteBatch.DrawString(_mFontBig, "World Locked: You need " + (480 - _mStarCount) + " more Stars to Unlock",
new Vector2(background.Center.X - worldText.X / 2, background.Center.Y - worldText.Y / 2), Color.White);
}
}
}
//Means this world is locked so don't draw the numbers
if (!drawNumbers) { i++; continue; }
//Draw numbers
Vector2 size = _mFont.MeasureString(_mLevels[i].Name);
if (i % 6 != _mCurrentIndex || i / 6 != _mCurrentWorld)
spriteBatch.Draw(_mUnselected[i % 6], rect, Color.White);
else
spriteBatch.Draw(_mSelected[i % 6, _number], rect, Color.White);
//Draw 10th star
if (_mLevels[i].TenthStar())
spriteBatch.Draw(_mStar, new Vector2(rect.Right - _mStar.Width, rect.Top), Color.White);
if (i == 48)
{
size = _mFontBig.MeasureString("Congrats Travis, for winning the Naming Contest!!");
spriteBatch.DrawString(_mFontBig, "Congrats Travis, for winning the Naming Contest!!",
new Vector2(rect.Right + size.X/32, rect.Center.Y - 2*size.Y / 3), Color.White);
spriteBatch.DrawString(_mFontBig, "Congrats Travis, for winning the Naming Contest!!",
new Vector2(rect.Right + size.X / 32 + 2, rect.Center.Y - 2 * size.Y / 3 + 2), Color.CornflowerBlue);
}
i++;
}
DrawInfoBar(spriteBatch, shiftValue);
}