private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { ShopItem item = itemList[i]; GameObject button = GameObject.Instantiate(buttonPrefab.gameObject); button.transform.SetParent(contentPanel); button.transform.localScale = Vector3.one; ShopSampleButton sampleButton = button.GetComponent <ShopSampleButton>(); sampleButton.Setup(item, this); } }
public void TryTransferItemToOtherShop(ShopSampleButton button) { ShopItem item = button.Item; if (otherShop.gold >= item.price) { gold += item.price; otherShop.gold -= item.price; this.RemoveItem(button); otherShop.AddItem(button); RefreshDisplay(); otherShop.RefreshDisplay(); } }
private void RemoveItem(ShopSampleButton buttonToRemove) { itemList.Remove(buttonToRemove.Item); buttonList.Remove(buttonToRemove); buttonToRemove.SetScrollList(null); }
private void AddItem(ShopSampleButton buttonToAdd) { itemList.Add(buttonToAdd.Item); buttonList.Add(buttonToAdd); buttonToAdd.SetScrollList(this); }