/// <summary> /// Displays scores from previous matches /// </summary> /// <param name="stats">Score information</param> private void DisplayPreviousMatches_(List <IGrouping <DateTime, StatContent> > stats) { var ph = new ProfileHandler(); ph.Initialise(); // order by date var sorted = stats.OrderByDescending(s => s.Key).ToList(); var index = 0; // loop though controls - up to 5 for (; index < PreviousResults.Count() && index < sorted.Count(); index++) { // find active player var activePlayerId = _playerDisplaysInUse[_playerIndex].PlayerID(); var player = sorted[index].Where(s => s.GetPlayerId() == activePlayerId).FirstOrDefault(); // get other players who played var otherPlayers = sorted[index].Where(s => s.GetPlayerId() != activePlayerId); // work out the scores var plScore = player?.GetScore(); var maxScore = sorted[index].Max(s => s.GetScore()); var otherCharacters = new List <int>(); // get a list of the characters that were used by other players foreach (var p in otherPlayers) { var profile = ph.GetProfile(p.GetPlayerId()); if (profile != null) { otherCharacters.Add(profile.GetCharacterIndex()); } } // initialise controls PreviousResults[index].gameObject.SetActive(true); PreviousResults[index].SetData(sorted[index].Key, (int)plScore, otherCharacters, plScore == maxScore); } // hind unused controls for (; index < PreviousResults.Count(); index++) { PreviousResults[index].gameObject.SetActive(false); } }
/// <summary> /// Called when object is created /// </summary> private void Start() { // we want this to stay DontDestroyOnLoad(this); // easy access to this item Instance = this; // loop through the players and configure the pause request messages for (int i = 0; i < PausePopups.Length; i++) { // update the colour and the name on the popup PausePopups[i].GetComponentsInChildren <Image>()[1].color = ColourFetcher.GetColour(i); } EndFader.StartFade(1, 0, null); // load values _profileHandler.Initialise(); }
/// <summary> /// Displays high score data /// </summary> /// <param name="stats">The data to show</param> private void ShowHighscores_(List <StatContent> stats) { var ph = new ProfileHandler(); ph.Initialise(); var index = 0; for (; (index < stats.Count && index < HighScores.Length); index++) { HighScores[index].gameObject.SetActive(true); var profile = ph.GetProfile(stats[index].GetPlayerId()); if (profile != null) { HighScores[index].SetPlayerData(profile.GetProfileName(), stats[index].GetScore(), profile.GetCharacterIndex()); } } for (; index < HighScores.Length; index++) { HighScores[index].gameObject.SetActive(false); } }