Exemplo n.º 1
0
        public void GetAssetsListByCategoryCorrectly()
        {
            // Arrange
            string          testCategoryA      = "test category A";
            string          testCategoryB      = "test category B";
            CatalogItemPack testDceneAssetPack = new CatalogItemPack
            {
                assets = new List <CatalogItem>
                {
                    new CatalogItem {
                        id = "testItemId1", categoryName = testCategoryA
                    },
                    new CatalogItem {
                        id = "testItemId2", categoryName = testCategoryA
                    },
                    new CatalogItem {
                        id = "testItemId3", categoryName = testCategoryB
                    }
                }
            };

            // Act
            List <CatalogItem> result = sceneCatalogController.GetAssetsListByCategory(testCategoryA, testDceneAssetPack);

            // Assert
            Assert.AreEqual(2, result.Count(x => x.categoryName == testCategoryA), "The number of returned catalog items does not match!");
            Assert.AreEqual(0, result.Count(x => x.categoryName == testCategoryB), "The number of returned catalog items does not match!");
        }
Exemplo n.º 2
0
    public static List <CatalogItemPack> GetCatalogItemPacksFilteredByCategories()
    {
        var assetPacks = DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.GetValues();

        Dictionary <string, CatalogItemPack> assetPackDic = new Dictionary <string, CatalogItemPack>();

        if (DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.ContainsKey(BIWSettings.ASSETS_COLLECTIBLES))
        {
            assetPackDic.Add(BIWSettings.ASSETS_COLLECTIBLES, DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict[BIWSettings.ASSETS_COLLECTIBLES]);
        }
        else
        {
            CreateNewCollectiblePack();
        }

        foreach (CatalogItemPack catalogAssetPack in assetPacks)
        {
            foreach (CatalogItem catalogItem in catalogAssetPack.assets)
            {
                if (catalogItem.IsNFT())
                {
                    continue;
                }
                if (!assetPackDic.ContainsKey(catalogItem.category))
                {
                    CatalogItemPack categoryAssetPack = new CatalogItemPack();
                    categoryAssetPack.SetThumbnailULR(catalogItem.thumbnailURL);
                    categoryAssetPack.title  = catalogItem.category;
                    categoryAssetPack.assets = new List <CatalogItem>();
                    catalogItem.categoryName = catalogAssetPack.title;
                    categoryAssetPack.assets.Add(catalogItem);

                    if (!string.IsNullOrEmpty(categoryAssetPack.title))
                    {
                        if (categoryAssetPack.title.Length == 1)
                        {
                            categoryAssetPack.title = categoryAssetPack.title.ToUpper();
                        }
                        else
                        {
                            categoryAssetPack.title = char.ToUpper(categoryAssetPack.title[0]) + categoryAssetPack.title.Substring(1);
                        }
                    }

                    assetPackDic.Add(catalogItem.category, categoryAssetPack);
                    continue;
                }
                else
                {
                    catalogItem.categoryName = catalogAssetPack.title;
                    assetPackDic[catalogItem.category].assets.Add(catalogItem);
                }
            }
        }

        return(assetPackDic.Values.OrderBy(x => x.title).ToList());
    }
Exemplo n.º 3
0
    public static void AddSceneAssetPack(SceneAssetPack sceneAssetPack)
    {
        if (DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(sceneAssetPack.id))
        {
            return;
        }

        CatalogItemPack catalogItemPack = CreateCatalogItemPack(sceneAssetPack);

        DataStore.i.builderInWorld.catalogItemPackDict.Add(catalogItemPack.id, catalogItemPack);
    }
Exemplo n.º 4
0
    private static CatalogItemPack CreateNewCollectiblePack()
    {
        CatalogItemPack collectiblesItemPack = new CatalogItemPack();

        collectiblesItemPack.id     = BIWSettings.ASSETS_COLLECTIBLES;
        collectiblesItemPack.title  = BIWSettings.ASSETS_COLLECTIBLES;
        collectiblesItemPack.assets = new List <CatalogItem>();
        if (!DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.ContainsKey(collectiblesItemPack.id))
        {
            DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.Add(collectiblesItemPack.id, collectiblesItemPack);
        }
        return(collectiblesItemPack);
    }
