示例#1
0
 public void VIPButtonOnClick()
 {
     if (GameSystem.GetInstance().CheckIsActivated())
     {
         GameSoundSystem.GetInstance().PlayRandomSound();
         string title   = TextManager.GetText("confirm_buy_vip_gift_title");
         string content = string.Format(TextManager.GetText("vip_gift_desc"), ShopData.GetShopData(IAPManager.IAPProduct.VIP).number);
         content = content.Replace('\n', ' ');
         //GameSystem.GetInstance().gameUI.vipConfirmMenu.SetConfirmCallback(ConfirmBuyVIPCallback);
         GameSystem.GetInstance().gameUI.vipConfirmMenu.SetContent(title, content);
         GameSystem.GetInstance().gameUI.vipConfirmMenu.Show(true);
     }
 }
示例#2
0
    // callback from platform purchse
    public void PayCallback(string param)
    {
        string[] returnParams = param.Split(","[0]);
        if (returnParams.Length != 2)
        {
            Debug.LogError("Invalid pay callback params!");
            return;
        }
        string     result    = returnParams[0];
        string     productID = returnParams[1];
        IAPProduct product   = IDProductMap [productID];

        if (result.Equals("succeed"))
        {
            ShopData shopData = ShopData.GetShopData(product);
            switch (product)
            {
            case IAPProduct.ActiveGame:
                GameSystem.GetInstance().ActivateGame();
                UMengManager.Pay(Constant.ACTIVATE_GAME_RMB_PRICE, Umeng.GA.PaySource.支付宝, UMengManager.Item_IAP[(int)shopData.product], 1, Constant.ACTIVATE_GAME_BONUS);
                break;

            case IAPProduct.VIP:
                GameSystem.GetInstance().Coin += shopData.number;
                PlayerProfile.SaveCoin(GameSystem.GetInstance().Coin);
                UMengManager.Bonus(shopData.number, (Umeng.GA.BonusSource)UMengManager.Bonus_Source_Buy_VIP);
                UMengManager.Pay(shopData.price, Umeng.GA.PaySource.支付宝, UMengManager.Item_IAP[(int)shopData.product], 1, shopData.number);

                GameSystem.GetInstance().BecomeVIP();
                break;

            case IAPProduct.WhiteBlock1:
            case IAPProduct.WhiteBlock2:
            case IAPProduct.WhiteBlock3:
            case IAPProduct.WhiteBlock4:
            case IAPProduct.WhiteBlock5:
                GameSystem.GetInstance().Coin += shopData.number;
                PlayerProfile.SaveCoin(GameSystem.GetInstance().Coin);
                UMengManager.Pay(shopData.price, Umeng.GA.PaySource.支付宝, shopData.number);
                UMengManager.Pay(shopData.price, Umeng.GA.PaySource.支付宝, UMengManager.Item_IAP[(int)shopData.product], 1, shopData.number);

#if UNITY_IOS
                if (GameSystem.GetInstance().UnlockRecommendMode)
                {
                    GameSystem.GetInstance().UnlockRecommendMode = false;
                    GameSystem.GetInstance().PayUnlockRecommendModeCallback(true);
                }
#else
                if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                {
                    GameSystem.GetInstance().PayUnlockModeCallback(true);
                }
#endif
                break;

            case IAPProduct.Rescue:
                GameSystem.GetInstance().CurrentModeLogic.Rescue();
                GameSystem.GetInstance().ChangeState(GameSystem.States.GamePreview);

                UMengManager.Pay(Constant.RESCUE_RMB_PRICE, Umeng.GA.PaySource.支付宝, UMengManager.Item_IAP[(int)shopData.product], 1, Constant.RESCUE_BASIC_PRICE);
                break;
            }
        }
        else if (result.Equals("failed"))
        {
#if !UNITY_IOS
            string rescueTitleText = TextManager.GetText("pay_failed");
            GameSystem.GetInstance().gameUI.confirmMenu.SetContent(rescueTitleText, null, ConfirmStyle.OnlyYes);
            GameSystem.GetInstance().gameUI.confirmMenu.Show(true);
#endif
            switch (product)
            {
            case IAPProduct.ActiveGame:
                GameSystem.GetInstance().gameUI.confirmMenu.SetConfirmCallback((confirmResult) => {
                    if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                    {
                        GameSystem.GetInstance().JumpToGameEnd();
                    }
                });
                break;

            case IAPProduct.VIP:
                break;

            case IAPProduct.WhiteBlock1:
            case IAPProduct.WhiteBlock2:
            case IAPProduct.WhiteBlock3:
            case IAPProduct.WhiteBlock4:
            case IAPProduct.WhiteBlock5:
#if UNITY_IOS
                if (GameSystem.GetInstance().UnlockRecommendMode)
                {
                    GameSystem.GetInstance().UnlockRecommendMode = false;
                    GameSystem.GetInstance().PayUnlockRecommendModeCallback(false);
                }
#else
                if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                {
                    GameSystem.GetInstance().PayUnlockModeCallback(false);
                }
#endif
                break;

            case IAPProduct.Rescue:
                GameSystem.GetInstance().gameUI.confirmMenu.SetConfirmCallback((confirmResult) => {
                    if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                    {
                        GameSystem.GetInstance().JumpToGameEnd();
                    }
                });
                break;
            }
        }
        else if (result.Equals("cancel"))
        {
#if !UNITY_IOS
            string rescueTitleText = TextManager.GetText("pay_cancel");
            GameSystem.GetInstance().gameUI.confirmMenu.SetContent(rescueTitleText, null, ConfirmStyle.OnlyYes);
            GameSystem.GetInstance().gameUI.confirmMenu.Show(true);
#endif
            switch (product)
            {
            case IAPProduct.ActiveGame:
                GameSystem.GetInstance().gameUI.confirmMenu.SetConfirmCallback((confirmResult) => {
                    if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                    {
                        GameSystem.GetInstance().JumpToGameEnd();
                    }
                });
                break;

            case IAPProduct.VIP:
                break;

            case IAPProduct.WhiteBlock1:
            case IAPProduct.WhiteBlock2:
            case IAPProduct.WhiteBlock3:
            case IAPProduct.WhiteBlock4:
            case IAPProduct.WhiteBlock5:
#if UNITY_IOS
                if (GameSystem.GetInstance().UnlockRecommendMode)
                {
                    GameSystem.GetInstance().UnlockRecommendMode = false;
                    GameSystem.GetInstance().PayUnlockRecommendModeCallback(false);
                }
#else
                if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                {
                    GameSystem.GetInstance().PayUnlockModeCallback(false);
                }
#endif
                break;

            case IAPProduct.Rescue:
                GameSystem.GetInstance().gameUI.confirmMenu.SetConfirmCallback((confirmResult) => {
                    if (GameSystem.GetInstance().CurrentState == GameSystem.States.WaveComplete)
                    {
                        GameSystem.GetInstance().JumpToGameEnd();
                    }
                });
                break;
            }
        }
    }