本文整理汇总了C#中Ants.Location.CorrectLocationForMapWrapAround方法的典型用法代码示例。如果您正苦于以下问题:C# Location.CorrectLocationForMapWrapAround方法的具体用法?C# Location.CorrectLocationForMapWrapAround怎么用?C# Location.CorrectLocationForMapWrapAround使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ants.Location
的用法示例。
在下文中一共展示了Location.CorrectLocationForMapWrapAround方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEveryVisibleSquare
public static Location[] GetEveryVisibleSquare()
{
List<Location> offsets = new List<Location>();
List<Location> visibleSquares = new List<Location>();
int squares = (int)Math.Floor(Math.Sqrt(ViewRadius2));
for (int r = -1 * squares; r <= squares; ++r)
{
for (int c = -1 * squares; c <= squares; ++c)
{
int square = r * r + c * c;
if (square < ViewRadius2)
{
offsets.Add(new Location(r, c));
}
}
}
for (int i = 0; i < MyAnts.Count; i++)
for (int j = 0; j < offsets.Count; j++)
{
Location offset = new Location(MyAnts[i].Location.Row + offsets[j].Row, MyAnts[i].Location.Col + offsets[j].Col);
offset.CorrectLocationForMapWrapAround();
visibleSquares.Add(offset);
}
List<Location> finalList = new List<Location>();
for (int i = 0; i < visibleSquares.Count; i++)
if (!finalList.Contains(visibleSquares[i]))
finalList.Add(visibleSquares[i]);
return finalList.ToArray();
}