public override void Recalculate() { directions[0] = new Napravlenie(this, -1, 1); //Вверх Влево directions[1] = new Napravlenie(this, 1, 1); //Вверх Вправо directions[2] = new Napravlenie(this, -1, -1); //Вниз Влево directions[3] = new Napravlenie(this, 1, -1); //Вниз Вправо }
public override void Recalculate() { directions[0] = new Napravlenie(this, 0, 1); directions[1] = new Napravlenie(this, 0, -1); directions[2] = new Napravlenie(this, -1, 0); directions[3] = new Napravlenie(this, 1, 0); }
public Napravlenie n1; // Сохранение направление public Zmeika(Point kon, int lengt, Napravlenie n) // Функция для увелечение змейки передаем конец змейки, длину и направление движения { n1 = n; // задаем новое направление plist = new List <Point>(); // Создаем список где хранится точки змейки for (int i = 0; i < lengt; i++) { Point p = new Point(kon); // Передаем змеку состоящию из точек p.mov(i, n); // Смещаем точки змейки на 1 в заданном направлении plist.Add(p); // добавляем в список новые координаты змейки } }
public override void Recalculate() { forward = new Napravlenie(this, 0, (Color == PlayerColor.White) ? 1 : -1, Moved ? 1 : 2, false); hits[0] = Parent.Open(-1, (Color == PlayerColor.White) ? 1 : -1); hits[1] = Parent.Open(1, (Color == PlayerColor.White) ? 1 : -1); if (hits[0] != null) { hits[0].HitBy.Add(this); } if (hits[1] != null) { hits[1].HitBy.Add(this); } }
public override void Recalculate() { if (!Moved) { canCastleLeft = true; Doska.Yacheika leftRookCell = Parent.Parent.GetCell(0, (Color == PlayerColor.White) ? 0 : 7); if (leftRookCell.Piece == null || !(leftRookCell.Piece is Ladiya) || leftRookCell.Piece.Color != Color || leftRookCell.Piece.Moved) { canCastleLeft = false; } else { for (int i = 1; i <= 3; i++) { if (Parent.Parent.GetCell(i, (Color == PlayerColor.White) ? 0 : 7).Piece != null) { canCastleLeft = false; } } } canCastleRight = true; Doska.Yacheika rightRookCell = Parent.Parent.GetCell(7, (Color == PlayerColor.White) ? 0 : 7); if (rightRookCell.Piece == null || !(rightRookCell.Piece is Ladiya) || rightRookCell.Piece.Color != Color || rightRookCell.Piece.Moved) { canCastleRight = false; } else { for (int i = 5; i <= 6; i++) { if (Parent.Parent.GetCell(i, (Color == PlayerColor.White) ? 0 : 7).Piece != null) { canCastleRight = false; } } } } directions[0] = new Napravlenie(this, 0, 1, 1); directions[1] = new Napravlenie(this, 0, -1, 1); directions[2] = new Napravlenie(this, -1, 0, 1); directions[3] = new Napravlenie(this, 1, 0, 1); directions[4] = new Napravlenie(this, -1, 1, 1); directions[5] = new Napravlenie(this, 1, 1, 1); directions[6] = new Napravlenie(this, -1, -1, 1); directions[7] = new Napravlenie(this, 1, -1, 1); }
public void mov(int of, Napravlenie n) { if (n == Napravlenie.vpravo) { x = x + of; } else if (n == Napravlenie.vlevo) { x = x - of; } else if (n == Napravlenie.vverx) { y = y - of; } else if (n == Napravlenie.vniz) { y = y + of; } }
/// //////////////////////////////////////////////////////////////////////////// //Поверка нажатых кнопок public void hand(ConsoleKey key) { if (n1 == Napravlenie.vlevo && key == ConsoleKey.RightArrow) { key = ConsoleKey.LeftArrow; } if (n1 == Napravlenie.vpravo && key == ConsoleKey.LeftArrow) { key = ConsoleKey.RightArrow; } if (n1 == Napravlenie.vniz && key == ConsoleKey.UpArrow) { key = ConsoleKey.DownArrow; } if (n1 == Napravlenie.vverx && key == ConsoleKey.DownArrow) { key = ConsoleKey.UpArrow; } if (key == ConsoleKey.LeftArrow) { n1 = Napravlenie.vlevo; } if (key == ConsoleKey.RightArrow) { n1 = Napravlenie.vpravo; } if (key == ConsoleKey.DownArrow) { n1 = Napravlenie.vniz; } if (key == ConsoleKey.UpArrow) { n1 = Napravlenie.vverx; } }