예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }