public void Setup(BosCoinUpgradeData data, BosItemList <BosCoinUpgradeData, ShopCoinUpgradeView> parent) { this.Data = data; this.Parent = parent; if (data.GeneratorId < 0) { nameText.text = data.Name.GetLocalizedString(); } else { var generatorLocalData = ResourceService.GeneratorLocalData.GetLocalData(data.GeneratorId); string generatorName = LocalizationObj.GetString(generatorLocalData.GetName(Planets.CurrentPlanetId.Id).name); string sourceFmt = LocalizationObj.GetString(data.Name); string result = sourceFmt.Replace("{0}", generatorName); nameText.text = result; } descriptionText.text = data.Description.GetLocalizedString(); priceText.text = data.Price.ToString(); BgSimple.gameObject.SetActive(data.UpgradeType != UpgradeType.Enhance); BgSpecial.gameObject.SetActive(data.UpgradeType == UpgradeType.Enhance); if (data.Icon.IsValid) { iconImage.overrideSprite = data.Icon.GetSprite(); } else { var generatorLocalData = Services.ResourceService.GeneratorLocalData.GetLocalData(data.GeneratorId); var iconData = generatorLocalData.GetIconData(Services.PlanetService.CurrentPlanet.Id); if (iconData.icon_id.IsValid()) { iconImage.overrideSprite = Services.ResourceService.GetSpriteByKey(iconData.icon_id); } else { iconImage.overrideSprite = Services.ResourceService.Sprites.FallbackSprite; } } buyButton.SetListener(() => { var result = Services.GetService <IStoreService>().Purchase(data); switch (result) { case TransactionState.DontEnoughCurrency: { //NotEnoughCoinsScreen.Instance.Show(data.Price); Services.ViewService.Show(ViewType.CoinRequiredView, new ViewData { UserData = data.Price }); } break; case TransactionState.AlreadyPurchased: { parent.Remove(this); } break; case TransactionState.Success: { if (data.IsOneTime) { buyButton.interactable = false; } } break; } Debug.Log($"Purchase state => {result}"); }); }