public Snake(Point tail, int lenght, Dirrection direction) { plist = new List <Point>(); for (int i = 0; i < lenght; i++) { Point p = new Point(tail); p.Move(i, direction); plist.Add(p); } }
public void Move(int offset, Dirrection direction) { if (direction == Dirrection.RIGNT) { x = x + offset; } else if (direction == Dirrection.LEFT) { x = x - offset; } else { } }
public Point GetWayPoint(Point from, Dirrection dir) { Point res = null; switch (dir) { case Dirrection.Left: for (sbyte i = from.x; i >= 0 && !arr[i, from.y]; i--) { res = new Point(i, from.y); } break; case Dirrection.Up: for (sbyte i = from.y; i >= 0 && !arr[from.x, i]; i--) { res = new Point(from.x, i); } break; case Dirrection.Right: for (sbyte i = from.x; i < arr.GetLength(0) && !arr[i, from.y]; i++) { res = new Point(i, from.y); } break; case Dirrection.Down: for (sbyte i = from.y; i < arr.GetLength(1) && !arr[from.x, i]; i++) { res = new Point(from.x, i); } break; } return(res); }
public async Task SendStep(Dirrection down) { await Task.Yield(); }