Beispiel #1
0
        private static List <TileObject> LoadTileObjects(ResourceCollection resources, int index)
        {
            List <TileObject>    tileObjects   = new List <TileObject>();
            IEnumerable <string> subCategories = resources.SubCategories(index);

            foreach (string subCategory in subCategories)
            {
                string[] elementsOfSubCategory = resources.ElementsOfSubcategory(subCategory);
                string   config = resources.GetPossibleConfig(subCategory);
                if (config == null)
                {
                    throw new FileNotFoundException($"All tiles must have json file: {subCategory}");
                }
                Config configInstance = LoadConfig(config);
                Dictionary <string, BitmapImage> bitmaps = resources.LoadBitmaps(
                    resources.Categories[index], subCategory, ResourceDir
                    );
                Sprite     sprite     = new Sprite(elementsOfSubCategory, configInstance?.Offsets, bitmaps);
                TileObject tileObject = new TileObject(
                    (resources.Categories[index], subCategory), sprite, configInstance
                    );
                tileObjects.Add(tileObject);
            }

            return(tileObjects);
        }