public static void Render(ConsoleGraphics consoleGraphics, CustomList.List <SnekePartMove> snake) { for (int i = 0; i < snake.Count; i++) { snake[i].Render(consoleGraphics); } }
public object Clone() //Дълбоко копиране (имплементиране на интерфейса ICloneable) { List <T> newList = new CustomList.List <T>(); for (Node p = first; p != last; p = p.next) { newList.Add(p.key); } return(newList); }
public static bool ContactWithOneself(CustomList.List <SnekePartMove> snake) { for (int i = 1; i < snake.Count; i++) { if (snake[0].X == snake[i].X && snake[0].Y == snake[i].Y) { return(true); } } return(false); }
public static void Move(CustomList.List <SnekePartMove> snake) { SnekePartMove head = snake[0]; for (int i = snake.Count - 1; i > 0; i--) { snake[i].X = snake[i - 1].X; snake[i].Y = snake[i - 1].Y; } head.Update(); }
public SimpleSnakePart CriateSimplePart(CustomList.List <SnekePartMove> list, ConsoleGraphics _graphics) { int xCord = size * _random.Next(1, _columns); int yCord = size * _random.Next(1, _lines); for (int i = 0; i < list.Count; i++) { if (xCord == list[i].X && yCord == list[i].Y) { i = -1; xCord = size * _random.Next(1, _columns); yCord = size * _random.Next(1, _lines); } } return(new SimpleSnakePart(0xFF325230, xCord, yCord, _graphics)); }