Ejemplo n.º 1
0
    public void OpenPurchaseItemScreen(StoreItemContent itemToPurchase)
    {
        MenuNavigation.INSTANCE.selectPurchaseIcon();

        PurchaseItemImageField.sprite = itemToPurchase.itemImage;
        PurchaseItemNameField.text    = itemToPurchase.itemName;

        PurchaseItemCostField.text = string.Format("{0:N}", itemToPurchase.itemCost);
        PurchaseItemCostField.text = CurrencyCodeMapper.GetCurrencySymbol(StoreProperties.INSTANCE.currencyCode) + PurchaseItemCostField.text;

        PurchaseItemDescField.text     = itemToPurchase.itemDesc;
        PurchaseItemCurrCodeField.text = StoreProperties.INSTANCE.currencyCode;

        changePurchaseStatus(PurchaseStatus.CREATING_PURCHASE);

        CreatePaymentAPI_Call existingCreatePaymentAPIcall = StoreProperties.INSTANCE.gameObject.GetComponent <CreatePaymentAPI_Call> ();

        if (existingCreatePaymentAPIcall != null)
        {
            Destroy(existingCreatePaymentAPIcall);
        }

        CreatePaymentAPI_Call createPaymentAPICall = StoreProperties.INSTANCE.gameObject.AddComponent <CreatePaymentAPI_Call> ();

        createPaymentAPICall.accessToken            = StoreProperties.INSTANCE.GetComponent <GetAccessTokenAPI_Call> ().API_SuccessResponse.access_token;
        createPaymentAPICall.transactionDescription = "purchased 1 item from x game";
        createPaymentAPICall.itemCurrency           = StoreProperties.INSTANCE.currencyCode;
        createPaymentAPICall.itemDescription        = itemToPurchase.itemDesc;
        createPaymentAPICall.itemName  = itemToPurchase.itemName;
        createPaymentAPICall.itemPrice = itemToPurchase.itemCost;
        createPaymentAPICall.JSON_CreatePaymentRequest = Resources.Load("Misc/CreatePaymentRequestBody") as TextAsset;

        InvokeRepeating("checkForPurchaseStatusChange", 1f, 1f);
    }
    public void ArrangeItems()
    {
        storeItems = GetComponentsInChildren <StoreItemContent>();

        for (int i = 0; i < storeItems.Length; i++)
        {
            StoreItemContent nextStoreItem = storeItems[i];

            GameObject    nextStoreItemGO   = nextStoreItem.gameObject;
            RectTransform nextStoreItemRect = nextStoreItemGO.GetComponent <RectTransform>();

            nextStoreItemRect.localPosition  = new Vector3(nextStoreItemRect.localPosition.x, 0f, 0f);
            nextStoreItemRect.localPosition += new Vector3(0f, i * -100f, 0f);
        }

        //set the height of the scrollable area to the number of store items multiplied by 100 pixels
        GetComponent <RectTransform>().sizeDelta = new Vector2(350f, 100f * storeItems.Length);

        //hide scrollbar if store has less than 3 items
        if (storeItems.Length < 3)
        {
            scrollbar.SetActive(false);
        }
        else
        {
            scrollbar.SetActive(true);
        }

        scrollbar.GetComponent <Scrollbar>().value = 1f;
    }
Ejemplo n.º 3
0
    public void OnEnable()
    {
        int productCount = UCE_Tmpl_PayPalProduct.dict.Count;

        UIUtils.BalancePrefabs(productSlot.gameObject, productCount, content);

        for (int i = 0; i < productCount; ++i)
        {
            StoreItemContent slot = content.GetChild(i).GetComponent <StoreItemContent>();
            slot.Init(UCE_Tmpl_PayPalProduct.dict.ElementAt(i).Value);
        }
    }
    public Sprite GetSprite(string spriteName)
    {
        for (int i = 0; i < storeItems.Length; i++)
        {
            StoreItemContent nextStoreItem = storeItems[i];

            if (spriteName == nextStoreItem.itemName)
            {
                return(nextStoreItem.itemImage);
            }
        }

        return(Resources.Load <Sprite>("ItemSprites/DefaultImage"));
    }
    public string GetDescription(string itemName)
    {
        for (int i = 0; i < storeItems.Length; i++)
        {
            StoreItemContent nextStoreItem = storeItems[i];

            if (itemName == nextStoreItem.itemName)
            {
                return(nextStoreItem.itemDesc);
            }
        }

        // no description available so return empty string
        return("");
    }