/* TEMPORARY METHODS */ /*public void addGold() { * DataAndSettingsManager.setGoldAmount(DataAndSettingsManager.getGoldAmount() + 100); * this.updateGoldLabel(); * } * * public void subtractGold() { * DataAndSettingsManager.setGoldAmount(DataAndSettingsManager.getGoldAmount() - 1); * this.updateGoldLabel(); * }*/ /* * * * Private methods * * * */ ///<summary>Populates the list of store items with `StoreListItem`s /// and adjusts the heights of the content rects.</summary> private void setupList() { // expendables for (int i = 0; i < StoreManager.getNumExpendables(); i++) { StoreListItem item = Instantiate(this.listItemPrefab, new Vector2(0f, -LIST_ITEM_HEIGHT * i - LIST_TITLE_HEIGHT), Quaternion.identity) as StoreListItem; RectTransform itemRect = item.gameObject.GetComponent <RectTransform>(); itemRect.SetParent(this.expendablesListContentRect.transform, false); item.setup(i, true, this.updateGoldLabel); } // unlockables for (int i = StoreManager.getNumExpendables(); i < StoreManager.getNumItems(); i++) { StoreListItem item = Instantiate(this.listItemPrefab, new Vector2(0f, -LIST_ITEM_HEIGHT * (i - StoreManager.getNumExpendables()) - LIST_TITLE_HEIGHT), Quaternion.identity) as StoreListItem; RectTransform itemRect = item.gameObject.GetComponent <RectTransform>(); itemRect.SetParent(this.unlockablesListContentRect.transform, false); item.setup(i, false, this.updateGoldLabel); } // adjust content rect heights and positions - anchors are at top left and top right RectTransform expendablesRect = this.expendablesListContentRect.GetComponent <RectTransform>(); float expendablesRectHeight = LIST_ITEM_HEIGHT * StoreManager.getNumExpendables() + LIST_TITLE_HEIGHT; expendablesRect.sizeDelta = new Vector2(0f, expendablesRectHeight); RectTransform unlockablesRect = this.unlockablesListContentRect.GetComponent <RectTransform>(); float unlockablesRectHeight = LIST_ITEM_HEIGHT * (StoreManager.getNumItems() - StoreManager.getNumExpendables()) + LIST_TITLE_HEIGHT; unlockablesRect.sizeDelta = new Vector2(0f, unlockablesRectHeight); RectTransform purchasablesRect = this.purchasablesListContentRect.GetComponent <RectTransform>(); float purchasablesRectHeight = LIST_ITEM_HEIGHT * IAPManager.getNumIAPs() + LIST_TITLE_HEIGHT; purchasablesRect.sizeDelta = new Vector2(0f, purchasablesRectHeight); }
void ConfirmActivateGameInTrialEndCallback(bool result) { if (result) { IAPManager.GetInstance().Pay(IAPManager.IAPProduct.ActiveGame); } }
public void InitIap(string id) { iapId = id; product = IAPManager.GetIAPInfo(id); if (product == null) { SetInitInProgress(); return; } button.interactable = true; if (product.metadata != null) { if (priceText != null) { priceText.text = product.metadata.localizedPriceString; } if (payoutText != null) { payoutText.text = product.definition.payout.quantity.ToString(); } if (descriptionText != null) { descriptionText.text = product.metadata.localizedDescription; } Refresh(); initialized = true; } else { SetInitInProgress(); } }
private void ConfirmRescueCallback(bool result) { if (result) { if (GameSystem.GetInstance().CheckIsActivated(ConfirmActiveGame, ActivateGameSucceed)) { if (GameSystem.GetInstance().Coin >= rescuePrice) { GameSystem.GetInstance().Coin -= rescuePrice; GameSystem.GetInstance().CurrentModeLogic.Rescue(); GameSystem.GetInstance().ChangeState(GameSystem.States.GamePreview); PlayerProfile.SaveCoin(GameSystem.GetInstance().Coin); UMengManager.Buy(UMengManager.Item_IAP[(int)IAPManager.IAPProduct.Rescue], 1, rescuePrice); } else { IAPManager.GetInstance().Pay(IAPManager.IAPProduct.Rescue); } } } else { entity.gameCore.StarWaveFailAnim(); } }
/// <summary> /// Purchase this instance. /// </summary> public bool Purchase(Action <IAPPackage> callback = null) { bool result = false; if (fetchFromStore) { // Debug.Log("purcahse " + _callback); _purchaseCallback = callback; IAPManager.OnIAPProcessPurchase += handleOnIAPProcessPurchaseInternal; IAPManager.OnIAPPurchaseFailed += handleOnIAPPurchaseFailedInternal; IAPManager.PurchaseProduct(uid); } else { if (productType == IAPProductType.NonConsumable && amount > 0) { //For non-consumable products, only purcahse one } else { // Get the currency IAPCurrency cur = IAPInventoryManager.GetCurrency(this.currency); // Check if enough currency if (cur != null && cur.Consume(this.price)) { DeliveryProduct(); result = true; } } } return(result); }
void ConfirmTrialEndCallback(bool result) { if (result) { int price = Constant.MODE_UNLOCK_COIN[(int)currentMode]; if (GameSystem.GetInstance().Coin >= price) { isTrial = false; UnlockMode(currentMode); StartNextWave(); } #if UNITY_IOS else { gameUI.shopMenu.RegisterCloseCallback(RefreshConfirmUnlockModeMenu); gameUI.shopMenu.Show(true); } #else else { for (int i = 0; i < ShopData.gameShopData.Length - 1; i++) { ShopData shopData = ShopData.gameShopData[i]; if (shopData.number >= price) { IAPManager.GetInstance().Pay(shopData.product); break; } } } #endif }
private void PopulateScreen() { #if ENABLE_IAP IAPManager iapManager = IAPManager.Instance; if (iapManager == null || !iapManager.Initialized) { return; } if (m_ItemPrefab != null && m_ItemParent != null) { List <IAPItem> availableItems = iapManager.AvailableItems; for (int i = 0; i < availableItems.Count; ++i) { IAPItem item = availableItems[i]; ShopItem spawnedItem = Instantiate <ShopItem>(m_ItemPrefab); spawnedItem.ShowItem(item); spawnedItem.transform.SetParent(m_ItemParent, false); } } #endif }
private void ConfirmBuyVIPCallback(bool result) { if (result) { IAPManager.GetInstance().Pay(IAPManager.IAPProduct.VIP); } }
public void ClickConfirmInputButton() { ResetProcessPanel(); string code = codeInputField.text; IAPManager.AsyncExchangeCodesToDiamond(code, OnGetDiamondSuccess, OnGetDiamondFailed, OnError); }
private void Awake() { if (INSTANCE == null) { INSTANCE = this; } }
/// <summary> /// Initialize the IAP Manager. /// </summary> public static void InitIAPManager() { // Init the IAPManager if (_instance != null && _initing == false && _packageSettings != null) { _initing = true; // Get the product list need to fetch List <IAPProductSetting> products = new List <IAPProductSetting>(); foreach (IAPPackageSetting p in _packageSettings) { if (p.fetchFromStore) { products.Add(p); } } // Add events IAPManager.OnIAPInitialized += handleOnIAPInitialized; IAPManager.OnIAPInitializeFailed += handleOnIAPInitializeFailed; IAPManager.OnIAPProcessPurchase += handleOnIAPProcessPurchase; IAPManager.OnIAPPurchaseDeferred += handleOnIAPProcessDeferred; IAPManager.OnIAPPurchaseFailed += handleOnIAPPurchaseFailed; IAPManager.OnIAPPurchaseStart += handleOnIAPPurchaseStart; IAPManager.OnIAPTransactionsRestored += handleOnIAPTransactionsRestored; IAPManager.Create(products, _advancedSetting); } }
void Awake() { if (instance == null) { instance = this; } }
void BuyItem(ShopData shopData) { if (CheckIsPurchasing(shopData.product) == false) { IAPManager.GetInstance().Pay(shopData.product); } }
public static IAPManager GetInstance() { if (instance == null) { instance = new IAPManager(); } return(instance); }
public void OpenShop(bool on) { if (on) { IAPManager.Start(); } OpenPanel(shopPanel, on); }
public static void CreateManager() { if (instance == null) { instance = new IAPManager(); Instance.Initialize(); } }
void Awake() { instance = this; if (m_StoreController == null) { InitializePurchasing(); } }
static public void Init(IAPFinish callback) { if (instance == null) { instance = new IAPManager(); instance.defaultFinishCallback = callback; } }
//Buy logic public void Buy() { IAPManager manager = IAPManager.Instance; if (manager != null) { manager.PurchaseItem(displayedItem.ItemID); } }
void AddPurchasingItem(string productId) { if (purchasingList.Contains(productId) == false) { purchasingList.Add(productId); IAPManager.IAPProduct product = IAPManager.GetInstance().IDProductMap[productId]; ChangeItemDisplayState(product, true); } }
void RemovePurchasingItem(string productId) { if (purchasingList.Contains(productId)) { purchasingList.Remove(productId); IAPManager.IAPProduct product = IAPManager.GetInstance().IDProductMap[productId]; ChangeItemDisplayState(product, false); } }
private void TestSingleton() { if (instance != null) { Destroy(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); }
void InitializePurchsingList(string purchasingData) { string[] dataStrings = purchasingData.Split(new char[] { ',' }); foreach (string data in dataStrings) { purchasingList.Add(data); IAPManager.IAPProduct product = IAPManager.GetInstance().IDProductMap[data]; ChangeItemDisplayState(product, true); } }
/// <summary> /// Updates the button. /// </summary> /// <param name="productId">Product identifier.</param> /// <param name="btn">Button.</param> public void UpdateButton(string productId, GameObject btn) { // Get the product if (IAPManager.IsProductReady(productId)) { IAPProduct p = IAPManager.products[productId]; _setButtonLabel(p, btn, p.priceString); } }
void Awake() { if (ins != null && ins != this) { Destroy(this.gameObject); return; } ins = this; DontDestroyOnLoad(this.gameObject); }
void Awake() { if (shared != null) { DestroyImmediate(gameObject); return; } shared = this; DontDestroyOnLoad(gameObject); }
/* * * * Public methods * * * */ public void setup(int itemIndex) { this.productID = IAPManager.getProductID(itemIndex); Product product = IAPManager.getProductWithID(productID); this.itemLabel.text = product.metadata.localizedTitle; this.descriptionLabel.text = product.metadata.localizedDescription; this.costLabel.text = product.metadata.localizedPriceString; this.isConsumable = (product.definition.type == ProductType.Consumable); this.updateButton(); }
// Restore purchase public void RestorePurchase() { if (IAPManager.IsInitialized()) { IAPManager.RestorePurchases(); } else { MobileNativeUI.Alert("Service Unavailable", "Please check your internet connection."); } }
// Buy an IAP product using its name public void Purchase(string productName) { if (IAPManager.IsInitialized()) { IAPManager.Purchase(productName); } else { MobileNativeUI.Alert("Service Unavailable", "Please check your internet connection."); } }
void Start() { curtain.SetActive(!EM_Settings.IsIAPModuleEnable); if (logProductLocalizedData) { #if EM_UIAP foreach (IAPProduct p in EM_Settings.InAppPurchasing.Products) { UnityEngine.Purchasing.ProductMetadata data = IAPManager.GetProductLocalizedData(p.Name); if (data != null) { Debug.Log("Product Localized Title: " + data.localizedTitle); Debug.Log("Localized Price: " + data.localizedPriceString); Debug.Log("Product Localized Description: " + data.localizedDescription); } else { Debug.Log("Localized data is null"); } } #endif } StartCoroutine(CheckOwnedProducts()); }