public override void Initialize(CollectionItemSelectionHandler collectionItemSelectionHandler, CollectionPurchaseController purchaseController) { _purchaseController = purchaseController; var idx = 0; foreach (var itemId in _itemIds) { var collectionItem = _collectionItems[idx++]; var item = _itemManager.GetItemById <IItem>(itemId); collectionItem.Initialize(item, true, new ReactiveProperty <string>(item.Name)); collectionItemSelectionHandler.RegisterItemSelector(collectionItem); } _product = new Product(_productId, int.MaxValue, $"currency_random_{_productId}"); var payment = new LeveledCurrencyPayment($"payment_{name}", _currency, _currencyManager, _leveledPrices.ToArray()); var acquisition = new LumpSum(); var bundle = new PickUpBundle(_itemIds.Select(id => (id, 1, 1)).ToList(), _inventory, _itemManager); _product.SetPayment(payment) .SetAcquisition(acquisition) .SetBundle(bundle); payment.Price.Subscribe(price => _priceText.text = price.ToString()); _progressPurchaseButton.gameObject.SetActive(skinManager.CheckPurchaseButtons()); _rewardButton.gameObject.SetActive(skinManager.CheckPurchaseButtons()); bundle.OnUnboxed += (result) => { FireBase.Instance.UseCoin(result.Picked.Item1, payment.Price.Value); FireBase.Instance.Skin(result.Picked.Item1, payment.Price.Value, 0, 0); CoinManager.Instance.InitCoinText(); _progressPurchaseButton.gameObject.SetActive(skinManager.CheckPurchaseButtons()); _rewardButton.gameObject.SetActive(skinManager.CheckPurchaseButtons()); }; _rewardProduct = new Product(_rewardProductId, int.MaxValue, $"currency_reward_{_rewardProductId}"); var rewardPayment = new RewardedAdPayment("rewarded", _adsManager); var rewardAcquisition = new LumpSum(); var rewardBundle = new CurrencyBundle($"currency_reward_{_rewardProductId}", _currency, _rewardAmount, _currencyManager); _rewardProduct.SetPayment(rewardPayment) .SetAcquisition(rewardAcquisition) .SetBundle(rewardBundle); if (_rewardButton != null) { _rewardButton.onClick.AddListener(() => _purchaseController.ProgressPurchase(_rewardProduct)); } }
public void RegisterPreviewSelectionHandler(string slot, CollectionItemSelectionHandler itemSelectionHandler) { itemSelectionHandler.PreviewingItem .Subscribe(item => { SetPreviewingItem(slot, item); if (slot == "Trail") { Trailpreview.EndAni(); Trailpreview.StartAni(); } }); itemSelectionHandler.PreviewAction += ChangePreview; }
void OnEnable() { if (CollectionItemSelectionHandler == null) { return; } var equipped = _equipment.GetItem(_equipmentSlot); CollectionItemSelectionHandler.SelectItem(equipped); for (int i = 0; i < _collectionPages.Count; i++) { if (_collectionPages[i].ContainsItem(equipped)) { _scrollSnap.ChangePage(i); break; } } }
public void Initialize(Equipment equipment, CollectionPreviewer collectionPreviewer) { _equipment = equipment; CollectionItemSelectionHandler = new CollectionItemSelectionHandler(_inventory, _toggleGroup, _equipmentSlot, equipment, collectionPreviewer); CollectionPurchaseController = new CollectionPurchaseController(); var idx = 0; foreach (var collectionPage in _collectionPages) { var p = idx; _scrollSnap.AddChild(collectionPage.gameObject); _scrollSnap.OnSelectionPageChangedEvent.AddListener((page) => { if (_equipmentSlot != "Trail") { if (page == p) { collectionPage.OnFocused(); } else { collectionPage.OnUnfocused(); } } }); collectionPage.Initialize(CollectionItemSelectionHandler, CollectionPurchaseController); idx++; } var equippedItem = _equipment.GetItem(_equipmentSlot); //CollectionItemSelectionHandler.SelectItem(equippedItem); for (int i = 0; i < _paginations.Count; i++) { _paginations[i].gameObject.SetActive(i < _collectionPages.Count); } }
public abstract void Initialize(CollectionItemSelectionHandler collectionItemSelectionHandler, CollectionPurchaseController purchaseController);