A purchasable item from the item catalog
Inheritance: PlayFabModelBase
Example #1
0
    public void ShowOffer(string guid)
    {
        UB_OfferData details = null;

        PF_GameData.Offers.TryGetValue(PF_PlayerData.pendingOffers[guid].OfferId, out details);

        if (details != null)
        {
            this.OfferName.text = details.OfferName;
            this.OfferDesc.text = details.OfferDescription;

            if (details.ItemToGrant != null)
            {
                PlayFab.ClientModels.CatalogItem grantItem = PF_GameData.catalogItems.Find((i) =>
                {
                    return(i.ItemId == details.ItemToGrant);
                });

                if (grantItem != null)
                {
                    this.ItemName.text = grantItem.DisplayName;

                    string iconString = string.Empty;
                    Dictionary <string, string> customData = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(grantItem.CustomData);
                    customData.TryGetValue("icon", out iconString);

                    this.ItemIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(iconString);
                    this.OfferItem.gameObject.SetActive(true);
                }
                else
                {
                    Debug.Log("Grant Item not found in catalog");
                    this.ItemName.text = GlobalStrings.GRANT_CATALOG_ERR_MSG;
                }
            }
            else
            {
                this.OfferItem.gameObject.SetActive(false);
            }

            if (details.StoreToUse != null && this.selectedDetails != null)
            {
                this.VisitStore.GetComponent <Text>().text = "Visit " + this.selectedDetails.StoreToUse;
                this.OfferStore.gameObject.SetActive(true);
            }
            else
            {
                this.OfferStore.gameObject.SetActive(false);
            }
        }
        else
        {
            Debug.Log("Could not locate a corresponding offer on the server.");
        }
    }