void OnPropertyChanged(int objectID, int eventType, IPropertyObject obj, object eventObj) { if (eventType == (int)CardBag.ENPropertyChanged.enInitCardBag) { InitBag(); UpdateInfo(); } else if (eventType == (int)CardBag.ENPropertyChanged.enUpdateCardInBag) { if (WindowRoot.gameObject.activeSelf) { m_cardSortUI.SortCards(m_cardSortUI.GetLastSortType(), true); UpdateInfo(); } } else if (eventType == (int)CardBag.ENPropertyChanged.enResetSelectedList) { UpdateInfo(); } else if (eventType == (int)CardBag.ENPropertyChanged.enShowOption) { UpdateOption(); } else if (eventType == (int)CardBag.ENPropertyChanged.enExpandCardBag) { ExpandCardBagGrid(); } else if (eventType == (int)CardBag.ENPropertyChanged.enCardSort) { UpdateInfo(); } else if (eventType == (int)CardBag.ENPropertyChanged.enCardSelect) { UpdateInfo(); } }
// 更新 void UpdateInfo() { m_tempIndex = 1; // 不同类型显示内容不同 ShowCurTypeLayout(); // 排序好的列表 List <CSItemGuid> cardList = m_cardSortUI.GetSortReslut(); ENSortType sortType = m_cardSortUI.GetLastSortType(); // 显示卡牌列表 foreach (CSItemGuid itemGuid in cardList) { CSItem item = CardBag.Singleton.GetCardByGuid(itemGuid); if (null == item) { continue; } int cardID = item.IDInTable; HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(cardID); if (null == heroInfo) { Debug.LogWarning("heroInfo == NULL heroInfo cardID:" + cardID); continue; } // 筛选 if (SortConditon(item)) { continue; } // 格子不够增加格子 if (false == m_gridList.ContainsKey(m_tempIndex)) { ExpandOneGrid(); } // 更新格子 UICardItem cardItem = m_gridList[m_tempIndex]; cardItem.UpdateOperate(item, sortType, m_tempIndex); m_tempIndex++; } // 把剩余的空格子图片置空 for (; m_tempIndex <= m_gridList.Count; m_tempIndex++) { UICardItem cardItem = m_gridList[m_tempIndex]; cardItem.SetEmpty(); cardItem.HideWindow(); } m_gridItemList.Reposition(); }