Example #1
0
 public void Draw(ConsoleGraphics g)//Рисует игру
 {
     g.FillArea(new CChar(' ', ConsoleColor.Black, ConsoleColor.DarkGray), 10, 5, 8, 8);
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             Doska.Yacheika yacheika = board.GetCell(i, j);
             if (yacheika.Piece != null)
             {
                 g.DrawTransparent(yacheika.Piece.Char, (yacheika.Piece.Color == PlayerColor.White) ? ConsoleColor.White : ConsoleColor.Black, 10 + i, 5 + (7 - j));
                 if (yacheika.Piece.LegalMoves.Count == 0)
                 {
                     g.SetBackground(ConsoleColor.DarkRed, 10 + i, 5 + (7 - j));
                 }
             }
             if (yacheika.HitBy.Contains(debugPiece))
             {
                 g.SetBackground(ConsoleColor.DarkMagenta, 10 + i, 5 + (7 - j));
             }
         }
     }
     if (holdedNode != null && playerState == PlayerState.Holding)
     {
         foreach (Doska.Yacheika move in holdedNode.Piece.LegalMoves)// Подсветка возможных ходов
         {
             g.SetBackground(ConsoleColor.DarkGreen, 10 + move.X, 5 + (7 - move.Y));
         }
     }
     g.SetBackground(ConsoleColor.DarkYellow, 10 + cursorX, 5 + (7 - cursorY));// курсор- желтый
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             if ((i + j) % 2 == 1)
             {
                 g.LightenBackground(10 + i, 5 + j);
             }
         }
     }
     if (playerState == PlayerState.AwaitPromote)// Меню параметров продвижения
     {
         g.DrawTextTrasparent("Dama", promoteOption == PromoteOptions.Queen ? ConsoleColor.Yellow : ConsoleColor.White, 22, 7);
         g.DrawTextTrasparent("LAdiya", promoteOption == PromoteOptions.Rook ? ConsoleColor.Yellow : ConsoleColor.White, 22, 9);
         g.DrawTextTrasparent("Slon", promoteOption == PromoteOptions.Bishop ? ConsoleColor.Yellow : ConsoleColor.White, 22, 11);
         g.DrawTextTrasparent("Kon", promoteOption == PromoteOptions.Knight ? ConsoleColor.Yellow : ConsoleColor.White, 22, 13);
     }
     else
     {
         g.ClearArea(22, 7, 6, 7);
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            Console.CursorVisible  = false;
            ConsoleGraphics graphics = new ConsoleGraphics();

            game = new Chess();
            do
            {
                game.Draw(graphics);
                graphics.SwapBuffers();
                game.Update();
            } while (game.Running);
            Console.Read();
        }