当前位置: 首页>>代码示例>>C#>>正文


C# TileSet.ToArray方法代码示例

本文整理汇总了C#中TileSet.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# TileSet.ToArray方法的具体用法?C# TileSet.ToArray怎么用?C# TileSet.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TileSet的用法示例。


在下文中一共展示了TileSet.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTiles

        public IEnumerable<TileBase> GetTiles(
            Rectangle bounds,
            [NotNull] IEnumerable<TileBase> existingTiles)
        {
            TileSet tiles = new TileSet();
            Queue<TileBase> openTiles = new Queue<TileBase>();
            List<TileBase> removeTiles = new List<TileBase>();

            Rectangle tileBounds;

            foreach (TileBase tile in existingTiles)
            {
                // if tile is in bounds
                // TODO The width and height must also be >= 1px
                tileBounds = tile.GetApproximateBounds();
                if (bounds.IntersectsWith(tileBounds))
                {
                    tiles.Add(tile);

                    if (tile.GetOpenEdgeParts().Any())
                        openTiles.Enqueue(tile);
                }
                else
                    removeTiles.Add(tile);
            }

            foreach (TileBase tile in removeTiles)
                tile.RemoveAdjacent();

            if (tiles.Count < 1)
            {
                TileBase tile = Tiles[0];
                Debug.Assert(tile != null, "tile != null");

                // TODO The width and height must also be >= 1px
                tileBounds = tile.GetApproximateBounds();
                if (!bounds.IntersectsWith(tileBounds))
                {
                    tile = new TileInstance(
                        (Tile) tile,
                        tile.Label,
                        tile.Transform * Matrix3x2.CreateTranslation(bounds.Center - tileBounds.Center));
                }

                // add initial tile to tiles
                tiles.Add(tile);

                // add initial tile to end of openTiles
                openTiles.Enqueue(tile);
            }

            // while there are tiles with no neighbour
            while (openTiles.Count > 0)
            {
                TileBase tile = openTiles.Dequeue();

                // for each edgePart with no neighbour
                foreach (EdgePart edgePart in tile.GetOpenEdgeParts())
                {
                    TileBase newTile = CreateNewTile(tile, edgePart);

                    tiles.Add(newTile);

                    // if newTile is in bounds
                    // TODO The width and height must also be >= 1px
                    tileBounds = newTile.GetApproximateBounds();
                    if (bounds.IntersectsWith(tileBounds))
                    {
                        // add newTile to end of openTiles
                        openTiles.Enqueue(newTile);
                    }
                }
            }

            // Set the style for the new cells
            foreach (TileBase tile in tiles.Where(t => t.Style == null))
            {
                // set cell style from styleManager
                tile.Style = StyleManager.GetStyle(tile);
            }

            return tiles.ToArray();
        }
开发者ID:billings7,项目名称:EscherTilier,代码行数:83,代码来源:Tiling.cs


注:本文中的TileSet.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。