public void Setup(Community buyer, CommodityGroup currentOffer) { OnOffer.Clear(); foreach (var i in InitializedObjects) { Destroy(i); } foreach (var rin in buyer.Inventory) { var res = (KeyValuePair <Commodity, int>)rin; var r = res.Key; int max = res.Value - currentOffer.GetResourceAmount(r); if (max <= 0) { continue; } var o = Instantiate(OfferPrefab, OfferPrefab.transform.parent); o.Max = max; o.ResourceNameText.text = r.name; o.ResourceImage.sprite = r.Sprite; o.gameObject.SetActive(true); o.AmountInputField.onValueChanged.AddListener(v => UpdateResourceInOffer(v, r)); InitializedObjects.Add(o.gameObject); } Holder.SetActive(true); }
private void Clear() { CurrentOffer.Clear(); AddOns.Clear(); }