Exemplo n.º 1
0
        private ISpriteManager SetUpSpriteManager(IEntityDataProvider graphicsDataProvider)
        {
            var spriteManager = new BLTSpriteManager();

            var graphicsData = graphicsDataProvider.GetData();

            foreach (var spriteCollection in graphicsData)
            {
                var entity = EntitySerializer.DeserializeOutsideEngine(spriteCollection);

                foreach (SpriteSheet sheet in entity.Components)
                {
                    switch (sheet.Type)
                    {
                    case "SingleSprite":
                        spriteManager.AddAnimated(_spriteLoader.LoadSingleSprite(sheet.Name, sheet.Path, sheet.SpriteWidth, sheet.SpriteHeight, sheet.Scaling, TILE_SPACING, sheet.Frames.Count), sheet.Frames);
                        break;

                    case "TilesetBox":
                        spriteManager.AddAnimated(_spriteLoader.LoadTileset_BoxType(sheet.Name, sheet.Path, sheet.SpriteWidth, sheet.SpriteHeight, sheet.Scaling, TILE_SPACING, sheet.Frames.Count), sheet.Frames);
                        break;

                    case "TilesetWall":
                        spriteManager.Add(_spriteLoader.LoadTileset_WallType(sheet.Name, sheet.Path, sheet.SpriteWidth, sheet.SpriteHeight, sheet.Scaling, TILE_SPACING));
                        break;

                    case "FourDirection":
                        spriteManager.Add(_spriteLoader.LoadFourDirectionSprite(sheet.Name, sheet.Path, sheet.SpriteWidth, sheet.SpriteHeight, sheet.Scaling, TILE_SPACING));
                        break;

                    default:
                        throw new Exception($"Unknown sprite sheet type '{sheet.Type}' in SetUpSpriteManager");
                    }
                }
            }

            return(spriteManager);
        }