Beispiel #1
0
        public void SetUpButton(CatalogItemData catalogItemData, Color foreground, Color background, bool isCreatorNameHidden = false)
        {
            itemData = catalogItemData;
            DCustomEquipment equipment = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(itemData.equipment);

            if (isCreatorNameHidden)
            {
                DisableName();
            }
            CreatorNameText.text = itemData.creatorName;
            CatalogItemIcon component = GetComponent <CatalogItemIcon>();

            AbstractImageBuilder.CallbackToken callbackToken = default(AbstractImageBuilder.CallbackToken);
            callbackToken.Id           = itemData.clothingCatalogItemId;
            callbackToken.DefinitionId = equipment.DefinitionId;
            base.itemImageBuilder.RequestImage(equipment, component.SetIcon, callbackToken, background, foreground);
            if (!isAlreadyOwned)
            {
                isAlreadyOwned = ((itemData.equipment.equipmentId != 0) ? true : false);
            }
            ItemOwned.SetActive(isAlreadyOwned);
            PriceTagText.text = itemData.cost.ToString();
            PriceTag.SetActive(!isAlreadyOwned);
            int definitionId = equipment.DefinitionId;
            Dictionary <int, TemplateDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >();
            TemplateDefinition templateDefinition           = dictionary.Values.ToList().First((TemplateDefinition x) => x.Id == definitionId);

            isMemberUnlocked = !templateDefinition.IsMemberOnly || Service.Get <CPDataEntityCollection>().IsLocalPlayerMember();
            if (!isMemberUnlocked)
            {
                MemberLock.SetActive(value: true);
            }
        }
        private bool onSaveClothingClicked(CustomizerUIEvents.ConfirmSaveClickedEvent evt)
        {
            bool flag = false;

            try
            {
                itemModel.CustomEquipmentModel = EquipmentNetworkUtils.GetModelFromCustomizerChildList(customizerChildren, currentTemplateDefition, decalDefinitionIds);
                flag = true;
            }
            catch (Exception ex)
            {
                Log.LogException(this, ex);
            }
            if (flag)
            {
                serviceEventChannel.AddListener <InventoryServiceEvents.EquipmentCreated>(onEquipmentCreated);
                serviceEventChannel.AddListener <InventoryServiceErrors.EquipmentCreationError>(onEquipmentCreationError);
                CustomEquipment equipmentRequest = CustomEquipmentResponseAdaptor.ConvertCustomEquipmentToRequest(itemModel.CustomEquipmentModel);
                Service.Get <INetworkServicesManager>().InventoryService.CreateCustomEquipment(equipmentRequest);
                logItemCreatedAnalytics();
            }
            else
            {
                CustomizationContext.EventBus.DispatchEvent(default(CustomizerUIEvents.SaveClothingItemError));
            }
            return(false);
        }
        private bool onSubmitCatalogChallengeItemClicked(CustomizerUIEvents.ConfirmSubmitClickedEvent evt)
        {
            bool flag = false;

            try
            {
                itemModel.CustomEquipmentModel = EquipmentNetworkUtils.GetModelFromCustomizerChildList(customizerChildren, currentTemplateDefition, decalDefinitionIds);
                flag = true;
            }
            catch (Exception ex)
            {
                Log.LogException(this, ex);
            }
            if (flag)
            {
                CustomEquipment equipment             = CustomEquipmentResponseAdaptor.ConvertCustomEquipmentToRequest(itemModel.CustomEquipmentModel);
                long            activeThemeScheduleId = Service.Get <CatalogServiceProxy>().GetActiveThemeScheduleId();
                Service.Get <INetworkServicesManager>().CatalogService.SubmitCatalogThemeItem(activeThemeScheduleId, equipment);
                CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.SubmitClothingItemStart(itemModel.CustomEquipmentModel));
            }
            else
            {
                CustomizationContext.EventBus.DispatchEvent(default(CustomizerUIEvents.SubmitClothingItemError));
            }
            return(false);
        }
    private bool onInventoryRetrieved(InventoryServiceEvents.InventoryLoaded evt)
    {
        Service.Get <EventDispatcher>().RemoveListener <InventoryServiceEvents.InventoryLoaded>(onInventoryRetrieved);
        DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle;

        if (!localPlayerHandle.IsNull)
        {
            InventoryData inventoryData = Service.Get <CPDataEntityCollection>().AddComponent <InventoryData>(localPlayerHandle);
            inventoryData.Inventory = new Dictionary <long, InventoryIconModel <DCustomEquipment> >();
            inventoryData.CurrentAvatarEquipment = new List <long>();
            for (int i = 0; i < evt.Inventory.Count; i++)
            {
                try
                {
                    DCustomEquipment data = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(evt.Inventory[i]);
                    InventoryIconModel <DCustomEquipment> value = new InventoryIconModel <DCustomEquipment>(data.Id, data, isEquipped: false, isMemberItem: true);
                    inventoryData.Inventory.Add(data.Id, value);
                }
                catch (KeyNotFoundException)
                {
                }
            }
        }
        else
        {
            Log.LogError(this, "Unable to find the LocalPlayerHandle.");
        }
        if (callback != null)
        {
            callback();
            callback = null;
        }
        return(false);
    }
        private bool onPurchaseComplete(CatalogServiceEvents.ItemPurchaseCompleteEvent e)
        {
            int coins = Service.Get <CPDataEntityCollection>().GetComponent <CoinsData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).Coins;

            if (e.Response.newCoinTotal < coins)
            {
                coins -= (int)e.Response.newCoinTotal;
                Service.Get <CPDataEntityCollection>().GetComponent <CoinsData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).RemoveCoins(coins);
            }
            if (selectedItem.clothingCatalogItemId == purchaseItem.clothingCatalogItemId && buyPanel != null)
            {
                buyPanel.SetState(CatalogShopBuyPanelState.Success);
            }
            if (itemForPurchase.HasValue)
            {
                DCustomEquipment data = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(itemForPurchase.Value);
                data.Id = e.Response.equipmentId;
                data.DateTimeCreated = DateTime.UtcNow.GetTimeInMilliseconds();
                DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle;
                InventoryData    component         = Service.Get <CPDataEntityCollection>().GetComponent <InventoryData>(localPlayerHandle);
                if (component != null)
                {
                    InventoryIconModel <DCustomEquipment> value = new InventoryIconModel <DCustomEquipment>(data.Id, data, isEquipped: false, isMemberItem: true);
                    component.Inventory.Add(data.Id, value);
                    Service.Get <NotificationBreadcrumbController>().AddPersistentBreadcrumb(BreadcrumbType, data.Id.ToString());
                }
                else
                {
                    Log.LogError(this, "Unable to locate InventoryData object.");
                }
            }
            Service.Get <CatalogServiceProxy>().cache.ClearCache();
            return(false);
        }
        protected void SetEquipment()
        {
            DCustomEquipment  dCustomEquipment  = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(ItemData.equipment);
            AvatarDetailsData avatarDetailsData = new AvatarDetailsData();

            DCustomEquipment[] outfit = ((dCustomEquipment.Parts.Length != 0) ? new DCustomEquipment[1] {
                dCustomEquipment
            } : new DCustomEquipment[0]);
            avatarDetailsData.Init(outfit);
            if (!Service.Get <CPDataEntityCollection>().LocalPlayerHandle.IsNull&& Service.Get <CPDataEntityCollection>().TryGetComponent <AvatarDetailsData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle, out var component))
            {
                avatarDetailsData.BodyColor = component.BodyColor;
            }
            AvatarRenderTextureComponent.RenderAvatar(avatarDetailsData);
        }
    private bool onInventoryRetrieved(InventoryServiceEvents.InventoryLoaded evt)
    {
        Service.Get <EventDispatcher>().RemoveListener <InventoryServiceEvents.InventoryLoaded>(onInventoryRetrieved);
        DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle;

        if (!localPlayerHandle.IsNull)
        {
            inventoryData           = Service.Get <CPDataEntityCollection>().AddComponent <InventoryData>(localPlayerHandle);
            inventoryData.Inventory = new Dictionary <long, InventoryIconModel <DCustomEquipment> >();
            inventoryData.CurrentAvatarEquipment = new List <long>();
            setTemplateData();
            for (int i = 0; i < evt.Inventory.Count; i++)
            {
                try
                {
                    DCustomEquipment data = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(evt.Inventory[i]);
                    InventoryIconModel <DCustomEquipment> value = new InventoryIconModel <DCustomEquipment>(data.Id, data, isEquipped: false, isMemberItem: true);
                    inventoryData.Inventory.Add(data.Id, value);
                }
                catch (KeyNotFoundException)
                {
                }
            }
            if (Service.Get <CPDataEntityCollection>().TryGetComponent(localPlayerHandle, out AvatarDetailsData component) && component.Outfit != null)
            {
                DCustomOutfit currentAvatarEquipment = default(DCustomOutfit);
                currentAvatarEquipment.Equipment = component.Outfit;
                setCurrentAvatarEquipment(currentAvatarEquipment);
            }
        }
        else
        {
            Log.LogError(this, "Unable to find the LocalPlayerHandle.");
        }
        setDefaultScreen();
        string key = SceneTransitionService.SceneArgs.ShowCatalogOnEntry.ToString();

        if (Service.Get <SceneTransitionService>().HasSceneArg(key) && (bool)Service.Get <SceneTransitionService>().GetSceneArg(key))
        {
            showCatalog();
        }
        return(false);
    }
