Ejemplo n.º 1
0
        // hàm đánh cờ
        public bool Chess(Graphics g, int x, int y)
        {
            if ((x % Cells.WIDTH == 0) || (y % Cells.HEIGHT == 0))
            {
                return(false);
            }
            int col = x / Cells.WIDTH;
            int row = y / Cells.HEIGHT;

            if (arrayCells[row, col].Owned != 0)
            {
                return(false);
            }
            switch (turn)
            {
            case 1:
                arrayCells[row, col].Owned = 1;
                board.DrawPawn(g, arrayCells[row, col].Location, MyPaint.solidBlack());
                turn = 2;
                break;

            case 2:
                arrayCells[row, col].Owned = 2;
                board.DrawPawn(g, arrayCells[row, col].Location, MyPaint.solidRed());
                turn = 1;
                break;
            }
            Cells cells = new Cells(arrayCells[row, col].Rows, arrayCells[row, col].Column, arrayCells[row, col].Location, arrayCells[row, col].Owned);

            cacNuocDaDi.Push(cells);
            return(true);
        }
Ejemplo n.º 2
0
 // vẽ lại các quân cờ - Trường hợp người chơi nhấn vào nút minimum
 public void DrawPawnAgain(Graphics gr)
 {
     foreach (Cells cel in cacNuocDaDi)
     {
         if (cel.Owned == 1)
         {
             board.DrawPawn(gr, cel.Location, MyPaint.solidBlack());
         }
         else if (cel.Owned == 2)
         {
             board.DrawPawn(gr, cel.Location, MyPaint.solidRed());
         }
     }
 }