コード例 #1
0
ファイル: PvPMode.cs プロジェクト: kampoengboy/Othello
 public void newBoard()
 {
     for (int i = 0; i < 8; i++)
     {
         Button[] col = new Button[8];
         for (int j = 0; j < 8; j++)
         {
             if ((i == 3 && j == 3) || (i == 4 && j == 4))
                 col[j] = new ButtonX(i, j);
             else if ((i == 3 && j == 4) || (i == 4 && j == 3))
                 col[j] = new ButtonO(i, j);
         }
         row.Add(col);
     }
 }
コード例 #2
0
ファイル: Function.cs プロジェクト: kampoengboy/Othello
 public void ReverseXtoO(int key)
 {
     //left
     if (findleft(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c - 1; c >= 0; c--)
         {
             if (row[query[key - 1].r][c] is ButtonX)
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             else if (row[query[key - 1].r][c] is ButtonO)
                 break;
         }
     }
     //right
     if (findright(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             if (row[query[key - 1].r][c] is ButtonX)
                 row[query[key - 1].r][c] = new ButtonO(query[key - 1].r, c);
             else if (row[query[key - 1].r][c] is ButtonO)
                 break;
         }
     }
     //up
     if (findup(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             if (row[r][query[key - 1].c] is ButtonX)
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             else if (row[r][query[key - 1].c] is ButtonO)
                 break;
         }
     }
     //down
     if (finddown(query[key - 1].r, query[key - 1].c, 3))
     {
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             if (row[r][query[key - 1].c] is ButtonX)
                 row[r][query[key - 1].c] = new ButtonO(r, query[key - 1].c);
             else if (row[r][query[key - 1].c] is ButtonO)
                 break;
         }
     }
     //dleftup
     if (findDleftup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r - 1; r >= 0; r--)
         {
             j--;
             if (j < 0) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
     //dleftdown
     if (findDleftdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j--;
             if (j < 0) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
     //drightup
     if (findDrightup(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].r;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int c = query[key - 1].c + 1; c < 8; c++)
         {
             j--;
             if (j - 1 < 0) break;
             if (row[j][c] is ButtonX)
                 row[j][c] = new ButtonO(j, c);
             else if (row[j][c] is ButtonO)
                 break;
         }
     }
     //drightdown
     if (findDrightdown(query[key - 1].r, query[key - 1].c, 3))
     {
         int j = query[key - 1].c;
         row[query[key - 1].r][query[key - 1].c] = new ButtonO(query[key - 1].r, query[key - 1].c);
         for (int r = query[key - 1].r + 1; r < 8; r++)
         {
             j++;
             if (j + 1 > 7) break;
             if (row[r][j] is ButtonX)
                 row[r][j] = new ButtonO(r, j);
             else if (row[r][j] is ButtonO)
                 break;
         }
     }
 }