private IEnumerator loadConfirmation(PrefabContentKey prefabKey, IglooCatalogItemData item, Sprite icon, IglooCatalogItem catalogItem)
        {
            AssetRequest <GameObject> request = Content.LoadAsync(prefabKey);

            yield return(request);

            GameObject newConfirmation = UnityEngine.Object.Instantiate(request.Asset, base.transform, worldPositionStays: false);

            newConfirmation.GetComponent <IglooCatalogPurchaseConfirmation>().SetItem(item, icon, this, catalogItem, (RectTransform)catalogScrollRect.transform);
            hideConfirmation();
            confirmation = newConfirmation;
        }
        private void onPooledObjectAdded(RectTransform item, int index)
        {
            if (index >= filteredDefinitions.Count)
            {
                return;
            }
            StaticGameDataDefinition staticGameDataDefinition = filteredDefinitions[index];
            IglooCatalogItem         component            = item.GetComponent <IglooCatalogItem>();
            IglooCatalogItemData     iglooCatalogItemData = null;

            if (staticGameDataDefinition.GetType() == typeof(DecorationDefinition))
            {
                DecorationDefinition decorationDefinition = (DecorationDefinition)staticGameDataDefinition;
                if (!decorationProgressionStatus.TryGetValue(decorationDefinition.Id, out var value))
                {
                    value = new ProgressionUtils.ParsedProgression <DecorationDefinition>(decorationDefinition, -1, null, levelLocked: false, progressionLocked: false, decorationDefinition.IsMemberOnly);
                }
                iglooCatalogItemData = new IglooCatalogItemData(decorationDefinition, value);
                component.SetItem(iglooCatalogItemData, this);
                try
                {
                    Content.LoadAsync(component.SetImageFromTexture2D, decorationDefinition.Icon);
                }
                catch (Exception ex)
                {
                    Log.LogException(this, ex);
                }
            }
            else if (staticGameDataDefinition.GetType() == typeof(StructureDefinition))
            {
                StructureDefinition structureDefinition = (StructureDefinition)staticGameDataDefinition;
                if (!structureProgressionStatus.TryGetValue(structureDefinition.Id, out var value2))
                {
                    value2 = new ProgressionUtils.ParsedProgression <StructureDefinition>(structureDefinition, -1, null, levelLocked: false, progressionLocked: false, structureDefinition.IsMemberOnly);
                }
                iglooCatalogItemData = new IglooCatalogItemData(structureDefinition, value2);
                component.SetItem(iglooCatalogItemData, this);
                try
                {
                    Content.LoadAsync(component.SetImageFromTexture2D, structureDefinition.Icon);
                }
                catch (Exception ex)
                {
                    Log.LogException(this, ex);
                }
            }
            else
            {
                Log.LogErrorFormatted(this, "Definition was not a Decoration or a Structure!");
            }
        }
 public void SetItem(IglooCatalogItemData item, Sprite icon, IglooCatalogController catalog, IglooCatalogItem catalogItem, RectTransform scrollRectTransform)
 {
     this.catalog         = catalog;
     this.item            = item;
     this.catalogItem     = catalogItem;
     titleText.text       = Service.Get <Localizer>().GetTokenTranslation(item.TitleToken);
     descriptionText.text = Service.Get <Localizer>().GetTokenTranslation(item.DescriptionToken);
     StartCoroutine(waitForItemIcon());
     setState(ConfirmationState.Pending);
     setPurchaseCount(1);
     ConfirmationPlacement.PositionConfirmation((RectTransform)catalogItem.transform, scrollRectTransform);
     logItemViewed(item);
     if (notificationBreadcrumbController == null)
     {
         notificationBreadcrumbController = Service.Get <NotificationBreadcrumbController>();
     }
     Service.Get <EventDispatcher>().AddListener <IglooServiceEvents.DecorationPurchaseFailed>(onDecorationPurchaseFailed);
 }
Пример #4
0
 public void SetItem(IglooCatalogItemData itemData, IglooCatalogController catalog)
 {
     this.itemData = itemData;
     this.catalog  = catalog;
     if (itemData.IsDecoration())
     {
         breadcrumb.SetBreadcrumbId(decorationBreadcrumbType, itemData.ID.ToString());
         structureSizeIcon.SetActive(value: false);
     }
     else
     {
         breadcrumb.SetBreadcrumbId(structureBreadcrumbType, itemData.ID.ToString());
         structureIconSpriteSelector.SelectSprite(itemData.StructureSize - 1);
         structureSizeIcon.SetActive(value: true);
     }
     titleText.text = Service.Get <Localizer>().GetTokenTranslation(itemData.TitleToken);
     priceText.text = itemData.Cost.ToString();
     ShowItemStatus();
 }
 public void ShowConfirmation(IglooCatalogItemData item, Sprite icon, IglooCatalogItem catalogItem)
 {
     CoroutineRunner.Start(loadConfirmation(PurchaseConfirmationPrefabKey, item, icon, catalogItem), this, "");
 }
 protected void logItemViewed(IglooCatalogItemData item)
 {
 }