本文整理汇总了C#中Ants.Location.SimpleAdd方法的典型用法代码示例。如果您正苦于以下问题:C# Location.SimpleAdd方法的具体用法?C# Location.SimpleAdd怎么用?C# Location.SimpleAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ants.Location
的用法示例。
在下文中一共展示了Location.SimpleAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareVisionArrays
void PrepareVisionArrays()
{
var viewRadius = Convert.ToInt32(Math.Floor(Math.Sqrt(ViewRadius2)));
var list = new List<Location>();
for (int x = -viewRadius; x <= viewRadius; x++)
for (int y = -viewRadius; y <= viewRadius; y++)
if (x * x + y * y <= ViewRadius2)
list.Add(new Location { X = x, Y = y });
FullVision = list.ToArray();
list = new List<Location>();
foreach (var loc in FullVision)
foreach (var dLoc in PathFinding.Directions)
{
var newLoc = loc.SimpleAdd(dLoc);
if (!FullVision.Contains(newLoc, Location.Comparer))
{
list.Add(loc);
break;
}
}
MoveVision = list.Distinct(Location.Comparer).ToArray();
list = new List<Location>();
for (int x = -AttackRadius2; x <= AttackRadius2; x++)
for (int y = -AttackRadius2; y <= AttackRadius2; y++)
if (x * x + y * y <= AttackRadius2)
{
var loc = new Location { X = x, Y = y };
list.Add(loc);
for (int dir = 0; dir < 4; dir++)
list.Add(loc.SimpleAdd(PathFinding.Directions[dir]));
}
AttackRangeP1 = list.Distinct(Location.Comparer).ToArray();
list = new List<Location>();
for (int x = -4; x <= 4; x++)
for (int y = -4; y <= 4; y++)
if (x * x + y * y <= 16 && x * x + y * y >= 4)
list.Add(new Location { X = x, Y = y });
FinalAttack = list.OrderBy(loc => loc.X * loc.X + loc.Y * loc.Y).ToArray();
}