Exemplo n.º 1
0
        /// <summary>
        /// Intitialize a new session with the given level number of players and teams.
        /// </summary>
        /// <param name="levelIndex"></param>
        /// <param name="numPlayers"></param>
        public void Initialize(int levelIndex, int numPlayers, int numTeams)
        {
            ScriptMain.DebugPrint("Initializing a new session with {0} players and {1} total teams.", numPlayers, numTeams);

            LevelManager levelMgr = ScriptThread.GetOrAddExtension <LevelManager>();

            InitTeamConstantData(numTeams);

            current = new SessionInfo(levelIndex, numPlayers);

            levelMgr.DoLoadLevel(current.LevelIndex);

            for (int i = 0; i < numPlayers; i++)
            {
                TeamData team = FindFreeTeam();

                Player player = CreatePlayer(i, team.Index, i < 1);

                player.OnDead += OnPlayerDead;

                current.AddPlayer(i, team.Index, player);

                //ScriptMain.DebugPrint("Added a new player at slot '{0}' with name \"{1}\" teamIdx: {2}", i, player.Name, team.Index);
            }

            ScriptThread.SetVar("scr_activesession", true);
        }