Beispiel #8
0
        private void loadItemIcon(DisneyStoreItemData item)
        {
            if (item.Definition.Icon != null && !string.IsNullOrEmpty(item.Definition.Icon.Key))
            {
                Content.LoadAsync(onCustomIconLoadComplete, item.Definition.Icon);
                return;
            }
            List <DReward> rewards = item.GetRewards();

            switch (rewards[0].Category)
            {
            case RewardCategory.equipmentTemplates:
            {
                Dictionary <int, TemplateDefinition> dictionary2 = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >();
                if (dictionary2.TryGetValue((int)rewards[0].UnlockID, out var value2))
                {
                    Texture2DContentKey equipmentIconPath = EquipmentPathUtil.GetEquipmentIconPath(value2.AssetName);
                    Content.LoadAsync(delegate(string key, Texture2D texture)
                        {
                            onIconReady(texture, 0);
                        }, equipmentIconPath);
                }
                break;
            }

            case RewardCategory.equipmentInstances:
                renderRewardItem(rewards[0].EquipmentRequest.definitionId, CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(rewards[0].EquipmentRequest));
                break;

            case RewardCategory.decorationInstances:
            {
                Dictionary <int, DecorationDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, DecorationDefinition> >();
                if (dictionary.TryGetValue((int)rewards[0].UnlockID, out var value))
                {
                    Content.LoadAsync(delegate(string path, Texture2D asset)
                        {
                            onIconReady(asset, 1);
                        }, value.Icon);
                }
                break;
            }
            }
        }
        private void loadItemIcon(MarketplaceEventItem item)
        {
            List <DReward> rewards = item.GetRewards();

            for (int i = 0; i < rewards.Count; i++)
            {
                TemplateDefinition value;
                switch (rewards[i].Category)
                {
                case RewardCategory.equipmentTemplates:
                {
                    Dictionary <int, TemplateDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >();
                    if (dictionary.TryGetValue((int)rewards[0].UnlockID, out value))
                    {
                        Texture2DContentKey equipmentIconPath = EquipmentPathUtil.GetEquipmentIconPath(value.AssetName);
                        Content.LoadAsync(delegate(string key, Texture2D texture)
                            {
                                onIconReady(texture);
                            }, equipmentIconPath);
                        TitleText.text = Service.Get <Localizer>().GetTokenTranslation(value.Name);
                        itemNameForBI  = value.AssetName;
                        isMemberOnly   = value.IsMemberOnly;
                    }
                    return;
                }

                case RewardCategory.equipmentInstances:
                {
                    Dictionary <int, TemplateDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >();
                    if (dictionary.TryGetValue(rewards[0].EquipmentRequest.definitionId, out value))
                    {
                        TitleText.text = Service.Get <Localizer>().GetTokenTranslation(value.Name);
                        itemNameForBI  = value.AssetName;
                        isMemberOnly   = value.IsMemberOnly;
                    }
                    renderRewardItem(rewards[0].EquipmentRequest.definitionId, CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(rewards[0].EquipmentRequest));
                    return;
                }
                }
            }
        }
        private void addChallengeItem(int currentThemeDataIndex)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate(ChallengeItem);

            gameObject.transform.SetParent(scrollRectContent, worldPositionStays: false);
            CatalogChallengeItem component = gameObject.GetComponent <CatalogChallengeItem>();

            component.SetChallengeTheme(themes[currentThemeDataIndex], currentThemeDataIndex);
            CatalogItemIcon  component2       = gameObject.GetComponent <CatalogItemIcon>();
            CurrentThemeData currentThemeData = themes[currentThemeDataIndex];

            if (currentThemeData.mostPopularItem.HasValue)
            {
                DCustomEquipment equipment     = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(currentThemeData.mostPopularItem.Value.equipment);
                Color[]          colorsByIndex = Service.Get <CatalogServiceProxy>().themeColors.GetColorsByIndex(currentThemeDataIndex);
                AbstractImageBuilder.CallbackToken callbackToken = default(AbstractImageBuilder.CallbackToken);
                callbackToken.Id           = ((equipment.Id == 0) ? currentThemeData.mostPopularItem.Value.clothingCatalogItemId : equipment.Id);
                callbackToken.DefinitionId = equipment.DefinitionId;
                base.itemImageBuilder.RequestImage(equipment, component2.SetIcon, callbackToken, Color.clear, colorsByIndex[0]);
            }
        }
