public static void Create(ICustomData customData, SFSX2Manager sfsx2Manager, ViewElementsSpawnData viewElementsSpawnData) { var rewardGetter = new RewardGetter(customData); var realOfferPurchaser = new RealOfferPurchaser(customData.BalanceData.ShopCards, customData.BalanceData.ShopInApps, rewardGetter, sfsx2Manager); var inGameOfferPurchaser = new InGameOfferPurchaser(rewardGetter); customData.BalanceData.ShopCards.ForEach(shopCardData => { var cardPurchaser = shopCardData.price.Any(x => x.resourceType == global::Shop.PriceData.INAPP_RESOURCE_TYPE) ? (IPurchaser)realOfferPurchaser : inGameOfferPurchaser; var shopCardModel = new ShopCardModel(cardPurchaser, shopCardData); var offersSpawnInfo = viewElementsSpawnData.GetSpawnInfo(shopCardData.isBigSize ? "big_offers" : "small_offers"); shopCardData.Sprite = Resources.Load <Sprite>("Shop/Textures/" + shopCardData.decorationId); var shopCardPrefab = Resources.Load <GameObject>("Shop/shop_card"); var shopCardPrefabGameobject = GameObject.Instantiate(shopCardPrefab, offersSpawnInfo.LocalPosition, offersSpawnInfo.Rotation, offersSpawnInfo.Parent); var shopCardView = shopCardPrefabGameobject.GetComponent <ShopCardView>(); shopCardData.DataChanged += changedData => shopCardView.DataChanged(new ShopCardViewModel(changedData)); shopCardData.NotifyThatDataChanged(); shopCardView.BuyButton.onClick.AddListener(() => shopCardModel.RequestCardPurchasing()); }); }
public RealOfferPurchaser(List <ShopCardData> shopCardDatas, List <ShopInApp> shopInApps, IRewardGetter rewardGetter, SFSX2Manager sfsx2Manager) { _shopCardDatas = shopCardDatas; _shopInApps = shopInApps; _sfsx2Manager = sfsx2Manager; _rewardGetter = rewardGetter; var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); _shopInApps.ForEach(realInApp => builder.AddProduct(realInApp.inappName, ProductType.Consumable, new IDs { { realInApp.inappName, GooglePlay.Name }, { realInApp.inappName, AppleAppStore.Name }, })); UnityPurchasing.Initialize(this, builder); }
public static void Create(SFSX2Manager sfsx2Manager) { var customData = GameLayer.I.CustomData; customData.BalanceChanged += () => { var shopCardsStateSwitcher = new ShopCardStateSwitcher(customData.BalanceData.ShopCards); var shopData = new ShopData(shopCardsStateSwitcher); var shopModel = new ShopModel(shopData); var shopView = Object.FindObjectOfType <ShopView>(); shopView.SetModel(shopModel); shopView.Bind(); shopData.DataChanged += data => shopView.ShopDataChanged(shopData); shopData.NotifyThatDataChanged(); ShopNotificationCreator.Create(customData.BalanceData.ShopCards); var viewElementsSpawnData = shopView.GetComponent <ViewElementsSpawnData>(); // it's not right, spawning element must be by info recieved from server ShopCardsCreator.Create(customData, sfsx2Manager, viewElementsSpawnData); }; }