Exemple #1
0
    private IEnumerator Init()
    {
        GameObject host = null;

        while (host == null)
        {
            host = GameObject.Find("Host");
            yield return(new WaitForEndOfFrame());
        }
        while (this.seed == 0)
        {
            this.seed = host.GetComponent <RandomSeedSync>().seed;
            UnityEngine.Object.FindObjectOfType <GameConsole.Console>().UpdateValue("seed", this.seed.ToString());
        }
        if (!base.isLocalPlayer)
        {
            yield break;
        }
        yield return(new WaitForSeconds(2f));

        if (base.isServer)
        {
            if (ServerStatic.isDedicated)
            {
                ServerConsole.AddLog("Waiting for players..");
            }
            CursorManager.roundStarted = true;
            RoundStart rs = RoundStart.singleton;
            if (TutorialManager.status)
            {
                this.ForceRoundStart();
            }
            else
            {
                rs.ShowButton();
                int timeLeft   = 20;
                int maxPlayers = 1;
                while (rs.info != "started")
                {
                    if (maxPlayers > 1)
                    {
                        timeLeft--;
                    }
                    int count = PlayerManager.singleton.players.Length;
                    if (count > maxPlayers)
                    {
                        maxPlayers = count;
                        if (timeLeft < 5)
                        {
                            timeLeft = 5;
                        }
                        else if (timeLeft < 10)
                        {
                            timeLeft = 10;
                        }
                        else if (timeLeft < 15)
                        {
                            timeLeft = 15;
                        }
                        else
                        {
                            timeLeft = 20;
                        }
                        if (maxPlayers == NetworkManager.singleton.maxConnections)
                        {
                            timeLeft = 0;
                        }
                    }
                    if (timeLeft > 0)
                    {
                        this.CmdUpdateStartText(timeLeft.ToString());
                    }
                    else
                    {
                        this.ForceRoundStart();
                    }
                    yield return(new WaitForSeconds(1f));
                }
            }
            CursorManager.roundStarted = false;
            this.CmdStartRound();
            this.SetRandomRoles();
        }
        else
        {
            while (!host.GetComponent <CharacterClassManager>().roundStarted)
            {
                yield return(new WaitForEndOfFrame());
            }
            yield return(new WaitForSeconds(2f));

            if (this.curClass < 0)
            {
                this.CallCmdSuicide(default(PlayerStats.HitInfo));
            }
        }
        int iteration = 0;

        for (;;)
        {
            GameObject[] plys = PlayerManager.singleton.players;
            if (iteration >= plys.Length)
            {
                yield return(new WaitForSeconds(3f));

                iteration = 0;
            }
            try
            {
                plys[iteration].GetComponent <CharacterClassManager>().InitSCPs();
            }
            catch
            {
            }
            iteration++;
            yield return(new WaitForEndOfFrame());
        }
    }