コード例 #1
0
    private void OnClickItem(int heroConfigID)
    {
        HeroInfo info = UserManager.Instance.GetHeroInfoByUnitID(heroConfigID);

        if (info == null)
        {
            return;
        }

        if (info.IsOnPVE())
        {
            UserManager.Instance.PVEHeroList.Remove(info);
        }
        else
        {
            UserManager.Instance.PVEHeroList.Add(info);
        }

        // 只刷新点击的英雄
        foreach (Transform item in _listView._listContainer)
        {
            PVESelectHeroWidget widget = item.GetComponent <PVESelectHeroWidget>();
            if (widget != null && widget.IsWidget(heroConfigID))
            {
                widget.SetInfo(info);
            }
        }

        // TODO 刷新英雄
    }
コード例 #2
0
 private void UpdateList()
 {
     _listView.Data = UserManager.Instance.HeroList.ToArray();
     _listView.OnListItemAtIndex = (index) =>
     {
         PVESelectHeroWidget go = _listView.CreateListItemWidget <PVESelectHeroWidget>(0);
         go.OnClickItem += OnClickItem;
         go.SetInfo(UserManager.Instance.HeroList[index]);
         return(go);
     };
     _listView.Refresh();
 }