void InitMyItemList(List <ItemFielInfo> itemList) { MyItemList.Clear(); Grid.ClearChild(); m_UIDraggablePanel.ResetPosition(); int lineNumber = (itemList.Count / 3) + (itemList.Count % 3 > 0?1:0); int itemIndex = 0; for (int line = 0; line < lineNumber; line++) { for (int row = 0; row < 3; row++) { if (itemList.Count > itemIndex) { SigleUpgradeItem upgradItem = Grid.InstantiateNGUIObj(SingleUpgradeItemPrefab).GetComponent <SigleUpgradeItem>(); upgradItem.transform.localPosition = new Vector3(-110 + 110 * row, 210 - 110 * line, 0); upgradItem.Init(itemList[itemIndex], OnMyItemClick); MyItemList.Add(upgradItem); itemIndex++; } } } // if(itemList.Count>0) // { // OnMyItemClick(itemList[0]);//默认选中第一个 // } }
void Init() { Grid.ClearChild(); MyItemList.Clear(); SelectItemList.Clear(); List <ItemFielInfo> packItemList = ContainerInfomanager.Instance.GetPackItemList().Where(p => (!p.GetIfBesetJewel(1)) && (!p.GetIfBesetJewel(2)) && (p.LocalItemData._TradeFlag == 1)).ToList(); // 所有已装备的装备本地信息 List <EquipmentData> equipedDataList = new List <EquipmentData>(); ContainerInfomanager.Instance.GetEquiptItemList().ApplyAllItem(P => equipedDataList.Add(P.LocalItemData as EquipmentData)); packItemList.Sort((left, right) => { bool leftCanSelectFast = IsCanFastSelect(left.LocalItemData, equipedDataList); bool rightCanSelectFast = IsCanFastSelect(right.LocalItemData, equipedDataList); if (leftCanSelectFast && !rightCanSelectFast) { return(-1); } else if (!leftCanSelectFast && rightCanSelectFast) { return(1); } else { if (left.sSyncContainerGoods_SC.nPlace < right.sSyncContainerGoods_SC.nPlace) { return(-1); } else if (left.sSyncContainerGoods_SC.nPlace == right.sSyncContainerGoods_SC.nPlace) { return(0); } else { return(1); } } }); for (int i = 0; i < ContainerInfomanager.Instance.GetAllPackMaxNum(); i++) { int indexX = i % 4; int indexY = i / 4; GameObject newObj = CreatObjectToNGUI.InstantiateObj(SinglePackItemPrefab, Grid); newObj.transform.localScale = new Vector3(0.85f, 0.85f, 1); newObj.transform.localPosition = new Vector3(-136 + 90 * indexX, 140 - 94 * indexY, 0); SinglePackItemSlot newItemSlot = newObj.GetComponent <SinglePackItemSlot>(); ItemFielInfo newItemFielInfo = packItemList.Count > i?packItemList[i]:null; newItemSlot.Init(newItemFielInfo, false, SinglePackItemSlot.ItemStatus.Sell, OnItemCLick); MyItemList.Add(newItemSlot); //引导注入 if (newItemFielInfo != null) { newObj.RegisterBtnMappingId(newItemFielInfo.LocalItemData._goodID, UIType.Package, BtnMapId_Sub.Package_Cell); } } //UpdateSellBtnStatus(); }