Beispiel #1
0
    public override void Initialize()
    {
        if (this.m_ProductsDict == null)
        {
            this.InitialProductItems();
        }

        string unconfirmedPurchaseID = PlayerPrefs.GetString(UNCONFIRMED_PURCHASE_ID_KEY, string.Empty);

        if (string.IsNullOrEmpty(unconfirmedPurchaseID))
        {
            string unconfirmedProductID = PlayerPrefs.GetString(UNCONFIRMED_PRODUCT_ID_KEY, string.Empty);
            if (string.IsNullOrEmpty(unconfirmedProductID))
            {
                NdIdleContext idleContext = new NdIdleContext();
                this.ChangeContext(idleContext);
                this.State = ShopActionState.Idle;
            }
            else
            {
                this.m_CurrentPurchaseID = unconfirmedProductID;
                NdRequestPurchaseIDContext requestContext = new NdRequestPurchaseIDContext();
                this.ChangeContext(requestContext);
                this.State = ShopActionState.Operating;
            }
        }
        else
        {
            NdConfirmContext confirmContext = new NdConfirmContext();
            this.ChangeContext(confirmContext);
            this.State = ShopActionState.Operating;
        }
    }
Beispiel #2
0
    public override void Execute()
    {
        if (NdCenter.Instace.CurrentBuyState == BuyState.Success)
        {
            NdConfirmContext confirmContext = new NdConfirmContext();
            this.ShopModule.ChangeContext(confirmContext);
        }
        else if (NdCenter.Instace.CurrentBuyState == BuyState.Fail)
        {
            PlayerPrefs.DeleteKey(NdShopUtility.UNCONFIRMED_PRODUCT_ID_KEY);
            PlayerPrefs.DeleteKey(NdShopUtility.UNCONFIRMED_PURCHASE_ID_KEY);
            PlayerPrefs.Save();

            NdIdleContext context = new NdIdleContext();
            this.ShopModule.ChangeContext(context);
            this.ShopModule.State = ShopActionState.Fail;

            this.ShopModule.OnPurchaseFailed(new PurchaseFailInformation()
            {
                Reason = PurchaseFailedReason.Cancel, ErrorDescription = NdCenter.Instace.BuyError
            });
        }
    }