// LOGIC

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

        if (database != null)
        {
            for (int index = 0; index < database.stadiumsCount; ++index)
            {
                tnStadiumDataEntry entry = database.GetStadiumDataEntry(index);
                if (entry != null)
                {
                    string key = entry.id;
                    tnStadiumDataDescriptor descriptor = entry.descriptor;
                    if (key != "" && descriptor != null)
                    {
                        int           hash = StringUtils.GetHashCode(key);
                        tnStadiumData data = new tnStadiumData(descriptor);

                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
Пример #2
0
    // CTOR

    public tnStadiumData(tnStadiumDataDescriptor i_Descriptor)
    {
        m_Tags = new List <int>();

        m_ScorePanelsPrefabsPaths = new Dictionary <int, string>();

        if (i_Descriptor != null)
        {
            m_Name = i_Descriptor.stadiumName;

            m_Description = i_Descriptor.description;

            m_SceneName      = i_Descriptor.sceneName;
            m_GoalPrefabPath = i_Descriptor.goalPrefabPath;

            m_Icon = i_Descriptor.icon;

            m_HiddenOnline = i_Descriptor.hiddenOnline;

            int cameraId = StringUtils.GetHashCode(i_Descriptor.cameraId);
            m_CameraId = cameraId;

            m_TeamSize       = new IntRange(i_Descriptor.minTeamSize, i_Descriptor.maxTeamSize);
            m_OnlineTeamSize = new IntRange(i_Descriptor.minOnlineTeamSize, i_Descriptor.maxOnlineTeamSize);

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

            foreach (string id in i_Descriptor.scorePanelsPrefabsPathsKeys)
            {
                string path = "";
                if (i_Descriptor.TryGetScorePanelPrefabPath(id, out path))
                {
                    int hash = StringUtils.GetHashCode(id);
                    m_ScorePanelsPrefabsPaths.Add(hash, path);
                }
            }
        }
    }
    // UTILS

    private int GetMinPlayers(string i_StadiumId)
    {
        tnStadiumsDatabase stadiumDatabase = Resources.Load <tnStadiumsDatabase>("Database/Game/StadiumsDatabase");

        if (stadiumDatabase == null)
        {
            return(0);
        }

        for (int index = 0; index < stadiumDatabase.stadiumsCount; ++index)
        {
            tnStadiumDataEntry entry = stadiumDatabase.GetStadiumDataEntry(index);
            if (entry.id == i_StadiumId)
            {
                tnStadiumDataDescriptor stadiumDataDescriptor = entry.descriptor;
                if (stadiumDataDescriptor != null)
                {
                    return(stadiumDataDescriptor.minTeamSize);
                }
            }
        }

        return(0);
    }