本文整理汇总了C#中System.Point.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Move方法的具体用法?C# Point.Move怎么用?C# Point.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Point
的用法示例。
在下文中一共展示了Point.Move方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextPoint
public Point GetNextPoint()
{
Point head = pList.Last();
Point nextPoint = new Point(head);
nextPoint.Move(1, direction);
return nextPoint;
}
示例2: Snake
public Snake(Point tail, int lenght, Direction _direction)
{
direction = _direction;
pList = new List<Point>();
for (int i = 0; i < lenght; i++ )
{
Point p = new Point(tail);
p.Move(i, direction);
pList.Add(p);
}
}
示例3: Main
public static void Main(string[] args)
{
var point = new Point(1, 2);
var point2 = point.Clone() as Point;
point.Move(2, 3);
point.Print();
point2.Print();
var personWithChildren = new PersonWithChildren("John", "Doe");
Console.WriteLine(personWithChildren.Name);
personWithChildren.Children.Add(new PersonWithChildren("John", "Little"));
Console.WriteLine(personWithChildren["John Little"].Name);
}
示例4: CheckVictory
/// <summary>
/// Checks if one of the players won
/// </summary>
/// <returns>playerId if someone won, -1 if no one did</returns>
public string CheckVictory(int x, int y, int z)
{
/*
* Basic winner finding algo:
* 1. generate all posible direction vectors ([-1,-1,-1], [-1,-1,0] ... )
* 2. move from current position in vector direction while its posible, getting point A
* 3. move from current position in reverse vector direction while posible, getting point B
* 4. if distance between A and B is field size, we've got the winner!
*
*/
var who = Field[x, y, z];
if (who == 0) return null;
var ways = new[] { -1, 0, 1 };
foreach (var wx in ways)
{
foreach (var wy in ways)
{
foreach (var wz in ways)
{
if (wx == 0 && wy == 0 && wz == 0)
continue;
Point pa = new Point(x, y, z);
Point pb = new Point(x, y, z);
Point newA;
while ((newA = pa.Move(wx, wy, wz, _fieldSize)) != null
&& Field[newA.X, newA.Y, newA.Z] == who)
{
pa = newA;
}
Point newB;
while ((newB = pb.Move(-wx, -wy, -wz, _fieldSize)) != null
&& Field[newB.X, newB.Y, newB.Z] == who)
{
pb = newB;
}
if (pa.Distance(pb) == _fieldSize)
{
return Players[who - 1];
}
}
}
}
return null;
}
示例5: GetPriority
private int GetPriority(RobotMap map, Point p, int rotation)
{
if (!map.Explored(p)) return 5;
var t = map[p];
if (t == MapTileResult.Goal) return 10000000;
if (t == MapTileResult.Wall || t == MapTileResult.Robot) return 0;
if (t == MapTileResult.ClosedDoor) return 0;
var count = 1;
if (!map.Explored(p.Move(rotation + 3))) count++;
if (!map.Explored(p.Move(rotation))) count++;
if (!map.Explored(p.Move(rotation + 1))) count++;
return count;
}