Exemplo n.º 1
0
    public void AddCharacterButton(JamJSONCharacterEntry charData, string subRegion, string realmName, bool online)
    {
        this.m_characterEntry = charData;
        GameObject gameObject = Object.Instantiate <GameObject>(this.charListItemPrefab);

        gameObject.transform.SetParent(this.charListContents.transform, false);
        CharacterListButton component = gameObject.GetComponent <CharacterListButton>();

        component.SetGUID(charData.PlayerGuid);
        component.m_characterEntry = charData;
        component.m_subRegion      = subRegion;
        Sprite sprite = GeneralHelpers.LoadClassIcon((int)charData.ClassID);

        if (sprite != null)
        {
            component.m_characterClassIcon.sprite = sprite;
        }
        component.m_characterName.text = charData.Name;
        bool flag = online;

        if (!charData.HasMobileAccess)
        {
            component.m_missingRequirement.text  = StaticDB.GetString("REQUIRES_CLASS_HALL", null);
            component.m_missingRequirement.color = Color.red;
            flag = false;
        }
        else if (realmName == "unknown")
        {
            component.m_missingRequirement.text = string.Empty;
            flag = false;
        }
        else
        {
            if (online)
            {
                component.m_missingRequirement.text = realmName;
            }
            else
            {
                component.m_missingRequirement.text = realmName + " (" + StaticDB.GetString("OFFLINE", null) + ")";
            }
            component.m_missingRequirement.color = Color.yellow;
        }
        component.m_missingRequirement.gameObject.SetActive(true);
        if (!flag)
        {
            Button component2 = gameObject.GetComponent <Button>();
            component2.interactable          = false;
            component.m_characterName.color  = Color.grey;
            component.m_characterLevel.color = Color.grey;
        }
        int num = (int)charData.ExperienceLevel;

        if (num < 1)
        {
            num = 1;
        }
        component.m_characterLevel.text = GeneralHelpers.TextOrderString(CharacterListView.m_levelText, num.ToString());
    }