protected virtual void OnPlayerScored(PlayerScoreEventArgs e) { try { if (e.IsThereAWinner) { var potentialPlayerWinning = CurrentScores.First(c => c.Player == e.Platformer2DUserControl.m_PlayerData); potentialPlayerWinning.CurrentScore++; e.PlayerScore = potentialPlayerWinning.CurrentScore; } } catch (Exception ex) { ex.Log("InScoreManager when checking for winner"); throw; } try { EventHandler <PlayerScoreEventArgs> handler = PlayerScored; if (handler != null) { handler(this, e); } } catch (Exception ex) { ex.Log(); throw; } }
public void FollowScoreOf(IPlatformer2DUserControl control, HPScript hpScript) { CurrentScores.Add(new PlayerScoreTracker { CurrentScore = 0, Player = control.m_PlayerData }); var data = new ScoreData() { HpScript = hpScript, Platformer2DUserControl = control }; data.HpScript.Dead += HpScript_Dead; ScoreDatas.Add(data); }
/// <summary> /// Adds the highscore to the save file, and saves it to the disk /// </summary> /// <param name="highscore">Highscore to add</param> public void AddHighscore(Highscore highscore) { CurrentScores.Add(highscore); SaveFile(); }
public PlayerScoreTracker GetScoreData(PlayerData player) { var ret = CurrentScores.FirstOrDefault(c => c.Player == player); return(ret); }