本文整理汇总了C#中Selection.ContainsTile方法的典型用法代码示例。如果您正苦于以下问题:C# Selection.ContainsTile方法的具体用法?C# Selection.ContainsTile怎么用?C# Selection.ContainsTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection.ContainsTile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectTiles
public static Selection SelectTiles(Map thisMap, Selection selection, int left, int top, int width, int height)
{
var result = new Selection();
result.AddRange(selection);
for (int x = left; x < left + width; x++)
for (int y = top; y < top + height; y++)
{
Tile t = thisMap.GetTileAcrossWrap(x, y);
if (t != null && !selection.ContainsTile(t))
result.Add(t.GetCoordinate());
}
return result;
}
示例2: ScrambleSelection
public static Map ScrambleSelection(Map thisMap, Selection selection, int distance, bool dontScrambleWater)
{
Map map = (Map)thisMap.Clone();
var unswappedTiles = map.GetAllTiles().Where(t => selection.ContainsTile(t) && !(t.IsWater() && dontScrambleWater)).ToList();
unswappedTiles = Utility.ShuffleList(unswappedTiles);
Dictionary<Tile, Tile> swaps = new Dictionary<Tile, Tile>();
while (unswappedTiles.Count > 0)
{
var tileToSwap = unswappedTiles[0];
Tile tileToSwapWith = null;
for (var i = 1; i < unswappedTiles.Count; i++)
{
var t = unswappedTiles[i];
if (map.GetDistanceBetween(t.X, t.Y, tileToSwap.X, tileToSwap.Y) <= distance)
{
tileToSwapWith = t;
break;
}
}
if (tileToSwapWith != null)
{
swaps[tileToSwap] = tileToSwapWith;
unswappedTiles.Remove(tileToSwapWith);
}
unswappedTiles.Remove(tileToSwap);
}
foreach (var tile in swaps.Keys)
{
Utility.SwapTiles(tile, swaps[tile]);
}
map.CalculateFreshWater();
map.CalculateIrrigationStatus();
map.AssignContinentIds();
return map;
}