Exemplo n.º 5
0
    internal List <CatalogItem> GetAssetsListByCategory(string category, CatalogItemPack sceneAssetPack)
    {
        List <CatalogItem> catalogItemList = new List <CatalogItem>();

        foreach (CatalogItem catalogItem in sceneAssetPack.assets)
        {
            if (category == catalogItem.categoryName)
            {
                catalogItemList.Add(catalogItem);
            }
        }

        return(catalogItemList);
    }
Exemplo n.º 6
0
    public void SetContent(CatalogItemPack catalogItemPack)
    {
        this.catalogItemPack = catalogItemPack;
        titleTxt.text        = this.catalogItemPack.title;

        if (catalogItemPack.id != BIWSettings.ASSETS_COLLECTIBLES)
        {
            GetThumbnail();
        }
        else
        {
            packImg.enabled = true;
            packImg.texture = collectiblesSprite;
        }
    }
Exemplo n.º 7
0
    public static void AddSceneAssetPack(SceneAssetPack sceneAssetPack)
    {
        if (DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(sceneAssetPack.id))
        {
            return;
        }

        CatalogItemPack catalogItemPack = CreateCatalogItemPack(sceneAssetPack);

        //TODO: SmartItems disabled until kernel has them implemented
        if (catalogItemPack.assets.Count != 0)
        {
            DataStore.i.builderInWorld.catalogItemPackDict.Add(catalogItemPack.id, catalogItemPack);
        }
    }
Exemplo n.º 8
0
    public static CatalogItemPack CreateCatalogItemPack(SceneAssetPack sceneAssetPack)
    {
        CatalogItemPack catalogItemPack = new CatalogItemPack();

        catalogItemPack.id    = sceneAssetPack.id;
        catalogItemPack.title = sceneAssetPack.title;

        catalogItemPack.assets = new List <CatalogItem>();

        catalogItemPack.SetThumbnailULR(sceneAssetPack.ComposeThumbnailUrl());

        foreach (SceneObject sceneObject in sceneAssetPack.assets)
        {
            catalogItemPack.assets.Add(CreateCatalogItem(sceneObject));
        }

        return(catalogItemPack);
    }
Exemplo n.º 9
0
    public static List <CatalogItemPack> GetCatalogItemPacksFilteredByCategories()
    {
        var assetPacks = DataStore.i.builderInWorld.catalogItemPackDict.GetValues();

        Dictionary <string, CatalogItemPack> assetPackDic = new Dictionary <string, CatalogItemPack>();

        foreach (CatalogItemPack catalogAssetPack in assetPacks)
        {
            foreach (CatalogItem catalogItem in catalogAssetPack.assets)
            {
                if (!assetPackDic.ContainsKey(catalogItem.category))
                {
                    CatalogItemPack categoryAssetPack = new CatalogItemPack();
                    categoryAssetPack.SetThumbnailULR(catalogItem.thumbnailURL);
                    categoryAssetPack.title  = catalogItem.category;
                    categoryAssetPack.assets = new List <CatalogItem>();
                    catalogItem.categoryName = catalogAssetPack.title;
                    categoryAssetPack.assets.Add(catalogItem);

                    if (!string.IsNullOrEmpty(categoryAssetPack.title))
                    {
                        if (categoryAssetPack.title.Length == 1)
                        {
                            categoryAssetPack.title = categoryAssetPack.title.ToUpper();
                        }
                        else
                        {
                            categoryAssetPack.title = char.ToUpper(categoryAssetPack.title[0]) + categoryAssetPack.title.Substring(1);
                        }
                    }

                    assetPackDic.Add(catalogItem.category, categoryAssetPack);
                    continue;
                }
                else
                {
                    catalogItem.categoryName = catalogAssetPack.title;
                    assetPackDic[catalogItem.category].assets.Add(catalogItem);
                }
            }
        }
        return(assetPackDic.Values.ToList());
    }
