internal void MatchUpComplete(MatchUp matchUp) { activeMatchups.Remove(matchUp); if (activeMatchups.Count == 0) { // All match-ups have been completed, and winners were determined int remainingPlayersCount = CountRemainingPlayers() + 1; if (remainingPlayersCount == 1) { // Only one player left, so this player wins the tournament! TournamentMember winner = null; // Find the winning player instance for (int i = 0; i < registeredMembers.Count; i++) { if (registeredMembers[i].Active) { winner = registeredMembers[i]; } } if (winner != null) { TournamentComplete(winner); } } else if (remainingPlayersCount > 1) { // We have more than one player, continue the match-ups Scripting.ScriptManager.InvokeSub("OnTournamentRoundComplete", this); } } }
public void StartRound(MatchUpRules matchUpRules) { if (!tournamentStarted) { tournamentStarted = true; } bool evenPlayerCount = (CountRemainingPlayers() % 2 == 0); TournamentMemberCollection membersWaitList = registeredMembers.Clone() as TournamentMemberCollection; // Remove inactive players from wait list for (int i = membersWaitList.Count - 1; i >= 0; i--) { if (membersWaitList[i].Active == false) { membersWaitList.RemoveAt(i); } } if (!evenPlayerCount) { int skipIndex = MathFunctions.Rand(0, membersWaitList.Count); membersWaitList.RemoveAt(skipIndex); } activeMatchups.Clear(); // Continue making match-ups until all players have been accounted for while (membersWaitList.Count > 0) { int playerOneIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerOne = membersWaitList[playerOneIndex]; membersWaitList.RemoveAt(playerOneIndex); int playerTwoIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerTwo = membersWaitList[playerTwoIndex]; membersWaitList.RemoveAt(playerTwoIndex); MatchUp matchUp = new MatchUp(GenerateUniqueMatchUpID(), this, playerOne, playerTwo); matchUp.Rules = matchUpRules; activeMatchups.Add(matchUp); int combatMapIndex = MathFunctions.Rand(0, combatMaps.Count); InstancedMap iMap = MapCloner.CreateInstancedMap(MapManager.RetrieveMap(combatMaps[combatMapIndex])); matchUp.StartMatchUp(iMap); } }
internal void MatchUpComplete(MatchUp matchUp) { this.activeMatchups.Remove(matchUp); if (this.activeMatchups.Count == 0) { // All match-ups have been completed, and winners were determined int remainingPlayersCount = CountRemainingPlayers() + 1; if (remainingPlayersCount == 1) { // Only one player left, so this player wins the tournament! TournamentMember winner = null; // Find the winning player instance for (int i = 0; i < registeredMembers.Count; i++) { if (registeredMembers[i].Active) { winner = registeredMembers[i]; } } if (winner != null) { TournamentComplete(winner); } } else if (remainingPlayersCount > 1) { // We have more than one player, continue the match-ups Scripting.ScriptManager.InvokeSub("OnTournamentRoundComplete", this); } } }
public void StartRound(MatchUpRules matchUpRules) { if (!tournamentStarted) { tournamentStarted = true; } bool evenPlayerCount = (CountRemainingPlayers() % 2 == 0); TournamentMemberCollection membersWaitList = registeredMembers.Clone() as TournamentMemberCollection; // Remove inactive players from wait list for (int i = membersWaitList.Count - 1; i >= 0; i--) { if (membersWaitList[i].Active == false) { membersWaitList.RemoveAt(i); } } if (!evenPlayerCount) { int skipIndex = MathFunctions.Rand(0, membersWaitList.Count); membersWaitList.RemoveAt(skipIndex); } this.activeMatchups.Clear(); // Continue making match-ups until all players have been accounted for while (membersWaitList.Count > 0) { int playerOneIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerOne = membersWaitList[playerOneIndex]; membersWaitList.RemoveAt(playerOneIndex); int playerTwoIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerTwo = membersWaitList[playerTwoIndex]; membersWaitList.RemoveAt(playerTwoIndex); MatchUp matchUp = new MatchUp(GenerateUniqueMatchUpID(), this, playerOne, playerTwo); matchUp.Rules = matchUpRules; this.activeMatchups.Add(matchUp); int combatMapIndex = MathFunctions.Rand(0, combatMaps.Count); InstancedMap iMap = MapCloner.CreateInstancedMap(MapManager.RetrieveMap(combatMaps[combatMapIndex])); matchUp.StartMatchUp(iMap); } }