Esempio n. 1
0
    void OnClick()
    {
        /*
         * GameObject mallTableObj = GameObject.Find("MallDragPanel");
         * //MallInitialization tableCom = mallTableObj.GetComponent<MallInitialization>();
         * //tableCom.addDiamond("com.mfp.frozen.cash_30");
         * mallTableObj.SendMessage("addDiamond", "com.mfp.frozen.cash_30");
         *
         * return;
         */

        GameObject  diamondCellObj = transform.parent.gameObject;
        DiamondCell diamondCellCom = diamondCellObj.GetComponent <DiamondCell>();
        int         productID      = diamondCellCom.diamondProductID;

        Debug.Log("Press item cell" + productID);

        bool purchaseSuccess = ItemModel.Instance.buyItem(productID);

        if (purchaseSuccess)
        {
            Debug.Log("Purchase Success!");
            PopupMessage.Show(Language.Get("PURCHASE_ITEM_SUCCESS"));

            packageTableCom.UpdateContent();
        }
        else
        {
            Debug.Log("Not enough diamond. Then jump to mall tab.");
            PopupMessage.Show(Language.Get("NOT_ENOUGH_DIAMOND"));
            MallTab mallTab = GameObject.Find("MallTabButton2").gameObject.GetComponent <MallTab>();
            mallTab.OnClick();
        }
    }
Esempio n. 2
0
    /*
     * public void setActiveTab(int index)
     * {
     *      if (index == 0)
     *      {
     *              GameObject tabObj = transform.Find("TabButton1").gameObject;
     *              MallTab tabCom = tabObj.GetComponent<MallTab>();
     *
     *              tabCom.OnClick();
     *      }
     * }
     */

    // tabIndex: 0, 1, 2
    public void setActiveTable(int tabIndex)
    {
        string[] tabButtonNames = { "MallTabButton1", "MallTabButton2", "MallTabButton3" };

        GameObject tabObj = transform.Find(tabButtonNames[tabIndex]).gameObject;
        MallTab    tabCom = tabObj.GetComponent <MallTab>();

        tabCom.OnClick();
    }
Esempio n. 3
0
    void OnClick()
    {
        //MallInitialization
        //if (mySprite.enabled) {
        // "MallTabButton2"
        MallTab mallTab = GameObject.Find(tabButton).GetComponent <MallTab>();

        mallTab.OnClick();

        fsm.SendEvent(sendEvent);
        //}
    }
Esempio n. 4
0
    void OnClick()
    {
        if (LivesSystem.instance.Lives < LivesSystem.maxLives)
        {
            if (UserManagerCloud.Instance.CurrentUser.UserGoldCoins >= 20)
            {
                // refill energy
                UserManagerCloud.Instance.CurrentUser.UserGoldCoins -= 20;
                UserCloud.Serialize(UserManagerCloud.FILE_NAME_LOCAL);

//				PlayerPrefs.SetInt(LivesSystem.livesKey, LivesSystem.maxLives);
//				PlayerPrefs.Save();
                UserManagerCloud.Instance.CurrentUser.NumsLiveLeft = LivesSystem.maxLives;
                UserCloud.Serialize(UserManagerCloud.FILE_NAME_LOCAL);
                LivesSystem.instance.Lives = LivesSystem.maxLives;

                BIModel.Instance.addPurchaseData("Lives", LivesSystem.maxLives, 20);
                fsm.SendEvent(sendEvent);
                buyLivePanelFsm.SendEvent("NGUI / ON CLICK");
            }
            else
            {
                // go to mall

                MallTab mallTab = GameObject.Find("MallTabButton2").gameObject.GetComponent <MallTab>();
                mallTab.OnClick();

                buyLivePanelFsm.SendEvent("Other Panel");
                mallFsm.SendEvent("Lives");
            }
        }

        /*
         * if (purchasing) {
         *      return;
         * }
         *
         * purchasing = true;
         *
         * InAppPurchasesSystem.OnPurchaseSuccess += OnPurchaseSuccess;
         * InAppPurchasesSystem.OnPurchaseFail += OnPurchaseFail;
         * InAppPurchasesSystem.OnPurchaseCancel += OnPurchaseFail;
         * InAppPurchasesSystem.Instance.PurchaseProduct(InAppPurchasesSystem.InAppPurchase.Lives);
         */
    }
    void OnClick()
    {
        if (purchasing || buyFSM.ActiveStateName != "In")
        {
            return;
        }

        //purchasing = true;

        BasicItem       itemComponent = item.itemPrefab.GetComponent <BasicItem>();
        ItemProductData productData   = ItemModel.Instance.getItemProductData(itemComponent.ItemName, packIndex);

        bool purchaseSuccess = ItemModel.Instance.buyItem(productData);

        if (purchaseSuccess)
        {
            Debug.Log("Purchase success");
            item.AddItems(itemCount + freeItemCount);
            buyFSM.SendEvent("BuyFinished");
        }
        else
        {
            Debug.Log("Not enough diamond");


            // Popup mall window, with "mall" tab enabled.
            MallTab mallTab = GameObject.Find("MallTabButton2").gameObject.GetComponent <MallTab>();
            mallTab.OnClick();
            mallFSM.SendEvent("Show");
        }

        /*
         * InAppPurchasesSystem.OnPurchaseSuccess += OnPurchaseSuccess;
         * InAppPurchasesSystem.OnPurchaseFail += OnPurchaseFail;
         * InAppPurchasesSystem.OnPurchaseCancel += OnPurchaseFail;
         * InAppPurchasesSystem.Instance.PurchaseProduct(purchaseId);
         */
    }