Exemplo n.º 1
0
 private void ShowBuyButton(string title, string sku, string payload, ref int offset, bool isSubscription = false)
 {
     if (_processingPayment)
     {
         GUI.Box(new Rect(Screen.width / 2 - BUTTON_WIDTH / 2, offset, BUTTON_WIDTH, BUTTON_HEIGHT), title);
     }
     else
     {
         if (GUI.Button(new Rect(Screen.width / 2 - BUTTON_WIDTH / 2, offset, BUTTON_WIDTH, BUTTON_HEIGHT), title))
         {
             _processingPayment = true;
             if (isSubscription)
             {
                 if (!OpenIAB.areSubscriptionsSupported())
                 {
                     Debug.LogError("Subscriptions are not supported. Sorry!");
                 }
                 else
                 {
                     OpenIAB.purchaseSubscription(sku, payload);
                 }
             }
             else
             {
                 OpenIAB.purchaseProduct(sku, payload);
             }
         }
     }
     offset += OFFSET + BUTTON_HEIGHT;
 }
Exemplo n.º 2
0
 /// <summary>
 /// purchase subscription based on its product id.
 /// Our delegates then fire the appropriate succeeded/fail event.
 /// On Android we have to check whether subscriptions are supported
 /// </summary>
 public static void PurchaseSubscription(string productId)
 {
     if (OpenIAB.areSubscriptionsSupported())
     {
         OpenIAB.purchaseSubscription(GetIAPObject(productId).GetIdentifier());
     }
     else
     {
         BillingNotSupported("Subscriptions not available.");
     }
 }
Exemplo n.º 3
0
    void DrawShopWindow(int windowID)
    {
        // Close button
        if (GUI.Button(new Rect(WINDOW_WIDTH - 35, 5, 30, 30), "X"))
        {
            ShowShopWindow(false);
        }

        if (_processingPayment)
        {
            GUI.Box(new Rect(10, 40, WINDOW_WIDTH - 20, SIDE_BUTTON_HEIGHT), "Processing payment...");
            return;
        }

        GUI.skin.box.alignment = TextAnchor.MiddleCenter;

        // Buy Infinite Ammo subscription
        Rect rect = new Rect(10, 40, WINDOW_WIDTH - 20, SIDE_BUTTON_HEIGHT);

        if (_playerAmmoBox.IsInfinite)
        {
            GUI.Box(rect, "Infinite ammo plan active");
        }
        else if (GUI.Button(rect, "Buy infinite ammo"))
        {
            _processingPayment = true;
            OpenIAB.purchaseSubscription(SKU_INFINITE_AMMO);
        }

        // Buy Ammo
        rect = new Rect(10, SIDE_BUTTON_HEIGHT + 45, WINDOW_WIDTH - 20, SIDE_BUTTON_HEIGHT);
        if (_playerAmmoBox.IsFull)
        {
            GUI.Box(rect, "Ammo box is full");
        }
        else if (_playerAmmoBox.IsInfinite)
        {
            GUI.Box(rect, "Buy Ammo");
        }
        else if (GUI.Button(rect, string.Format("Buy Ammo ({0} rounds)", N_ROUNDS)))
        {
            _processingPayment = true;
            OpenIAB.purchaseProduct(SKU_AMMO);
        }

        // Buy MedKit
        rect = new Rect(10, SIDE_BUTTON_HEIGHT * 2 + 50, WINDOW_WIDTH - 20, SIDE_BUTTON_HEIGHT);
        if (_playerMedKitPack.IsFull)
        {
            GUI.Box(rect, "MedKit pack is full");
        }
        else if (GUI.Button(rect, "Buy MedKit"))
        {
            _processingPayment = true;
            OpenIAB.purchaseProduct(SKU_MEDKIT);
        }

        // Buy Cowboy Hat
        rect = new Rect(10, SIDE_BUTTON_HEIGHT * 3 + 55, WINDOW_WIDTH - 20, SIDE_BUTTON_HEIGHT);
        if (_playerHat.PutOn)
        {
            GUI.Box(rect, "Cowboy hat purchased");
        }
        else if (GUI.Button(rect, "Buy Cowboy Hat"))
        {
            _processingPayment = true;
            OpenIAB.purchaseProduct(SKU_COWBOY_HAT);
        }
    }