private tnTeamDescription CreateTeam(int i_TeamKey, int i_TeamSize, Color i_TeamColor)
        {
            tnTeamData teamData = tnGameData.GetTeamDataMain(i_TeamKey);

            if (teamData == null || i_TeamSize <= 0)
            {
                return(null);
            }

            tnTeamDescription teamDescription = new tnTeamDescription();

            teamDescription.SetTeamId(i_TeamKey);
            teamDescription.SetTeamColor(i_TeamColor);

            List <int> teamLineup = teamData.GetDefaultLineUp(i_TeamSize);

            for (int characterIndex = 0; characterIndex < teamLineup.Count; ++characterIndex)
            {
                int characterKey = teamLineup[characterIndex];

                tnCharacterDescription characterDescription = new tnCharacterDescription();
                characterDescription.SetCharacterId(characterKey);
                characterDescription.SetPlayerId(StringUtils.s_NULL);
                characterDescription.SetSpawnOrder(characterIndex);

                teamDescription.AddCharacterDescription(characterDescription);
            }

            return(teamDescription);
        }
コード例 #2
0
        public override void OnEnter()
        {
            tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>();

            if (teamsModule == null)
            {
                teamsModule = GameModulesManager.AddModuleMain <tnTeamsModule>();
                teamsModule.Clear();
            }

            tnTeamDescription team = new tnTeamDescription();

            team.SetTeamId(id.Value);
            team.SetTeamColor(color.Value);

            int charactersCount = characters.Length;

            for (int characterIndex = 0; characterIndex < charactersCount; ++characterIndex)
            {
                tnCharacterEntry entry = characters[characterIndex];
                if (entry != null)
                {
                    FsmString characterId       = entry.characterId;
                    FsmInt    onlinePlayerIndex = entry.onlinePlayerIndex;
                    FsmString playerId          = entry.playerId;
                    FsmInt    spawnOrder        = entry.spawnOrder;

                    if (characterId != null && !characterId.IsNone && onlinePlayerIndex != null && !onlinePlayerIndex.IsNone && playerId != null && !playerId.IsNone && spawnOrder != null && !spawnOrder.IsNone)
                    {
                        tnCharacterDescription character = new tnCharacterDescription();

                        character.SetCharacterId(characterId.Value);

                        character.SetOnlinePlayerIndex(onlinePlayerIndex.Value);

                        character.SetPlayerId(playerId.Value);
                        character.SetSpawnOrder(spawnOrder.Value);

                        team.AddCharacterDescription(character);
                    }
                }
            }

            teamsModule.AddTeamDescription(team);

            Finish();
        }
コード例 #3
0
    private void Internal_AddTeamB(tnTeamsModule i_TeamsModule, int i_CharacterCount)
    {
        if (i_TeamsModule == null)
        {
            return;
        }

        tnTeamDescription teamDescription = new tnTeamDescription();

        string teamId = GetTeamB();

        teamDescription.SetTeamId(teamId);

        Color teamColor = GetTeamBColor();

        teamDescription.SetTeamColor(teamColor);

        if (i_CharacterCount >= 0)
        {
            tnTeamData teamData = tnGameData.GetTeamDataMain(teamId);
            if (teamData != null)
            {
                int characterCount = Mathf.Min(i_CharacterCount, teamData.charactersCount);
                for (int index = 0; index < characterCount; ++index)
                {
                    tnCharacterDescription characterDescription = new tnCharacterDescription();
                    characterDescription.SetCharacterId(teamData.GetCharacterKey(index));
                    characterDescription.SetSpawnOrder(index);

                    if (m_AllHumans)
                    {
                        characterDescription.SetPlayerId(GetPlayerIdByIndex(index + characterCount));
                    }

                    teamDescription.AddCharacterDescription(characterDescription);
                }
            }
        }

        i_TeamsModule.AddTeamDescription(teamDescription);
    }
    private void SetupTeamB(tnTeamsModule i_Module)
    {
        if (m_TeamB == null)
        {
            return;
        }

        tnTeamDescription teamDescription = new tnTeamDescription();

        // Add real players.

        for (int index = 0; index < m_TeamB.entriesCount; ++index)
        {
            GridEntry gridEntry = m_TeamB.GetEntryByIndex(index);

            if (gridEntry == null)
            {
                continue;
            }

            bool present = (gridEntry.device != null);
            if (present)
            {
                int playerId = gridEntry.device.playerId;

                tnCharacterDescription characterDescription = new tnCharacterDescription();
                characterDescription.SetPlayerId(playerId);

                teamDescription.AddCharacterDescription(characterDescription);

                LogManager.Log(this, LogContexts.FSM, "Added character to Team A [Real player]");
            }
        }

        // Add bots.

        for (int index = 0; index < m_TeamB.entriesCount; ++index)
        {
            GridEntry gridEntry = m_TeamB.GetEntryByIndex(index);

            if (gridEntry == null)
            {
                continue;
            }

            bool present = (gridEntry.isBot);
            if (present)
            {
                tnCharacterDescription characterDescription = new tnCharacterDescription();
                characterDescription.SetPlayerId(Hash.s_NULL);

                teamDescription.AddCharacterDescription(characterDescription);

                LogManager.Log(this, LogContexts.FSM, "Added character to Team A [BOT]");
            }
        }

        // Add team description.

        i_Module.AddTeamDescription(teamDescription);
    }