Пример #1
0
    // LOGIC

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

        if (database != null)
        {
            for (int index = 0; index < database.teamsCount; ++index)
            {
                tnTeamDataEntry entry = database.GetTeamDataEntry(index);
                if (entry != null)
                {
                    string key = entry.id;
                    tnTeamDataDescriptor descriptor = entry.descriptor;
                    if (key != "" && descriptor != null)
                    {
                        int        hash = StringUtils.GetHashCode(key);
                        tnTeamData data = new tnTeamData(descriptor);

                        m_Data.Add(hash, data);
                        m_Keys.Add(hash);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database not loaded.");
        }
    }
    // CTOR

    public tnTeamData(tnTeamDataDescriptor i_Descriptor)
    {
        m_CharactersKeys = new LineUp();
        m_DefaultLineUps = new List <LineUp>();

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

            for (int characterIndex = 0; characterIndex < i_Descriptor.charactersCount; ++characterIndex)
            {
                string key = i_Descriptor.GetCharacterKey(characterIndex);
                if (key != "")
                {
                    int hash = StringUtils.GetHashCode(key);
                    m_CharactersKeys.Add(hash);
                }
            }

            for (int defaultLineUpIndex = 0; defaultLineUpIndex < i_Descriptor.defaultLineUpsCount; ++defaultLineUpIndex)
            {
                LineUp        lineUp           = new LineUp();
                List <string> lineUpDescriptor = i_Descriptor.GetDefaultLineUp(defaultLineUpIndex);
                if (lineUp != null)
                {
                    for (int characterIndex = 0; characterIndex < lineUpDescriptor.Count; ++characterIndex)
                    {
                        string key = lineUpDescriptor[characterIndex];
                        if (key != "")
                        {
                            int hash = StringUtils.GetHashCode(key);
                            lineUp.Add(hash);
                        }
                    }
                }

                if (lineUp.Count > 0)
                {
                    m_DefaultLineUps.Add(lineUp);
                }
            }

            m_Flag = i_Descriptor.flag;
            m_Icon = i_Descriptor.icon;

            m_BaseSprite = i_Descriptor.baseSprite;

            m_FirstColor  = i_Descriptor.firstColor;
            m_SecondColor = i_Descriptor.secondColor;

            m_SupportersFirstColor  = i_Descriptor.supportersFirstColor;
            m_SupportersSecondColor = i_Descriptor.supportersSecondColor;

            m_TeamStats = i_Descriptor.teamStats;
        }
    }