Beispiel #1
0
    /* 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);
    }
Beispiel #2
0
 void ConfirmActivateGameInTrialEndCallback(bool result)
 {
     if (result)
     {
         IAPManager.GetInstance().Pay(IAPManager.IAPProduct.ActiveGame);
     }
 }
Beispiel #3
0
 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();
     }
 }
Beispiel #4
0
    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();
        }
    }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
    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
        }
Beispiel #7
0
        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
        }
Beispiel #8
0
 private void ConfirmBuyVIPCallback(bool result)
 {
     if (result)
     {
         IAPManager.GetInstance().Pay(IAPManager.IAPProduct.VIP);
     }
 }
Beispiel #9
0
    public void ClickConfirmInputButton()
    {
        ResetProcessPanel();
        string code = codeInputField.text;

        IAPManager.AsyncExchangeCodesToDiamond(code, OnGetDiamondSuccess, OnGetDiamondFailed, OnError);
    }
Beispiel #10
0
 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);
            }
        }
Beispiel #12
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #13
0
 void BuyItem(ShopData shopData)
 {
     if (CheckIsPurchasing(shopData.product) == false)
     {
         IAPManager.GetInstance().Pay(shopData.product);
     }
 }
Beispiel #14
0
 public static IAPManager GetInstance()
 {
     if (instance == null)
     {
         instance = new IAPManager();
     }
     return(instance);
 }
Beispiel #15
0
 public void OpenShop(bool on)
 {
     if (on)
     {
         IAPManager.Start();
     }
     OpenPanel(shopPanel, on);
 }
Beispiel #16
0
 public static void CreateManager()
 {
     if (instance == null)
     {
         instance = new IAPManager();
         Instance.Initialize();
     }
 }
Beispiel #17
0
 void Awake()
 {
     instance = this;
     if (m_StoreController == null)
     {
         InitializePurchasing();
     }
 }
Beispiel #18
0
 static public void Init(IAPFinish callback)
 {
     if (instance == null)
     {
         instance = new IAPManager();
         instance.defaultFinishCallback = callback;
     }
 }
Beispiel #19
0
        //Buy logic
        public void Buy()
        {
            IAPManager manager = IAPManager.Instance;

            if (manager != null)
            {
                manager.PurchaseItem(displayedItem.ItemID);
            }
        }
Beispiel #20
0
 void AddPurchasingItem(string productId)
 {
     if (purchasingList.Contains(productId) == false)
     {
         purchasingList.Add(productId);
         IAPManager.IAPProduct product = IAPManager.GetInstance().IDProductMap[productId];
         ChangeItemDisplayState(product, true);
     }
 }
Beispiel #21
0
 void RemovePurchasingItem(string productId)
 {
     if (purchasingList.Contains(productId))
     {
         purchasingList.Remove(productId);
         IAPManager.IAPProduct product = IAPManager.GetInstance().IDProductMap[productId];
         ChangeItemDisplayState(product, false);
     }
 }
Beispiel #22
0
 private void TestSingleton()
 {
     if (instance != null)
     {
         Destroy(gameObject); return;
     }
     instance = this;
     DontDestroyOnLoad(gameObject);
 }
Beispiel #23
0
 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);
     }
 }
Beispiel #24
0
    /// <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);
        }
    }
Beispiel #25
0
 void Awake()
 {
     if (ins != null && ins != this)
     {
         Destroy(this.gameObject);
         return;
     }
     ins = this;
     DontDestroyOnLoad(this.gameObject);
 }
Beispiel #26
0
    void Awake()
    {
        if (shared != null)
        {
            DestroyImmediate(gameObject);
            return;
        }

        shared = this;
        DontDestroyOnLoad(gameObject);
    }
Beispiel #27
0
    /* * * * 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());
        }