コード例 #1
0
    // LOGIC

    public void Initialize(string i_DatabasePath)
    {
        tnGameModesDatabase database = Resources.Load <tnGameModesDatabase>(i_DatabasePath);

        if (database != null)
        {
            for (int index = 0; index < database.count; ++index)
            {
                tnGameModeDataEntry entry = database.GetGameModeDataEntry(index);
                if (entry != null)
                {
                    tnGameModeDataDescriptor descriptor = entry.descriptor;
                    if (descriptor != null)
                    {
                        int            hash = StringUtils.GetHashCode(entry.id);
                        tnGameModeData data = new tnGameModeData(descriptor);
                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
    // CTOR

    public tnGameModeData(tnGameModeDataDescriptor i_Descriptor)
    {
        m_FieldsExcludersTags = new List <int>();

        if (i_Descriptor != null)
        {
            m_Name         = i_Descriptor.gameModeName;
            m_Descriptrion = i_Descriptor.description;

            m_CharacterPrefabPath = i_Descriptor.characterPrefabPath;
            m_MatchController     = i_Descriptor.multiplayerController;

            m_TeamsRange                = new IntRange(i_Descriptor.teamsRange.min, i_Descriptor.teamsRange.max);
            m_PlayersPerTeamRange       = new IntRange(i_Descriptor.playersPerTeamRange.min, i_Descriptor.playersPerTeamRange.max);
            m_OnlinePlayersPerTeamRange = new IntRange(i_Descriptor.onlinePlayersPerTeamRange.min, i_Descriptor.playersPerTeamRange.max);

            int optionsConfigId = StringUtils.GetHashCode(i_Descriptor.optionsConfigId);
            m_OptionsConfigId = optionsConfigId;

            int camerasSetId = StringUtils.GetHashCode(i_Descriptor.camerasSetId);
            m_CamerasSetId = camerasSetId;

            for (int tagIndex = 0; tagIndex < i_Descriptor.fieldsExcludersTagsCount; ++tagIndex)
            {
                string tag = i_Descriptor.GetFieldExcluderTag(tagIndex);
                if (tag != "" && tag != "NULL")
                {
                    int hash = StringUtils.GetHashCode(tag);
                    m_FieldsExcludersTags.Add(hash);
                }
            }

            m_Hidden = i_Descriptor.hidden;
        }
    }