示例#1
0
 private void Start()
 {
     instance     = this;
     eventChannel = new EventChannel(Service.Get <EventDispatcher>());
     eventChannel.AddListener <PlayerSpawnedEvents.LocalPlayerSpawned>(onLocalPlayerSpawned);
     gate             = new ParentGate();
     gate.OnContinue += onGatePassed;
 }
示例#2
0
    private void showGate()
    {
        IContentInterruption contentInterruption = new ParentGate();

        contentInterruption.OnReturn   += onGateFailed;
        contentInterruption.OnContinue += onGatePassed;
        contentInterruption.Show(base.transform);
    }
        public void ReloadPurchaseFlow(CSGConfig csgConfig, string planId)
        {
            this.csgConfig = csgConfig;
            string text = this.csgConfig.BaseUrl + "?config={0}&planId={1}&pageType=checkout";

            if (webViewController != null)
            {
                IContentInterruption gate = new ParentGate();
                webViewController.Show(text, gate, "Membership.Purchase.CSG.WebviewerTitle", AllowPopups: true, openPopupInNewBrowser: false, 1.8f, 3f);
            }
            else
            {
                ShowFlow(text, "Membership.Purchase.CSG.WebviewerTitle");
            }
        }
        public void ShowFlow(string url, string title)
        {
            closeUserInitiated          = true;
            webViewGameObject           = new GameObject("WebView");
            webViewController           = new WebViewController(webViewGameObject);
            webViewController.OnLoaded += delegate
            {
                if (!string.IsNullOrEmpty("CPI.Membership.WebviewEventComm"))
                {
                    webViewController.RegisterJSFunction("CPI.Membership.WebviewEventComm");
                    webViewController.CallFunction("CPI.Membership.EnableWebviewEventComm");
                }
            };
            webViewController.OnFailed          += onWebViewFailed;
            webViewController.OnClosed          += onWebViewClosed;
            webViewController.OnReceivedMessage += onReceivedMessage;
            WebViewController obj = webViewController;

            obj.FormatURL = (WebViewController.FormatURLDelegate)Delegate.Combine(obj.FormatURL, new WebViewController.FormatURLDelegate(setURLParameters));
            IContentInterruption gate = new ParentGate();

            webViewController.Show(url, gate, title, webViewPopupKey, AllowPopups: true, openPopupInNewBrowser: false, 1.8f, 3f);
        }
        private void Start()
        {
            CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>();
            string text  = "";
            string text2 = "";
            bool   flag  = false;
            bool   productIsRecurring = true;
            bool   flag2 = false;

            PriceTitleText.gameObject.SetActive(value: false);
            PriceTitleSpinner.gameObject.SetActive(value: true);
            gate             = new ParentGate();
            gate.OnContinue += onGatePassed;
            RenewalPanel.SetActive(value: true);
            if (cPDataEntityCollection.TryGetComponent <SubscriptionData>(cPDataEntityCollection.LocalPlayerHandle, out subscriptionData))
            {
                string subscriptionProductId = subscriptionData.SubscriptionProductId;
                if (!string.IsNullOrEmpty(subscriptionProductId))
                {
                    Product productBySku = Service.Get <CommerceService>().GetProductBySku(subscriptionProductId);
                    if (productBySku != null)
                    {
                        flag = true;
                        productIsRecurring = productBySku.IsRecurring();
                        text = $"{productBySku.price} {productBySku.currencyCode}";
                        PriceTitleText.token = "Membership.MembershipTerms.TermsTitle." + productBySku.sku_duration;
                        PriceTitleText.UpdateToken();
                        if (!subscriptionData.SubscriptionRecurring)
                        {
                            RenewTitleText.token = "Settings.MembershipInfo.FinishedTitle";
                            RenewTitleText.UpdateToken();
                        }
                        PriceTitleText.gameObject.SetActive(value: true);
                        PriceTitleSpinner.gameObject.SetActive(value: false);
                    }
                    else
                    {
                        productBySku = Service.Get <CommerceService>().GetProductByVendorSku(subscriptionData.SubscriptionVendor, subscriptionProductId);
                        if (productBySku != null)
                        {
                            flag = true;
                            productIsRecurring   = productBySku.IsRecurring();
                            PriceTitleText.token = "Membership.MembershipTerms.TermsTitle." + productBySku.sku_duration;
                            PriceTitleText.UpdateToken();
                            if (!subscriptionData.SubscriptionRecurring)
                            {
                                RenewTitleText.token = "Settings.MembershipInfo.FinishedTitle";
                                RenewTitleText.UpdateToken();
                            }
                            PriceTitleText.gameObject.SetActive(value: true);
                            PriceTitleSpinner.gameObject.SetActive(value: false);
                        }
                        else if (!Service.Get <CommerceService>().MatchCurrentVendor(subscriptionData.SubscriptionVendor) && subscriptionData.SubscriptionVendor.ToLower() == "csg")
                        {
                            csgProcessor = new CommerceProcessorCSG();
                            if (csgProcessor != null)
                            {
                                csgProcessor.InitializeStore();
                                List <Product> allProducts = Service.Get <CommerceService>().GetAllProducts();
                                foreach (Product item in allProducts)
                                {
                                    csgProcessor.AddProduct(item.shared_key, item.gp_store_sku, item.apple_store_sku, item.csg_id, item.sku_duration, item.sku_trial_duration);
                                }
                                CommerceProcessorCSG commerceProcessorCSG = csgProcessor;
                                commerceProcessorCSG.SkuInventoryResponse = (CommerceProcessor.SkuInventoryResponseSend)Delegate.Combine(commerceProcessorCSG.SkuInventoryResponse, new CommerceProcessor.SkuInventoryResponseSend(handleCSGDataLoaded));
                                csgProcessor.GetSKUDetails();
                                flag2 = true;
                            }
                        }
                    }
                }
            }
            else
            {
                Log.LogError(this, "Could not find SubscriptionData on the local player");
            }
            if (!flag && !flag2)
            {
                PriceTitleText.token = "Settings.MembershipInfo.MonthlyCostUnavailableTitle";
                PriceTitleText.UpdateToken();
                PriceText.gameObject.SetActive(value: false);
                RenewalPanel.SetActive(value: false);
                PriceTitleText.gameObject.SetActive(value: true);
                PriceTitleSpinner.gameObject.SetActive(value: false);
            }
            if (cPDataEntityCollection.TryGetComponent <MembershipData>(cPDataEntityCollection.LocalPlayerHandle, out membershipData))
            {
                text2 = membershipData.MembershipExpireDateTime.ToString("d");
            }
            else
            {
                Log.LogError(this, "Could not find MembershipData on the local player");
            }
            PriceText.text      = text;
            RenewDateText.text  = text2;
            PriceLegalText.text = getLegalText(productIsRecurring, subscriptionData.SubscriptionRecurring, text);
            ManageSubscriptionButton.onClick.AddListener(onClicked);
        }