Exemplo n.º 10
0
    public static void ConvertCollectiblesPack(List <NFTInfo> nftList)
    {
        if (nftList == null)
        {
            return;
        }

        CatalogItemPack collectiblesItemPack;

        if (!DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(BuilderInWorldSettings.ASSETS_COLLECTIBLES))
        {
            collectiblesItemPack        = new CatalogItemPack();
            collectiblesItemPack.id     = BuilderInWorldSettings.ASSETS_COLLECTIBLES;
            collectiblesItemPack.title  = BuilderInWorldSettings.ASSETS_COLLECTIBLES;
            collectiblesItemPack.assets = new List <CatalogItem>();

            DataStore.i.builderInWorld.catalogItemPackDict.Add(collectiblesItemPack.id, collectiblesItemPack);
        }
        else
        {
            collectiblesItemPack = DataStore.i.builderInWorld.catalogItemPackDict[BuilderInWorldSettings.ASSETS_COLLECTIBLES];
            foreach (CatalogItem catalogItem in collectiblesItemPack.assets)
            {
                if (DataStore.i.builderInWorld.catalogItemDict.ContainsKey(catalogItem.id))
                {
                    DataStore.i.builderInWorld.catalogItemDict.Remove(catalogItem.id);
                }
            }
            collectiblesItemPack.assets.Clear();
        }

        foreach (NFTInfo info in nftList)
        {
            CatalogItem catalogItem = CreateCatalogItem(info);
            if (!DataStore.i.builderInWorld.catalogItemDict.ContainsKey(catalogItem.id))
            {
                DataStore.i.builderInWorld.catalogItemDict.Add(catalogItem.id, catalogItem);
            }

            collectiblesItemPack.assets.Add(catalogItem);
        }
    }
Exemplo n.º 11
0
    internal void SetCatalogAssetPackInListView(CatalogItemPack catalogItemPack)
    {
        sceneCatalogView.SetCatalogTitle(catalogItemPack.title);
        Dictionary <string, List <CatalogItem> > groupedCatalogItem = new Dictionary <string, List <CatalogItem> >();

        foreach (CatalogItem sceneObject in catalogItemPack.assets)
        {
            string titleToUse = sceneObject.categoryName;

            if (!groupedCatalogItem.ContainsKey(titleToUse))
            {
                groupedCatalogItem.Add(titleToUse, GetAssetsListByCategory(titleToUse, catalogItemPack));
            }
        }

        List <Dictionary <string, List <CatalogItem> > > contentList = new List <Dictionary <string, List <CatalogItem> > >
        {
            groupedCatalogItem
        };

        sceneCatalogView.catalogGroupList.SetContent(contentList);
    }
Exemplo n.º 12
0
    public static CatalogItemPack CreateCatalogItemPack(SceneAssetPack sceneAssetPack)
    {
        CatalogItemPack catalogItemPack = new CatalogItemPack();

        catalogItemPack.id    = sceneAssetPack.id;
        catalogItemPack.title = sceneAssetPack.title;

        catalogItemPack.assets = new List <CatalogItem>();

        catalogItemPack.SetThumbnailULR(sceneAssetPack.ComposeThumbnailUrl());

        foreach (SceneObject sceneObject in sceneAssetPack.assets)
        {
            //TODO: SmartItems disabled until kernel has them implemented
            if (!sceneObject.IsSmartItem())
            {
                catalogItemPack.assets.Add(CreateCatalogItem(sceneObject));
            }
        }

        return(catalogItemPack);
    }
Exemplo n.º 13
0
 public void OnCatalogItemPackSelected(CatalogItemPack catalogItemPack)
 {
     ShowCatalogContent();
     SetCatalogAssetPackInListView(catalogItemPack);
     sceneCatalogView.ShowBackButton(true);
 }
Exemplo n.º 14
0
 public void OnCatalogItemPackSelected(CatalogItemPack catalogItemPack)
 {
     ShowCatalogContent();
     SetCatalogAssetPackInListView(catalogItemPack);
 }