private Texture2D DrawScores(List<ScoreEntry> scores, Difficulty difficulty, int index) { Shorewood.graphics.GraphicsDevice.SetRenderTarget(0, scoreTarget[index]); Shorewood.graphics.GraphicsDevice.Clear(Color.TransparentBlack); Shorewood.spriteBatch.Begin(); Vector2 position = Vector2.One * 10; StringBuilder scoreString = new StringBuilder(100); scoreString.Append(GetDifficultyString(difficulty)); Vector2 header = position; header.X += scoreWidth/2 - Shorewood.fonts[FontTypes.ScoreFont].MeasureString(scoreString).X / 2; Shorewood.spriteBatch.DrawString(Shorewood.fonts[FontTypes.ScoreFont], scoreString, header, Color.Black); position.Y += Shorewood.fonts[FontTypes.ScoreFont].MeasureString(scoreString).Y; int count = 0; foreach (var score in scores) { scoreString.Length = 0; GamerEntry entry = new GamerEntry(); entry.gamerTag = score.GamerTag; if (Gamers.Contains(entry)) { entry = Gamers[Gamers.IndexOf(entry)]; } //Shorewood.spriteBatch.Draw(entry.GamerPicture, position, Color.White); if (count % 2 == 0) { Shorewood.spriteBatch.Draw(highlightTexture, new Rectangle((int)position.X, (int)position.Y, scoreWidth, 33), new Color(Color.White,220)); } else { Shorewood.spriteBatch.Draw(highlightTexture, new Rectangle((int)position.X, (int)position.Y, scoreWidth, 33), new Color(Color.WhiteSmoke, 220)); } Shorewood.spriteBatch.Draw(entry.GamerPicture, position, null, Color.White, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 1); scoreString.Append(score.GamerTag); Shorewood.spriteBatch.DrawString(Shorewood.fonts[FontTypes.ScoreFont], scoreString, position + Vector2.UnitX * 35, Color.Black); scoreString.Length = 0; scoreString.Append(score.Score); Shorewood.spriteBatch.DrawString(Shorewood.fonts[FontTypes.ScoreFont], scoreString, position + Vector2.UnitX * (scoreWidth - Shorewood.fonts[FontTypes.ScoreFont].MeasureString(scoreString).X - 20), Color.Black); position.Y += 33; count++; } Shorewood.spriteBatch.End(); Shorewood.graphics.GraphicsDevice.SetRenderTarget(0, null); return scoreTarget[index].GetTexture(); }
public void GameOver(GameTime gameTime, object nothing) { isGameOver = true; Shorewood.gameState = GameState.GameOver; int score = gridRenderer.grid.currentScore; TimeSpan duration = Shorewood.gameplayTimer.ElapsedTime; ScoreEntry highScore = new ScoreEntry(); highScore.Difficulty = Shorewood.Difficulty; highScore.Duration = duration; highScore.Score = Shorewood.scoreBox.CurrentScore; #if XBOX if ((Gamer.SignedInGamers.Count > 0) && Gamer.SignedInGamers[Shorewood.mainPlayer] != null) { highScore.GamerTag = Gamer.SignedInGamers[Shorewood.mainPlayer].Gamertag; GamerEntry gamer = new GamerEntry(); gamer.GamerPicture = Gamer.SignedInGamers[Shorewood.mainPlayer].GetProfile().GamerPicture; gamer.gamerTag = highScore.GamerTag; if (!Shorewood.storage.HighScores.Gamers.Contains(gamer)) { Shorewood.storage.HighScores.Gamers.Add(gamer); } } #else highScore.GamerTag = "Zikomo"; #endif List<ScoreEntry> scores = Shorewood.storage.HighScores.GetList(Shorewood.Difficulty); scores.Add(highScore); scores.Sort(); if (scores.Count > 10) { scores.RemoveRange(10, scores.Count - 10); } Shorewood.storage.SaveHighScoresToDevice(); gameplayState = NormalGameplayState.GameOver; }