private async void LoadHighScoresAsync() { try { var tmpImages = new List<ImageFile>(); var i = 1; var position = new Vector2(0, _highScores.Position.Y + (_highScores.SourceRectangle.Height * _highScores.Scale.Y) + 20); var scores = GameManager.MobileService.GetTable<ScoreItem>().Take(10).OrderByDescending(x => x.HighScore).ToListAsync(); foreach (var score in await scores) { var img = new ImageFile { Text = String.Format("{0} - {1}: {2}", i, score.PlayerName, score.HighScore) }; img.LoadContent(Content); img.Position = position; img.CenterX(GameManager.IndependentResolution.VirtualResolution.X); tmpImages.Add(img); i++; position.Y = img.Position.Y + (img.SourceRectangle.Height*img.Scale.Y); } _scoresImageFiles = tmpImages; } catch (Exception exception) { Debug.WriteLine("Error trying to load highscores: {0}", exception.StackTrace); var cantLoadScoresImage = new ImageFile {Text = Strings.HIGH_SCORES_NOT_AVAILABLE}; cantLoadScoresImage.LoadContent(Content); cantLoadScoresImage.CenterX(GameManager.IndependentResolution.VirtualResolution.X); _scoresImageFiles = new List<ImageFile>{cantLoadScoresImage}; } }
private void AddLoadingImage() { var img = new ImageFile {Text = Strings.LOADING}; var fadeEffect = new FadeImageEffect(); img.LoadContent(Content); img.Position = new Vector2(0, _highScores.Position.Y + (_highScores.SourceRectangle.Height * _highScores.Scale.Y) + 20); img.CenterX(GameManager.IndependentResolution.VirtualResolution.X); img.ActivateEffect(fadeEffect); _scoresImageFiles.Add(img); }