Exemple #1
0
        public StrategyGameRenderingFactory(GameRenderingConfig renderingConfig,
                                            StrategyGameData gameData,
                                            StrategyGameTileSet <TTile> tileSet,
                                            IDerivedTileProducer <TTile, TTexture> tileProducer,
                                            ITextureOperations <TTexture, TColor> textureOperations)
        {
            this.tileProducer      = tileProducer;
            this.textureOperations = textureOperations;
            RenderingConfig        = renderingConfig ?? throw new ArgumentNullException(nameof(RenderingConfig));
            GameData = gameData ?? throw new ArgumentNullException(nameof(GameData));
            TileSet  = tileSet ?? throw new ArgumentNullException(nameof(TileSet));

            var r = new BasicTileRegistry <TTile>();

            foreach (var t in tileSet.Textures.Tiles)
            {
                r.Add(t.Tag, t);
            }

            Tiles = r;

            cellRendering = new TagSetRenderingFactory(this);
            boolRendering = new BoolRenderingFactory(this);
            RenderControl = new RendererControl(tileSet.TileSize, renderingConfig.RenderType);
            EnableCache   = true;
        }
Exemple #2
0
        /// <summary>
        ///   Loads all tiles using the given content loader. Returns a
        ///   BasicTileRegistry to allow access to the contained tiles.
        /// </summary>
        /// <returns></returns>
        public ITileRegistry <TTile> LoadTexturePack()
        {
            var registry = new BasicTileRegistry <TTile>();

            foreach (var tf in tp.TextureFiles)
            {
                foreach (var x in tf.ProduceTiles())
                {
                    registry.Add(x.Tag, x);
                }
            }

            return(registry);
        }