Beispiel #11
0
    public static DataEntityHandle AddLocalPlayerProfileDataComponents(DataEntityCollection dataEntityCollection, LocalPlayerData data, bool isOnline = false)
    {
        DataEntityHandle dataEntityHandle = dataEntityCollection.FindEntityByName("LocalPlayer");

        if (dataEntityHandle.IsNull)
        {
            return(dataEntityHandle);
        }
        if (data == null)
        {
            return(dataEntityHandle);
        }
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out DisplayNameData component2))
        {
            component2 = dataEntityCollection.AddComponent <DisplayNameData>(dataEntityHandle);
        }
        component2.DisplayName = data.name;
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out QuestStateData component3))
        {
            component3 = dataEntityCollection.AddComponent <QuestStateData>(dataEntityHandle);
        }
        component3.Data = data.quests;
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out AvatarDetailsData component4))
        {
            component4           = dataEntityCollection.AddComponent <AvatarDetailsData>(dataEntityHandle);
            component4.BodyColor = AvatarService.DefaultBodyColor;
            component4.Outfit    = new DCustomEquipment[0];
        }
        if (data.outfit != null && data.outfit.Count > 0)
        {
            component4.Outfit = CustomEquipmentResponseAdaptor.ConvertResponseToOutfit(data.outfit);
        }
        if (data.profile != null)
        {
            Dictionary <int, AvatarColorDefinition> avatarColors = Service.Get <GameData>().Get <Dictionary <int, AvatarColorDefinition> >();
            component4.BodyColor = AvatarBodyColorAdaptor.GetColorFromDefinitions(avatarColors, data.profile.colour);
        }
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out ProfileData component5))
        {
            component5 = dataEntityCollection.AddComponent <ProfileData>(dataEntityHandle);
        }
        component5.PenguinAgeInDays = ((data.profile != null) ? data.profile.daysOld : 0);
        component5.IsOnline         = isOnline;
        component5.IsMigratedPlayer = (data.migrationData != null && data.migrationData.status.Equals("MIGRATED"));
        component5.ZoneId           = data.zoneId;
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out MembershipData component6))
        {
            component6 = dataEntityCollection.AddComponent <MembershipData>(dataEntityHandle);
        }
        component6.IsMember                 = data.member;
        component6.MembershipType           = (data.member ? MembershipType.Member : MembershipType.None);
        component6.MembershipExpireDate     = data.membershipExpireDate;
        component6.MembershipTrialAvailable = data.trialAvailable;
        if (!component6.IsMember && Service.Get <AllAccessService>().IsAllAccessActive())
        {
            component6.IsMember       = true;
            component6.MembershipType = MembershipType.AllAccessEventMember;
        }
        logPlayerStatusBI(data);
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out SubscriptionData component7))
        {
            component7 = dataEntityCollection.AddComponent <SubscriptionData>(dataEntityHandle);
        }
        component7.SubscriptionVendor         = data.subscriptionVendor;
        component7.SubscriptionProductId      = data.subscriptionProductId;
        component7.SubscriptionPaymentPending = data.subscriptionPaymentPending;
        component7.SubscriptionRecurring      = data.recurring;
        if (data.migrationData != null && data.migrationData.legacyAccountData != null)
        {
            if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out LegacyProfileData component8))
            {
                component8 = dataEntityCollection.AddComponent <LegacyProfileData>(dataEntityHandle);
            }
            component8.Username     = data.migrationData.legacyAccountData.username;
            component8.IsMember     = data.migrationData.legacyAccountData.member;
            component8.CreatedDate  = data.migrationData.legacyAccountData.createdDate;
            component8.MigratedDate = data.migrationData.migratedDate;
        }
        byte[] array = new byte[data.tutorialData.Count];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = (byte)data.tutorialData[i];
        }
        if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out TutorialData component9))
        {
            component9 = dataEntityCollection.AddComponent <TutorialData>(dataEntityHandle);
        }
        component9.Data = new BitArray(array);
        switch (data.id.type)
        {
        case PlayerId.PlayerIdType.SESSION_ID:
            if (!dataEntityCollection.HasComponent <SessionIdData>(dataEntityHandle))
            {
                dataEntityCollection.AddComponent(dataEntityHandle, delegate(SessionIdData component)
                {
                    component.SessionId = Convert.ToInt64(data.id.id);
                });
            }
            break;

        case PlayerId.PlayerIdType.SWID:
            if (!dataEntityCollection.HasComponent <SwidData>(dataEntityHandle))
            {
                dataEntityCollection.AddComponent <SwidData>(dataEntityHandle).Swid = data.id.id;
            }
            break;
        }
        setClaimedRewardIds(dataEntityCollection, dataEntityHandle, data.claimedRewardIds);
        addDailySpinDataComponent(dataEntityCollection, dataEntityHandle, data);
        return(dataEntityHandle);
    }
