本文整理汇总了C#中Unit.ToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.ToPoint方法的具体用法?C# Unit.ToPoint怎么用?C# Unit.ToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.ToPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveAndDig
public static bool MoveAndDig(Unit digger, IEnumerable<Point> targets)
{
Bb.ReadBoard();
var passable = Solver.GetPassable();
var moveTargets = targets.SelectMany(t => Pather.GetNeighbors(t, passable)).ToBitArray();
moveTargets.And(targets.ToBitArray().Not());
if (digger.MovementLeft == 0)
{
if (Dig(digger, targets, GetDiggableAndUnDug()))
{
return true;
}
return false;
}
var steps = Solver.GetWalkingSteps(digger.ToPoint(), moveTargets);
if (steps == null)
{
return false;
}
foreach (var step in steps)
{
if (digger.MovementLeft > 0)
{
digger.move(step.x, step.y);
}
}
Dig(digger, targets, GetDiggableAndUnDug());
return true;
}
示例2: Attack
public static bool Attack(Unit attacker, IEnumerable<Unit> targets)
{
var target = targets.FirstOrDefault(t => t.HealthLeft > 0 && Manhattan(attacker.ToPoint(), t.ToPoint()) <= attacker.Range);
if (target != null)
{
attacker.attack(target);
return true;
}
return false;
}
示例3: Dig
public static bool Dig(Unit digger, IEnumerable<Point> targets, BitArray diggable)
{
foreach (var n in Pather.GetNeighbors(digger.ToPoint(), diggable))
{
if (targets.Contains(n))
{
digger.dig(Bb.tileLookup[n]);
return true;
}
}
return false;
}
示例4: MoveAndAttack
public static void MoveAndAttack(Unit attacker, IEnumerable<Unit> targets, bool ifInRange = false)
{
var alive = targets.Where(t => t.HealthLeft > 0);
if (!alive.Any())
{
return;
}
if (Attack(attacker, alive))
{
return;
}
if (attacker.MovementLeft == 0)
{
return;
}
var steps = GetWalkingSteps(attacker.ToPoint(), alive.Select(t => t.ToPoint()).ToBitArray(), nearbyOk: true);
if (steps == null)
{
return;
}
if (ifInRange)
{
int simulationMoves = attacker.MovementLeft;
foreach (var step in steps)
{
simulationMoves--;
if (simulationMoves < 0)
{
return;
}
if (alive.Any(t => Manhattan(t.ToPoint(), step) < attacker.Range))
{
break;
}
}
}
foreach (var step in steps)
{
attacker.move(step.x, step.y);
if (Attack(attacker, alive) || attacker.MovementLeft == 0)
{
return;
}
}
}
示例5: Move
public static void Move(Unit unit, BitArray goals, bool walkInWater = false)
{
var stepCount = unit.MovementLeft;
if (stepCount == 0)
{
return;
}
var steps = GetWalkingSteps(unit.ToPoint(), goals, walkInWater);
if (steps == null)
{
return;
}
foreach (Point p in steps)
{
if (stepCount == 0)
{
return;
}
unit.move(p.x, p.y);
stepCount--;
}
}