private void DrawButton(SpriteBatch spriteBatch, Vector2 position, Rectangle sprite, string label, float alpha, bool labelWithShadow) { spriteBatch.Draw(_buttonsTexture, position, sprite, Color.White * alpha); if (label != "") { var h = SceneManager.Instance.GameFontSmall.MeasureString(label).Y; var labelPosition = position + new Vector2(18, (15 - h) / 2); if (labelWithShadow) spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontSmall, label, labelPosition, Color.White * alpha); else spriteBatch.DrawString(SceneManager.Instance.GameFontSmall, label, labelPosition, Color.White * alpha); } }
public override void Draw(SpriteBatch spriteBatch, ViewportAdapter viewportAdapter) { base.Draw(spriteBatch, viewportAdapter); var screenSize = SceneManager.Instance.VirtualSize; var gameFont = SceneManager.Instance.GameFont; spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: viewportAdapter.GetScaleMatrix()); // Background spriteBatch.Draw(_backgroundTexture, _backgroundTexture.Bounds, Color.White); // Title var titleString = _titleStrings[SceneManager.Instance.TypeOfSceneSaves]; var titleX = (SceneManager.Instance.VirtualSize.X - SceneManager.Instance.GameFontBig.MeasureString(titleString).X) / 2; spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontBig, titleString, new Vector2(titleX, 10), Color.White); // Slots for (var i = 0; i < 3; i++) { var slotPosition = _slotsPosition[i].Location.ToVector2(); // Check if the slot isn't empty if (_gameSaves[i].StagesCompleted > 0) { // Pete Head if (_slotIndex == i) { _peteAnimatedSprite.Position = slotPosition + _peteHeadPosition; _peteAnimatedSprite.Draw(spriteBatch); } else { spriteBatch.Draw(_peteSpritesheet, slotPosition + _peteHeadPosition, _peteDefaultFrame, Color.White); } // Save Name spriteBatch.DrawString(gameFont, "SAVE NAME", slotPosition + _namePosition, _fontColor); // Stages var divisorPosition = Vector2.Zero; for (var j = 0; j < _gameSaves[i].StagesCompleted; j++) { var markPosition = slotPosition + _stagesPosition + ((_stagePeteMarkFrame.Width + 4) * j * Vector2.UnitX); spriteBatch.Draw(_stageSpritesheet, markPosition, _stagePeteMarkFrame, Color.White); if (j < SceneManager.MaxLevels - 1) { divisorPosition = markPosition + (_stagePeteMarkFrame.Width + 1) * Vector2.UnitX + (9 * Vector2.UnitY); spriteBatch.Draw(_stageSpritesheet, divisorPosition, _stageDivisorFrame, Color.White); } } if (_gameSaves[i].StagesCompleted < SceneManager.MaxLevels) { var nextMarkPos = (divisorPosition == Vector2.Zero) ? (slotPosition + _stagesPosition) : (divisorPosition - (9 * Vector2.UnitY) + (3 * Vector2.UnitX)); if (_slotIndex == i) { _nextStageMarkAnimatedSprite.Position = nextMarkPos; _nextStageMarkAnimatedSprite.Draw(spriteBatch); } else { spriteBatch.Draw(_stageSpritesheet, nextMarkPos, _stageNextMarkFrame, Color.White); } } // Lives var lives = _gameSaves[i].Lives; var livesWidth = (lives * _lifeFrame.Width) + (lives - 1); var livesPosition = slotPosition + (_slotsPosition[i].Width - livesWidth - _livesPosition.X) * Vector2.UnitX + _livesPosition.Y * Vector2.UnitY; for (var j = 0; j < lives; j++) { var lifePosition = livesPosition + ((_lifeFrame.Width + 1) * j * Vector2.UnitX); spriteBatch.Draw(_iconsSpritesheet, lifePosition, _lifeFrame, Color.White); } // Hearts var hearts = _gameSaves[i].Hearts; var heartsWidth = (hearts * _heartFrame.Width) + (hearts - 1) * 5; var heartsPosition = slotPosition + (_slotsPosition[i].Width - heartsWidth - _heartsPosition.X) * Vector2.UnitX + _heartsPosition.Y * Vector2.UnitY; for (var j = 0; j < hearts; j++) { var heartPosition = heartsPosition + ((_heartFrame.Width + 5) * j * Vector2.UnitX); spriteBatch.Draw(_iconsSpritesheet, heartPosition, _heartFrame, Color.White); } // Ammo spriteBatch.Draw(_iconsSpritesheet, slotPosition + _ammoPosition, _ammoFrame, Color.White); spriteBatch.DrawString(gameFont, _gameSaves[i].Ammo.ToString(), slotPosition + _ammoTextPosition, _fontColor); // Coins spriteBatch.Draw(_iconsSpritesheet, slotPosition + _coinsPosition, _coinFrame, Color.White); spriteBatch.DrawString(gameFont, _gameSaves[i].Coins.ToString(), slotPosition + _coinsTextPosition, _fontColor); } else { // Empty slot text var emptySlotTextSize = gameFont.MeasureString(EmptySlotText); var emptyPosition = new Vector2(slotPosition.X + (_slotsPosition[i].Width - emptySlotTextSize.X) / 2, slotPosition.Y + (_slotsPosition[i].Height - emptySlotTextSize.Y) / 2); spriteBatch.DrawString(gameFont, EmptySlotText, emptyPosition, _fontColor); } } IconsManager.Instance.DrawRightArrow(spriteBatch, _arrowPosition + _arrowPositionInc * Vector2.UnitY, false); var xOffset = SceneManager.Instance.GameFontSmall.MeasureString(ConfirmButtonLabel).X + 30; IconsManager.Instance.DrawActionButton(spriteBatch, new Vector2(5, screenSize.Y - 18), false, ConfirmButtonLabel, 1.0f, true); IconsManager.Instance.DrawCancelButton(spriteBatch, new Vector2(xOffset, screenSize.Y - 18), false, CancelButtonLabel, 1.0f, true); if (_loadingVisible) { spriteBatch.Draw(_loadingBackgroundTexture, new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.White * 0.5f); _loadingAnimatedSprite.Draw(spriteBatch); } spriteBatch.End(); }
public void Draw(SpriteBatch spriteBatch) { if (!_paused) return; spriteBatch.Draw(_backgroundTexture, _backgroundDrawArea, Color.White * 0.5f); spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontBig, Title, _pausePosition, Color.White); for (var i = 0; i < _menu.Length; i++) { var position = new Vector2(_menuItemsX[i], _menuY + (i * SceneManager.Instance.GameFont.LineHeight)); spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFont, _menu[i], position, Color.White); } spriteBatch.Draw(_cursor, new Vector2(_menuItemsX[_index] - 16, _menuY + (_index * SceneManager.Instance.GameFont.LineHeight) - 1), Color.White); }
public void Draw(SpriteBatch spriteBatch) { var screenSize = SceneManager.Instance.VirtualSize; var fontBig = SceneManager.Instance.GameFontBig; var font = SceneManager.Instance.GameFont; var format = "{0}/{1}"; spriteBatch.Draw(_background, new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.White * 0.5f); var coinsLPos = new Vector2(_rowsInnerPositionsLeft[0, Current], 60); var coinsRPos = new Vector2(_rowsInnerPositionsRight[0], 60); var heartsLPos = new Vector2(_rowsInnerPositionsLeft[1, Current], 85); var heartsRPos = new Vector2(_rowsInnerPositionsRight[1], 85); var enemiesLPos = new Vector2(_rowsInnerPositionsLeft[2, Current], 110); var enemiesRPos = new Vector2(_rowsInnerPositionsRight[2], 110); var timeLPos = new Vector2(_rowsInnerPositionsLeft[3, Current], 135); var timeRPos = new Vector2(_rowsInnerPositionsRight[3], 135); spriteBatch.DrawTextWithShadow(fontBig, _completed ? TitleCompleted : TitleFailed, _titlePosition, Color.White); var coinsStr = String.Format(format, _values[0, 0], _data.MaxCoins); var coinsColor = CalculateColor(_values[0, 0], _data.MaxCoins); spriteBatch.DrawTextWithShadow(font, CoinsEarned, coinsLPos, Color.White); spriteBatch.DrawRightText(font, coinsStr, coinsRPos, coinsColor, Color.Black); var heartsColor = CalculateColor(_values[1, 0], 0); spriteBatch.DrawTextWithShadow(font, HeartsLost, heartsLPos, Color.White); spriteBatch.DrawRightText(font, _values[1, 0].ToString(), heartsRPos, heartsColor, Color.Black); var enemiesStr = String.Format(format, _values[2, 0], _data.MaxEnemies); var enemiesColor = CalculateColor(_values[2, 0], _data.MaxEnemies); spriteBatch.DrawTextWithShadow(font, EnemiesDefeated, enemiesLPos, Color.White); spriteBatch.DrawRightText(font, enemiesStr, enemiesRPos, enemiesColor, Color.Black); var timeColor = CalculateColor(_timeValues[0], _data.MaxTime); spriteBatch.DrawTextWithShadow(font, Time, timeLPos, Color.White); spriteBatch.DrawRightText(font, FormatTime(_timeValues[0]), timeRPos, timeColor, Color.Black); if (_phase >= 1) { spriteBatch.DrawTextWithShadow(font, _rankSentences[_rank], _rankSentencePosition, Color.White * _rankSentenceAlpha); if (_rank == "S") ((AnimatedSprite)_rankSprite).Draw(spriteBatch); else _rankSprite.Draw(spriteBatch); } IconsManager.Instance.DrawActionButton(spriteBatch, new Vector2(5, screenSize.Y - 40), false, "Continue", _buttonsAlpha, true); IconsManager.Instance.DrawCancelButton(spriteBatch, new Vector2(5, screenSize.Y - 20), false, "Again", _buttonsAlpha, true); }