本文整理汇总了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();
}