static void onMatchStatsCompleted(MatchStatsCompletedArgs e) { EventHandler handler = MatchStatsCompleted; if (MatchStatsCompleted != null) { MatchStatsCompleted(handler, e); } }
public static void HandleLevelLoad(byte[] buffer) { string s = ASCIIEncoding.ASCII.GetString(buffer); if (s == "mechlab") { if (matchActive) { if (friendlyList == null || enemyList == null || friendlyList.Count == 0 || enemyList.Count == 0) { return; } matchActive = false; foreach (MatchStat m in friendlyList) { if (m.status == 0) { allFriendsKilled = false; break; } } foreach (MatchStat m in enemyList) { if (m.status == 0) { allEnemiesKilled = false; break; } } if (allEnemiesKilled || allFriendsKilled) { playerStat.victoryType = "destruction"; } else { playerStat.victoryType = "capture"; } playerStat.time = matchEndTime; playerStat.matchType = activeMatchType; playerStat.level = activeLevelName; foreach (MatchStat m in friendlyList) { if (m.name == playerName) { playerStat.mech = m.mech; playerStat.status = m.status; } m.time = matchEndTime; m.victory = playerStat.victory; m.victoryType = playerStat.victoryType; m.level = activeLevelName; m.matchType = activeMatchType; } foreach (MatchStat m in enemyList) { if (playerStat.victory == 2) { m.victory = 1; } else if (playerStat.victory == 1) { m.victory = 2; } else { m.victory = playerStat.victory; } m.time = matchEndTime; m.victoryType = playerStat.victoryType; m.level = activeLevelName; m.matchType = activeMatchType; } LogCSV(); var matchStatsCompletedArgs = new MatchStatsCompletedArgs(); matchStatsCompletedArgs.MatchStats = friendlyList.Concat(enemyList).ToList(); onMatchStatsCompleted(matchStatsCompletedArgs); //reset all variables in preparation for next match matchEndTime = DateTime.MaxValue; activeLevelName = ""; team1.Clear(); team2.Clear(); playerStat = new PlayerStat(); friendlyList.Clear(); enemyList.Clear(); allEnemiesKilled = true; allFriendsKilled = true; } } else { matchActive = true; activeLevelName = s; playerStat.level = s; } //Log.LogMessage(string.Format("Level loading: {0}", s)); }