Ejemplo n.º 1
0
        public List <TextureTile> Generate(TextureGrid grid)
        {
            var cellMapEntries = grid.CellMappings.Where(e => !string.IsNullOrWhiteSpace(e.Key)).ToList();

            if (cellMapEntries.Count <= 1)
            {
                return(new List <TextureTile>());
            }

            var selectionFactory = TileTagEntrySelectionFactory.FromTagsAsTextKey(cellMapEntries.Select(e => e.Key ?? "").ToArray());
            var selections       = selectionFactory.ToSelectionArray();
            var tileCount        = Math.Pow(selections.Length, 4);
            var width            = (int)Math.Ceiling(Math.Sqrt(tileCount));

            TextureTile Create(ITileTagEntrySelection m1,
                               ITileTagEntrySelection m2,
                               ITileTagEntrySelection m3,
                               ITileTagEntrySelection m4)
            {
                var key      = new CellMapTileSelectorKey(m1, m2, m3, m4);
                var tileName = key.Format(grid.Name, grid.Pattern);
                var x        = key.LinearIndex % width;
                var y        = key.LinearIndex / width;

                return(new TextureTile(true, x, y, tileName)
                {
                    SelectorHint = FormatCellMapSelectorKey(key)
                });
            }

            var x = from m4 in selections
                    from m3 in selections
                    from m2 in selections
                    from m1 in selections
                    select Create(m1, m2, m3, m4);

            return(x.ToList());
        }
Ejemplo n.º 2
0
 public bool TryFind(string tag, CellMapTileSelectorKey selector, out TRenderTile tile)
 {
     return(baseRegistry.TryFind(selector.Format(tag, format), out tile));
 }