public void SetUpPurchasePlaneOnAndroid(string productID)
        {
            AdRewardType rewardType = AdRewardType.BagSlot_2;

            MyAdType adType = MyAdType.CPAd;

            if (productID.Equals(PurchaseManager.extra_bag_2_id))
            {
                rewardType = AdRewardType.BagSlot_2;
                adType     = MyAdType.RewardedVideoAd;
            }
            else if (productID.Equals(PurchaseManager.extra_bag_3_id))
            {
                rewardType = AdRewardType.BagSlot_3;
                adType     = MyAdType.RewardedVideoAd;
            }
            else if (productID.Equals(PurchaseManager.extra_equipmentSlot_id))
            {
                rewardType = AdRewardType.EquipmentSlot;
                adType     = MyAdType.RewardedVideoAd;
            }
            else if (productID.Equals(PurchaseManager.gold_100_id))
            {
                rewardType = AdRewardType.Gold;
                adType     = MyAdType.RewardedVideoAd;
            }

            switch (Application.internetReachability)
            {
            case NetworkReachability.NotReachable:
                hintHUD.SetUpSingleTextTintHUD("无网络连接");
                break;

            case NetworkReachability.ReachableViaCarrierDataNetwork:
            case NetworkReachability.ReachableViaLocalAreaNetwork:
                if (productID.Equals(PurchaseManager.gold_100_id))
                {
                    purchasePendingHUD.SetUpPurchasePendingHUDOnAndroid(productID, adType, rewardType, delegate
                    {
                        BuyRecord.Instance.RecordLastGoldAdTime();
                        Player.mainPlayer.totalGold += 100;
                        GameManager.Instance.persistDataManager.UpdateBuyGoldToPlayerDataFile();
                        if (ExploreManager.Instance != null)
                        {
                            ExploreManager.Instance.expUICtr.UpdatePlayerGold();
                        }
                    }, null);
                }
                else
                {
                    purchasePendingHUD.SetUpPurchasePendingHUDOnAndroid(productID, adType, rewardType, delegate
                    {
                        bagItemsDisplay.UpdateBagTabs();
                    }, null);
                }

                break;
            }
        }
예제 #2
0
        public void SetUpPurchasePlaneOnAndroid(string productID)
        {
            AdRewardType rewardType = AdRewardType.Life;

            MyAdType adType = MyAdType.RewardedVideoAd;

            if (productID.Equals(PurchaseManager.skill_point_id))
            {
                rewardType = AdRewardType.SkillPoint;
                adType     = MyAdType.CPAd;
            }
            else if (productID.Equals(PurchaseManager.new_life_id))
            {
                rewardType = AdRewardType.Life;
                adType     = MyAdType.RewardedVideoAd;
            }

            switch (Application.internetReachability)
            {
            case NetworkReachability.NotReachable:
                hintHUD.SetUpSingleTextTintHUD("无网络连接");
                break;

            case NetworkReachability.ReachableViaCarrierDataNetwork:
            case NetworkReachability.ReachableViaLocalAreaNetwork:
                if (productID.Equals(PurchaseManager.new_life_id))
                {
                    QuitFight();
                    HideFullMask();
                    purchaseHUD.SetUpPurchasePendingHUDOnAndroid(productID, adType, rewardType, delegate(MyAdType myAdType) {
                        PlayerPartlyRecomeToLifeCallBack();
                    }, delegate {
                        buyLifeQueryHUD.SetUpWhenADUnexpectedFailOnAndroid(delegate {
                            SetUpPurchasePlaneOnAndroid(PurchaseManager.new_life_id);
                        }, CancelBuyLife);
                    });
                }
                else if (productID.Equals(PurchaseManager.skill_point_id))
                {
                    enterExitHUD.QuitEnterExitHUD();
                    purchaseHUD.SetUpPurchasePendingHUDOnAndroid(productID, adType, rewardType, delegate(MyAdType myAdType) {
                        PlayerGetASkillPointReward();
                    }, null);
                }
                break;
            }
        }
예제 #3
0
        public void SetUpPurchasePendingHUDOnAndroid(string productId, MyAdType myAdType, AdRewardType adRewardType, AdCallBack sucessCallBack, AdCallBack failCallBack)
        {
#if !UNITY_ANDROID && !UNITY_EDITOR
            return;
#endif

            this.currentAdType = myAdType;

            Time.timeScale = 0;

            currentPurchasingItemId = productId;

            this.adSuccessCallBack = sucessCallBack;
            this.adFailCallBack    = failCallBack;

            gameObject.SetActive(true);

            pendingTint.gameObject.SetActive(false);

            string query = string.Empty;

            switch (adRewardType)
            {
            case AdRewardType.BagSlot_2:
                query = "观看广告后可\n<color=orange>解锁背包2</color>\n是否确认观看广告?";
                queryWatchADHUD.SetUpQueryWatchAdHUD(query, OnConfirmWatchAd, QuitPurchasePendingHUD);
                break;

            case AdRewardType.BagSlot_3:
                query = "观看广告后可\n<color=orange>解锁背包3</color>\n是否确认观看广告?";
                queryWatchADHUD.SetUpQueryWatchAdHUD(query, OnConfirmWatchAd, QuitPurchasePendingHUD);
                break;

            case AdRewardType.EquipmentSlot:
                query = "观看广告后可\n<color=orange>解锁装饰槽</color>\n是否确认观看广告?";
                queryWatchADHUD.SetUpQueryWatchAdHUD(query, OnConfirmWatchAd, QuitPurchasePendingHUD);
                break;

            case AdRewardType.Gold:
                double timeSpanInSeconds = 0;
                bool   canRewatch        = CheckCanReWatchGoldAd(out timeSpanInSeconds);
                if (canRewatch)
                {
                    query = "观看广告后可\n<color=orange>获得100金币</color>\n是否确认观看广告?";
                    queryWatchADHUD.SetUpQueryWatchAdHUD(query, OnConfirmWatchAd, QuitPurchasePendingHUD);
                }
                else
                {
                    int minuteLeft  = (1800 - (int)timeSpanInSeconds) / 60;
                    int secondsLeft = (1800 - (int)timeSpanInSeconds) % 60;
                    query = string.Format("<color=orange>{0}{1}:{2}{3}</color>后可以重新观看广告",
                                          minuteLeft < 10 ? "0" : "",
                                          minuteLeft,
                                          secondsLeft < 10 ? "0": "",
                                          secondsLeft);
                    queryWatchADHUD.SetUpQueryWatchAdHUDWhenCantWatch(query, timeSpanInSeconds, delegate {
                        query = "观看广告后可\n<color=orange>获得100金币</color>\n是否确认观看广告?";
                        queryWatchADHUD.SetUpQueryWatchAdHUD(query, OnConfirmWatchAd, QuitPurchasePendingHUD);
                    }, QuitPurchasePendingHUD);
                }

                break;

            case AdRewardType.Life:
                OnConfirmWatchAd();
                QuitPurchasePendingHUD();
                break;

            case AdRewardType.SkillPoint:
                OnConfirmWatchAd();
                QuitPurchasePendingHUD();
                break;
            }
        }