Ejemplo n.º 1
0
    /// <summary>
    /// 移除物品的显示
    /// </summary>
    /// <param name="playGoods"></param>
    protected virtual void RemoveItemShow(PlayGoods playGoods)
    {
        UIListItem[] uiListItems    = ItemUIList.GetAllImtes();
        UIListItem   thisUIListItem = uiListItems.FirstOrDefault(temp =>
        {
            PlayGoods thisPlayGoods = temp.value as PlayGoods;
            if (thisPlayGoods != null && thisPlayGoods == playGoods)
            {
                return(true);
            }
            return(false);
        });

        if (thisUIListItem != null)
        {
            ItemUIList.RemoveItem(thisUIListItem);
            ItemUIList.UpdateUI();
            SelectGoods = ItemUIList.FirstShowItem();
            if (SelectGoods != null)
            {
                ItemUIList.ShowItem(SelectGoods);
                SelectGoods.childImage.enabled = true;
                SelectGoods.childImage.gameObject.SetActive(true);
            }
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 玩家状态发生变化
 /// </summary>
 /// <param name="iPlayerState"></param>
 /// <param name="name"></param>
 private void IPlayerStateChanged(IPlayerState iPlayerState, string name)
 {
     if (name == GameState.Instance.GetFieldName <IPlayerState, bool>(temp => temp.EquipmentChanged))//主要用于装备发生变化时修改集合
     {
         UIListItem[]      nowUIListItems  = uiDepostiList.GetAllImtes();
         List <UIListItem> mustDeleteItems = new List <UIListItem>();
         foreach (UIListItem item in nowUIListItems)
         {
             PlayGoods playGoods = item.value as PlayGoods;
             if (playGoods.GoodsLocation == GoodsLocation.Wearing)
             {
                 mustDeleteItems.Add(item);
             }
         }
         PlayGoods[]      packageGoods     = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Package).ToArray();
         List <PlayGoods> mustAddPlayGoods = new List <PlayGoods>();
         PlayGoods[]      lastPackageGoods = nowUIListItems.Select(temp => temp.value as PlayGoods).ToArray();
         foreach (PlayGoods item in packageGoods)
         {
             if (!lastPackageGoods.Contains(item))
             {
                 mustAddPlayGoods.Add(item);
             }
         }
         //删除需要删除的条目
         foreach (UIListItem item in mustDeleteItems)
         {
             uiDepostiList.RemoveItem(item);
         }
         //添加需要添加的条目
         foreach (PlayGoods item in mustAddPlayGoods)
         {
             UIListItem uiListItem = uiDepostiList.NewItem();
             uiListItem.childText.text = item.GoodsInfo.GoodsName;
             uiListItem.value          = item;
             uiDepostiList.ShowItem(uiListItem);
         }
         uiDepostiList.UpdateUI();
     }
 }