コード例 #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 CancelTournament(string reason)
        {
            Scripting.ScriptManager.InvokeSub("OnTournamentCanceled", this, reason);

            for (int i = registeredMembers.Count - 1; i >= 0; i--)
            {
                WarpToHub(registeredMembers[i].Client);
                registeredMembers[i].Client.Player.Tournament        = null;
                registeredMembers[i].Client.Player.TournamentMatchUp = null;
                registeredMembers.RemoveAt(i);
            }
            TournamentManager.RemoveTournament(this);
        }