Beispiel #12
0
 private void renderClothingInstance()
 {
     itemImageBuilder = ItemImageBuilder.acquire();
     itemImageBuilder.RequestImage(CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(reward.EquipmentRequest), onEquipmentInstanceLoaded);
 }
Beispiel #13
0
 private bool onStatsResponse(CatalogServiceProxyEvents.StatsReponse evt)
 {
     if (isStatsLoading)
     {
         isStatsLoading = false;
         if (Model.State == CatalogState.StatsView)
         {
             shopScroller.ClearScroller();
             stats = evt.Stats;
             if (TotalSold != null)
             {
                 TotalSold.text = stats.TotalItemsSold.ToString();
             }
             if (BestSellerSold != null)
             {
                 try
                 {
                     BestSellerSold.text = stats.StatsItem.numberSold.ToString();
                     if (stats.TotalItemsSold < stats.StatsItem.numberSold)
                     {
                         BestSellerSold.text = stats.TotalItemsSold.ToString();
                     }
                 }
                 catch (Exception ex)
                 {
                     Log.LogErrorFormatted(this, "An error occured when setting best seller sold text. Message: {0}", ex.Message);
                 }
             }
             if (TotalSubmitted != null)
             {
                 TotalSubmitted.text = stats.TotalItemsPurchased.ToString();
             }
             if (stats.StatsData != null)
             {
                 DCustomEquipment[] outfit;
                 if (stats.StatsItem.equipment.parts == null || stats.StatsItem.equipment.parts.Length == 0)
                 {
                     outfit = new DCustomEquipment[0];
                 }
                 else
                 {
                     DCustomEquipment dCustomEquipment = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(stats.StatsItem.equipment);
                     outfit = new DCustomEquipment[1] {
                         dCustomEquipment
                     };
                 }
                 AvatarDetailsData avatarDetailsData = new AvatarDetailsData();
                 avatarDetailsData.Init(outfit);
                 if (this.avatarDetailsData != null)
                 {
                     avatarDetailsData.BodyColor = this.avatarDetailsData.BodyColor;
                 }
                 AvatarRenderTextureComponent.RenderAvatar(avatarDetailsData);
                 shopScroller.items         = stats.StatsData;
                 shopScroller.filteredItems = stats.StatsData;
                 shopScroller.GenerateScrollData(stats.StatsData);
                 for (int i = 0; i < shopScroller.numShopRows; i++)
                 {
                     shopScroller.Scroller.AddElement(1);
                 }
                 shopScroller.isShopScrollInitialized = true;
                 shopScroller.lastNumShopRows         = shopScroller.numShopRows;
             }
         }
     }
     return(false);
 }
 private void setUpAvatarDetails(AvatarDetailsData avatarDetailsData, OtherPlayerData data)
 {
     DCustomEquipment[] outfit = (data.outfit == null) ? new DCustomEquipment[0] : CustomEquipmentResponseAdaptor.ConvertResponseToOutfit(data.outfit);
     if (data.profile != null)
     {
         Dictionary <int, AvatarColorDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, AvatarColorDefinition> >();
         if (dictionary.TryGetValue(data.profile.colour, out AvatarColorDefinition value) && value != null)
         {
             if (ColorUtility.TryParseHtmlString("#" + value.Color, out Color color))
             {
                 avatarDetailsData.Init(outfit, color);
                 return;
             }
             Log.LogErrorFormatted(this, "Could not parse a color from color string {0}", value.Color);
             avatarDetailsData.Init(outfit);
         }
         else
         {
             Log.LogErrorFormatted(this, "Avatar color definitions did not contain a value for color id {0}", data.profile.colour);
             avatarDetailsData.Init(outfit);
         }
     }
     else
     {
         avatarDetailsData.Init(outfit);
     }
 }