本文整理汇总了C#中System.Point.GetDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Point.GetDistanceTo方法的具体用法?C# Point.GetDistanceTo怎么用?C# Point.GetDistanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Point
的用法示例。
在下文中一共展示了Point.GetDistanceTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTeamRadius
double GetTeamRadius(long removedTrooperId = -1, Point addedTrooper = null)
{
double radius = Inf;
for (var i = 0; i < Width; i++)
{
for (var j = 0; j < Height; j++)
{
double maxV = addedTrooper == null ? -Inf : addedTrooper.GetDistanceTo(i, j);
foreach (var trooper in Team)
if (removedTrooperId != trooper.Id)
maxV = Math.Max(maxV, trooper.GetDistanceTo(i, j));
radius = Math.Min(radius, maxV);
}
}
return radius;
}
示例2: GoToEncircling
Point GoToEncircling(Trooper center, Point goal)
{
var bestPoint = new Point(0, 0, Inf);
double optDanger = self.Type == TrooperType.FieldMedic || self.Type == TrooperType.Sniper ? Inf : -Inf;
for (var i = 0; i < Width; i++)
{
for (var j = 0; j < Height; j++)
{
if (map[i, j] == 0 || i == self.X && j == self.Y)
{
if (self.GetDistanceTo(i, j) > 10) // немного ускорит
continue;
// Нужно чтобы хватило ходов
int steps = GetShoterPath(self, new Point(i, j), map, beginFree: true, endFree: true);
if (self.ActionPoints / GetMoveCost() >= steps)
{
// и чтобы не закрывали кратчайший путь:
int before = goal == null ? Inf : GetShoterPath(center, goal, map, beginFree:true, endFree: false);
map[self.X, self.Y] = 0;
map[i, j] = 1;
int after = goal == null ? Inf : GetShoterPath(center, goal, map, beginFree: true, endFree: false);
map[i, j] = 0;
map[self.X, self.Y] = 1;
if ((goal == null || after < Inf) && after <= before)
{
double sum = GetShoterPath(center, new Point(i, j), notFilledMap, beginFree: true, endFree: true);
double dang = danger[i, j] + (goal == null ? 0 : goal.GetDistanceTo(i, j) * 0.01);
if (sum < bestPoint.profit ||
EqualF(sum, bestPoint.profit) &&
(self.Type == TrooperType.FieldMedic || self.Type == TrooperType.Sniper ? (dang < optDanger) : (dang > optDanger))
)
{
bestPoint = new Point(i, j, sum);
optDanger = dang;
}
}
}
}
}
}
return bestPoint.profit >= Inf ? null : bestPoint;
}
示例3: SetVisibleProfit
private void SetVisibleProfit(int x, int y)
{
var position = new Point(x, y);
for(var i = 0; i < Width; i++)
for (var j = 0; j < Height; j++)
if (x != i || y != j)
circle_visible_profit[i, j] += 10.0/position.GetDistanceTo(i, j);
}
示例4: SkipPath
Point SkipPath(Trooper center, Point goal)
{
// В первую очередь минимизировать путь center до goal
var bestPoint = new Point(0, 0, Inf);
double minPenalty = Inf;
for (var i = 0; i < Width; i++)
{
for (var j = 0; j < Height; j++)
{
if (map[i, j] == 0 || i == self.X && j == self.Y)
{
if (self.GetDistanceTo(i, j) > 10) // немного ускорит
continue;
// Нужно чтобы хватило ходов
int steps = GetShoterPath(self, new Point(i, j), map, beginFree: true, endFree: true);
if (self.ActionPoints / GetMoveCost() >= steps)
{
// и чтобы не закрывали кратчайший путь:
map[self.X, self.Y] = 0;
map[i, j] = 1;
int after = GetShoterPath(center, goal, map, beginFree: true, endFree: false);
map[i, j] = 0;
map[self.X, self.Y] = 1;
double penalty = GetShoterPath(center, new Point(i, j), notFilledMap, beginFree: true, endFree: true);
penalty += 2*Math.Max(0, goal.GetDistanceTo(center) - goal.GetDistanceTo(i, j) + 1);
if (after < bestPoint.profit || EqualF(after, bestPoint.profit) && penalty < minPenalty)
{
bestPoint = new Point(i, j, after);
minPenalty = penalty;
}
}
}
}
}
return bestPoint.profit >= Inf ? null : bestPoint;
}