Exemplo n.º 1
0
    void RefreshIEGrid(List <HeroData> herolist, int type)
    {
        ItemEmbattleList itemEmba = null;

        for (int i = 0; i < herolist.Count; i++)
        {
            if (type == 0)
            {
                if (itemEmbattles.TryGetValue(herolist[i].id, out itemEmba))
                {
                    if (!itemEmba.gameObject.activeSelf)
                    {
                        itemEmba.gameObject.SetActive(true);
                    }
                }
                if (sourceType == OpenSourceType.actGold)
                {
                    if (herolist[i].node.sex == 2)
                    {
                        itemEmba.gameObject.SetActive(false);
                    }
                }
                else if (sourceType == OpenSourceType.actExpe)
                {
                    if (herolist[i].node.sex == 1)
                    {
                        itemEmba.gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                if (!itemEmbattles.TryGetValue(herolist[i].id, out itemEmba))
                {
                    continue;
                }

                if (herolist[i].node.attribute != type)
                {
                    if (itemEmba.gameObject.activeSelf)
                    {
                        itemEmba.gameObject.SetActive(false);
                    }
                }
                else
                {
                    if (!itemEmba.gameObject.activeSelf)
                    {
                        itemEmba.gameObject.SetActive(true);
                    }
                }
            }
        }
        //itemEmbattleGrid.repositionNow = true;
        itemEmbattleGrid.Reposition();
        itemEmbattleGrid.transform.parent.GetComponent <UIScrollView>().ResetPosition();
    }
Exemplo n.º 2
0
    bool InitItem()
    {
        GameObject       item     = null;
        ItemEmbattleList itemEmba = null;

        herodatalist = new List <HeroData>();
        if (playerData.GetInstance().herodataList.Count <= 0)
        {
            Debug.Log("herodataList count is 0");
            return(false);
        }
        if (itemEmbattleGrid.transform.childCount > 0)
        {
            for (int i = itemEmbattleGrid.transform.childCount - 1; i >= 0; i--)
            {
                if (itemEmbattleGrid.GetChild(i) != null)
                {
                    DestroyImmediate(itemEmbattleGrid.GetChild(i).gameObject);
                }
            }
            itemEmbattles.Clear();
        }
        herodatalist = playerData.GetInstance().herodataList;
        herodatalist.Sort(new HeroDataComparer());
        for (int i = 0; i < herodatalist.Count; i++)
        {
            item = NGUITools.AddChild(itemEmbattleGrid.gameObject, itemEmbattle);
            if (item.GetComponent <ItemEmbattleList>())
            {
                itemEmba = item.GetComponent <ItemEmbattleList>();
                if (itemEmbattles.ContainsKey(herodatalist[i].id))
                {
                    itemEmbattles.Remove(herodatalist[i].id);
                }
                itemEmbattles.Add(herodatalist[i].id, itemEmba);

                itemEmba.RefreshItemUI(herodatalist[i]);
                if (null == itemEmba.OnClickItem)
                {
                    itemEmba.OnClickItem = OnIECallBack;
                }
            }
        }
        return(true);
    }
Exemplo n.º 3
0
 void OnIECallBack(ItemEmbattleList item, bool isPlay)
 {
     HeroToBattle(item.heroData, isPlay);
 }