Esempio n. 1
0
    public void RefreshHeroIcon()
    {
        if (Grid.transform.childCount > 0 && Grid.transform.childCount < playerData.GetInstance().herodataList.Count)
        {
            for (int i = Grid.transform.childCount - 1; i >= 0; i--)
            {
                if (Grid.GetChild(i) != null)
                {
                    DestroyImmediate(Grid.GetChild(i).gameObject);
                }
            }
        }

        GameObject item = null;

        for (int i = 0; i < playerData.GetInstance().herodataList.Count; i++)
        {
            item = NGUITools.AddChild(Grid.gameObject, ItemHeroDetail);
            if (item.GetComponent <ItemHeroIcon>())
            {
                icon = item.GetComponent <ItemHeroIcon>();
                if (heroIcon.ContainsKey(playerData.GetInstance().herodataList[i].id))
                {
                    heroIcon.Remove(playerData.GetInstance().herodataList[i].id);
                }
                heroIcon.Add(playerData.GetInstance().herodataList[i].id, icon);

                icon.RefreshInfo(playerData.GetInstance().herodataList[i]);
            }
        }
    }
Esempio n. 2
0
    void RefreshGrid(int type)
    {
        ItemHeroIcon icon = null;

        for (int i = 0; i < playerData.GetInstance().herodataList.Count; i++)
        {
            if (type == 0)
            {
                if (heroIcon.TryGetValue(playerData.GetInstance().herodataList[i].id, out icon))
                {
                    if (!icon.gameObject.activeSelf)
                    {
                        icon.gameObject.SetActive(true);
                    }
                }
            }
            else
            {
                if (!heroIcon.TryGetValue(playerData.GetInstance().herodataList[i].id, out icon))
                {
                    continue;
                }

                if (playerData.GetInstance().herodataList[i].node.attribute != type)
                {
                    if (icon.gameObject.activeSelf)
                    {
                        icon.gameObject.SetActive(false);
                    }
                }
                else
                {
                    if (!icon.gameObject.activeSelf)
                    {
                        icon.gameObject.SetActive(true);
                    }
                }
            }
        }
        Grid.repositionNow = true;
        Grid.Reposition();
        Grid.transform.parent.GetComponent <UIScrollView>().ResetPosition();
    }