Example #1
0
        void assignTeam(int id)
        {
            Debug.Assert(PlayerExists(id));

            if (players[id].Team != CTFTeam.None)
            {
                return;
            }

            bool redLTblue, blueLTred;

            if (CTFConfig.AssignTeamIgnoreOffline)
            {
                redLTblue = RedOnline < BlueOnline;
                blueLTred = BlueOnline < RedOnline;
            }
            else
            {
                redLTblue = RedPlayer < BluePlayer;
                blueLTred = BluePlayer < RedPlayer;
            }

            if (redLTblue)
            {
                players[id].Team = CTFTeam.Red;
                ++RedPlayer;
            }
            else if (blueLTred)
            {
                players[id].Team = CTFTeam.Blue;
                ++BluePlayer;
            }
            else
            {
                int randnum = CTFUtils.Random(2);
                if (randnum == 0)
                {
                    players[id].Team = CTFTeam.Red;
                    ++RedPlayer;
                }
                else
                {
                    players[id].Team = CTFTeam.Blue;
                    ++BluePlayer;
                }
            }
        }
Example #2
0
        public void DecidePositions()
        {
            int f1x = mapMiddle - flagDistance;
            int f1y = FindGround(f1x) - 1;

            int f2x = mapMiddle + flagDistance;
            int f2y = FindGround(f2x) - 1;

            int s1x = mapMiddle - spawnDistance;
            int s1y = FindGround(s1x) - 2;

            int s2x = mapMiddle + spawnDistance;
            int s2y = FindGround(s2x) - 2;

            if (CTFUtils.Random(2) == 0)
            {
                redFlag.X   = f1x;
                redFlag.Y   = f1y;
                redSpawn.X  = s1x;
                redSpawn.Y  = s1y;
                blueFlag.X  = f2x;
                blueFlag.Y  = f2y;
                blueSpawn.X = s2x;
                blueSpawn.Y = s2y;
            }
            else
            {
                redFlag.X   = f2x;
                redFlag.Y   = f2y;
                redSpawn.X  = s2x;
                redSpawn.Y  = s2y;
                blueFlag.X  = f1x;
                blueFlag.Y  = f1y;
                blueSpawn.X = s1x;
                blueSpawn.Y = s1y;
            }
        }