public void Refresh(List <Item> items) { Clear(); int r = 0; ItemListUI row = null; for (int n = 0; n < items.Count; n++, r++) { Debug.Log("r=" + r + " " + (r % itemsPerRow == 0)); if (r % itemsPerRow == 0) { int rowNum = (int)(r / itemsPerRow); if (rowNum < Rows.Count) { row = Rows[rowNum]; row.gameObject.SetActive(true); } else { row = Instantiate <ItemListUI>(RowPrototype, RowPrototype.transform.parent); row.gameObject.SetActive(true); Rows.Add(row); } } if (row.elements.Count < itemsPerRow) { row.AddDefault(); } ItemUI item = ((ItemUI)row.elements[n % itemsPerRow]); item.SetItem(items[n]); item.Refresh(); } }
static void ConsumeFromInventoryUI() { if (currentItem == null || currentItem.Count <= 0) { return; } int itemCount = GameObject.Find("MapScene/MapUI(Clone)/CommandCanvas/MenuUI(Clone)/CellularUI/Interface Panel/InventoryUI(Clone)/InfoPanel").GetComponent <ItemInfoRemoveUI>().Count; ItemListUI itemUI = GameObject.Find("MapScene/MapUI(Clone)/CommandCanvas/MenuUI(Clone)/CellularUI/Interface Panel/InventoryUI(Clone)/InventoryViewer(Clone)/ListPanel").GetComponent <ItemListUI>(); List <StuffItem> itemList = Singleton <Game> .Instance.WorldData.PlayerData.ItemList; ConsumeItem(ref currentItem, itemCount, ref itemUI, ref itemList); }
private void Awake() { ItemListUI[] itemListUiArray = new ItemListUI[2] { this._normalItemListUI, this._specialItemListUI }; for (int index = 0; index < this.controllers.Length; ++index) { ShopViewer.ItemListController itemListController = new ShopViewer.ItemListController(index != 0 ? ShopViewer.ItemListController.Mode.VendorSpecial : ShopViewer.ItemListController.Mode.Vendor); itemListController.Bind(itemListUiArray[index]); this.controllers[index] = itemListController; } }
private void NonEnabledInput(ItemListUI con) { if (Object.op_Equality((Object)con, (Object)null) || this.ItemListUIs.IsNullOrEmpty <ItemListUI>()) { return; } con.EnabledInput = true; foreach (ItemListUI itemListUi in this.ItemListUIs) { if (Object.op_Inequality((Object)itemListUi, (Object)null) && Object.op_Inequality((Object)itemListUi, (Object)con)) { itemListUi.EnabledInput = false; } } }
public void Bind(ItemListUI itemListUI) { this._itemListUI = itemListUI; }
static void ConsumeItem(ref StuffItem itemToConsume, int amountToConsume, ref ItemListUI itemUI, ref List <StuffItem> itemList) { if (amountToConsume <= 0 || itemUI == null) { return; } float caloriesPerItem = GetCalories(itemToConsume) * CalorieEfficiency.Value / CaloriePool.Value; float waterPerItem = GetWaterContent(itemToConsume) * WaterEfficiency.Value / WaterPool.Value; if (caloriesPerItem > 0) { int maxAmountToConsume = 1 + (int)((100 - playerController["food"]) / caloriesPerItem); if (amountToConsume > maxAmountToConsume) { amountToConsume = maxAmountToConsume; } } else if (waterPerItem > 0) { int maxAmountToConsume = 1 + (int)((100 - playerController["water"]) / waterPerItem); if (amountToConsume > maxAmountToConsume) { amountToConsume = maxAmountToConsume; } } if (amountToConsume > itemToConsume.Count) { amountToConsume = itemToConsume.Count; } playerController["food"] += amountToConsume * caloriesPerItem; playerController["water"] += amountToConsume * waterPerItem; playerController["stamina"] += amountToConsume * GetStaminaModifier(itemToConsume); itemToConsume.Count -= amountToConsume; if (itemToConsume.Count <= 0) { if (itemList != null && itemList.Contains(itemToConsume)) { itemList.Remove(itemToConsume); } itemUI.RemoveItemNode(itemUI.CurrentID); } itemUI.Refresh(); }
public void SendItem( int count, PanelType panelType, ItemListController sender, ItemListController receiver, int currentID, ItemNodeUI nodeUI) { if (sender == null || receiver == null || (Object.op_Equality((Object)nodeUI, (Object)null) || nodeUI.Item == null) || (count <= 0 || nodeUI.Item.Count <= 0)) { return; } StuffItem stuffItem1 = new StuffItem(nodeUI.Item); stuffItem1.Count = Mathf.Min(count, nodeUI.Item.Count); int num = receiver.AddItem(stuffItem1); if (num <= 0) { return; } switch (panelType) { case PanelType.Pouch: case PanelType.Chest: if (this.SelectedInventoryUI != null) { List <StuffItem> itemList = this.SelectedInventoryUI.itemList; ItemListUI itemListUi = this.SelectedInventoryUI.itemListUI; StuffItem stuffItem2 = itemList.Find((Predicate <StuffItem>)(x => x == nodeUI.Item)); if (stuffItem2 != null) { stuffItem2.Count -= num; if (stuffItem2.Count <= 0) { itemList.Remove(stuffItem2); itemListUi.RemoveItemNode(currentID); itemListUi.ForceSetNonSelect(); this._infoPanelUI.DetachItem(); } Action refreshEvent = sender.RefreshEvent; if (refreshEvent != null) { refreshEvent(); break; } break; } break; } break; case PanelType.DecidedItem: case PanelType.CreatedItem: if (sender.RemoveItem(currentID, new StuffItem(nodeUI.Item) { Count = num }) <= 0) { this._infoPanelUI.DetachItem(); } if (this.SelectedInventoryUI != null && Object.op_Inequality((Object)this.SelectedInventoryUI.itemListUI, (Object)null)) { Action refreshEvent = this.SelectedInventoryUI.ListController.RefreshEvent; if (refreshEvent != null) { refreshEvent(); break; } break; } break; } this.OnSendItem.OnNext(stuffItem1); }
private void FinishedInventoryUISetting() { this._vieweres = new RecyclingInventoryFacadeViewer[2] { this._pouchInventoryUI, this._chestInventoryUI }; if (this.WarningUIs.IsNullOrEmpty <WarningViewer>()) { List <WarningViewer> toRelease = ListPool <WarningViewer> .Get(); toRelease.Add(this._pouchWarningViewer); toRelease.Add(this._chestWarningViewer); toRelease.Add(this._pouchAndChestWarningViewer); toRelease.RemoveAll((Predicate <WarningViewer>)(x => Object.op_Equality((Object)x, (Object)null))); this.WarningUIs = new WarningViewer[toRelease.Count]; for (int index = 0; index < toRelease.Count; ++index) { this.WarningUIs[index] = toRelease[index]; } ListPool <WarningViewer> .Release(toRelease); } if (this.MenuUIBehaviours.IsNullOrEmpty <MenuUIBehaviour>()) { List <MenuUIBehaviour> toRelease = ListPool <MenuUIBehaviour> .Get(); toRelease.Add((MenuUIBehaviour)this); toRelease.Add((MenuUIBehaviour)this._infoPanelUI); toRelease.Add((MenuUIBehaviour)this._deleteRequestUI); toRelease.AddRange((IEnumerable <MenuUIBehaviour>) this._pouchInventoryUI.viewer.MenuUIList); toRelease.AddRange((IEnumerable <MenuUIBehaviour>) this._chestInventoryUI.viewer.MenuUIList); toRelease.Add((MenuUIBehaviour)this._decidedItemSlotUI.ItemListUI); toRelease.Add((MenuUIBehaviour)this._createItemStockUI.ItemListUI); toRelease.Add((MenuUIBehaviour)this._createPanelUI); toRelease.RemoveAll((Predicate <MenuUIBehaviour>)(x => Object.op_Equality((Object)x, (Object)null))); this.MenuUIBehaviours = new MenuUIBehaviour[toRelease.Count]; for (int index = 0; index < toRelease.Count; ++index) { this.MenuUIBehaviours[index] = toRelease[index]; } ListPool <MenuUIBehaviour> .Release(toRelease); } if (this.ItemListUIBehaviours.IsNullOrEmpty <MenuUIBehaviour>()) { List <MenuUIBehaviour> toRelease = ListPool <MenuUIBehaviour> .Get(); toRelease.Add((MenuUIBehaviour)this._pouchInventoryUI.itemListUI); toRelease.Add((MenuUIBehaviour)this._chestInventoryUI.itemListUI); toRelease.Add((MenuUIBehaviour)this._decidedItemSlotUI.ItemListUI); toRelease.Add((MenuUIBehaviour)this._createItemStockUI.ItemListUI); toRelease.RemoveAll((Predicate <MenuUIBehaviour>)(x => Object.op_Equality((Object)x, (Object)null))); this.ItemListUIBehaviours = new MenuUIBehaviour[toRelease.Count]; for (int index = 0; index < toRelease.Count; ++index) { this.ItemListUIBehaviours[index] = toRelease[index]; } ListPool <MenuUIBehaviour> .Release(toRelease); } if (this.ItemListUIs.IsNullOrEmpty <ItemListUI>()) { List <ItemListUI> toRelease = ListPool <ItemListUI> .Get(); toRelease.Add(this._pouchInventoryUI.itemListUI); toRelease.Add(this._chestInventoryUI.itemListUI); toRelease.Add(this._decidedItemSlotUI.ItemListUI); toRelease.Add(this._createItemStockUI.ItemListUI); toRelease.RemoveAll((Predicate <ItemListUI>)(x => Object.op_Equality((Object)x, (Object)null))); this.ItemListUIs = new ItemListUI[toRelease.Count]; for (int index = 0; index < toRelease.Count; ++index) { this.ItemListUIs[index] = toRelease[index]; } ListPool <ItemListUI> .Release(toRelease); } if (this.ListControllers.IsNullOrEmpty <ItemListController>()) { List <ItemListController> toRelease = ListPool <ItemListController> .Get(); toRelease.Add(this._pouchInventoryUI.ListController); toRelease.Add(this._chestInventoryUI.ListController); toRelease.Add(this._decidedItemSlotUI.ListController); toRelease.Add(this._createItemStockUI.ListController); toRelease.RemoveAll((Predicate <ItemListController>)(x => x == null)); this.ListControllers = new ItemListController[toRelease.Count]; for (int index = 0; index < toRelease.Count; ++index) { this.ListControllers[index] = toRelease[index]; } ListPool <ItemListController> .Release(toRelease); } DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <Unit>((IObservable <M0>) this._infoPanelUI.ClickDecide, (Action <M0>)(_ => this.SendItem(this._infoPanelUI))), (Component)this); DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <Unit>((IObservable <M0>) this._infoPanelUI.ClickReturn, (Action <M0>)(_ => this.SendItem(this._infoPanelUI))), (Component)this); this._pouchInventoryUI.itemListUI.CurrentChanged += (Action <int, ItemNodeUI>)((currentID, node) => this.CurrentChanged(PanelType.Pouch, currentID, node)); this._chestInventoryUI.itemListUI.CurrentChanged += (Action <int, ItemNodeUI>)((currentID, node) => this.CurrentChanged(PanelType.Chest, currentID, node)); this._decidedItemSlotUI.ItemListUI.CurrentChanged += (Action <int, ItemNodeUI>)((currentID, node) => this.CurrentChanged(PanelType.DecidedItem, currentID, node)); this._createItemStockUI.ItemListUI.CurrentChanged += (Action <int, ItemNodeUI>)((currentID, node) => { if (Object.op_Equality((Object)node, (Object)null)) { return; } this.NonSelection(this._createItemStockUI.ListController); this._infoPanelUI.AttachDeleteItem(this._createItemStockUI.ListController, node, currentID); }); this._pouchInventoryUI.ItemNodeOnDoubleClick = (Action <InventoryFacadeViewer.DoubleClickData>)(data => this.OnDoubleClick(PanelType.Pouch, data.ID, data.node)); this._chestInventoryUI.ItemNodeOnDoubleClick = (Action <InventoryFacadeViewer.DoubleClickData>)(data => this.OnDoubleClick(PanelType.Chest, data.ID, data.node)); this._decidedItemSlotUI.ListController.DoubleClick += (Action <int, ItemNodeUI>)((currentID, nodeUI) => this.OnDoubleClick(PanelType.DecidedItem, currentID, nodeUI)); this._createItemStockUI.ListController.DoubleClick += (Action <int, ItemNodeUI>)((currentID, nodeUI) => this.OnDoubleClick(PanelType.CreatedItem, currentID, nodeUI)); if (!this.ItemListUIs.IsNullOrEmpty <ItemListUI>()) { foreach (ItemListUI itemListUi in this.ItemListUIs) { ItemListUI ui = itemListUi; RecyclingUI recyclingUi = this; if (!Object.op_Equality((Object)ui, (Object)null)) { DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <int>(Observable.Where <int>((IObservable <M0>)ui.OnEntered, (Func <M0, bool>)(_ => ((Behaviour)recyclingUi).get_isActiveAndEnabled())), (Action <M0>)(_ => recyclingUi.NonEnabledInput(ui))), (Component)this); } } } if (!this.ListControllers.IsNullOrEmpty <ItemListController>()) { int num = -1; foreach (ItemListController listController in this.ListControllers) { ++num; if (listController != null) { listController.RefreshEvent += (Action)(() => this.UpdateWarningUI()); } } } this.SetActive(false, ((Component)this).get_gameObject()); this.Initialized = true; }