Exemplo n.º 1
0
    private void AddProduct(ConfigurationBuilder builder, InAppProductList.ProductInfo product, ProductType productType)
    {
        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.

        if (product.m_nStoreFlag == InAppProductList.Store.ALL)
        {
            builder.AddProduct(product.m_sProductIdentifier, productType);
        }
        else
        {
            // @todo: Not tested yet
            if ((product.m_nStoreFlag & InAppProductList.Store.GOOGLE) != 0 && Application.platform == RuntimePlatform.Android)
            {
                builder.AddProduct(product.m_sProductIdentifier, productType);
            }
            else if ((product.m_nStoreFlag & InAppProductList.Store.APPLE) != 0 && Application.platform == RuntimePlatform.IPhonePlayer)
            {
                builder.AddProduct(product.m_sProductIdentifier, productType);
            }
        }

        // @todo: Handle different id logic

        /*
         * builder.AddProduct( product.m_sProductIdentifier, productType, new IDs(){
         *              { product.m_sProductAppleIdentifier, AppleAppStore.Name },
         *              { product.m_sProductGoogleIdentifier, GooglePlay.Name },
         *      });
         */
    }
Exemplo n.º 2
0
    void InitialiseShopList()
    {
        // @debug variables
        for (int i = 0; i < 20; ++i)
        {
            // @debug
            int nIndex = i % 2;
            GemLibrary.GemSet gemType = (GemLibrary.GemSet)nIndex;

            GameObject itemIcon = (GameObject)Instantiate(m_ItemPrefab, m_ItemIconStartPos, Quaternion.identity);
            Button     button   = itemIcon.GetComponent <Button>();
            button.image.sprite = m_GemLibrary.GemsSetList[nIndex].GetGemContainer(GemContainerSet.BLUE_GEM_CONTAINER_INDEX)[0];

            Text label = itemIcon.GetComponentInChildren <Text>();
            label.text = m_GemLibrary.GemsSetList[nIndex].m_sGemContainerSetName;

            ItemIcon ic = itemIcon.GetComponent <ItemIcon>();
            ic.m_ItemType = gemType;

            itemIcon.transform.GetChild(2).gameObject.SetActive(false);

            // Hide lock if unlocked
            if (GameData.Instance.m_Sets.Contains(gemType))
            {
                itemIcon.transform.GetChild(1).gameObject.SetActive(false);
                ic.m_bLocked = false;
            }
            else
            {
                Color c = label.color;
                c.a         = 0.5f;
                label.color = c;

                ic.m_bLocked = true;

                string productIdentifier = InAppProductList.GetProductIdentifier(InAppProductList.ProductType.AVATAR, nIndex);
                if (InAppProductList.Instance.NonConsumableList.ContainsKey(productIdentifier))
                {
                    InAppProductList.ProductInfo product = InAppProductList.Instance.NonConsumableList[productIdentifier];

                    GameObject priceTag  = itemIcon.transform.GetChild(2).gameObject;
                    Text       priceText = priceTag.GetComponent <Text>();
                    priceText.text = product.m_sPrice;
                }
            }

            m_ItemIcons.Add(itemIcon);
        }

        // @todo Resize Item Prefab for new art assets
        // Resize base on item count
        Vector2 dimension = m_ItemContentTransform.sizeDelta;

        dimension.x += (m_fItemIconWidth + ITEM_PAD) * (m_ItemIcons.Count - 1);
        m_ItemContentTransform.sizeDelta = dimension;

        // Add item icons to content

        for (int i = 0; i < m_ItemIcons.Count; ++i)
        {
            GameObject    itemIcon          = m_ItemIcons[i];
            RectTransform itemIconTransform = itemIcon.GetComponent <RectTransform>();
            itemIconTransform.SetParent(m_ItemContentTransform);

            Vector3 pos = itemIconTransform.localPosition;
            pos.x = m_ItemIconStartPos.x + i * (ITEM_PAD + m_fItemIconWidth);
            pos.y = m_ItemIconStartPos.y;
            pos.z = m_ItemIconStartPos.z;
            itemIconTransform.localPosition = pos;
            itemIconTransform.localScale    = Vector3.one;

            SetItemIconEnable(itemIcon, i == 0);
        }

        m_ItemPrefab.SetActive(false);

        // @todo set scroll to equipped
        // @todo back button in item screen will scroll to equipped as well
    }