예제 #1
0
 private void showButton_Click(object sender, EventArgs e)
 {
     //  label1.Text = comboBox1.Text;
     int i = Convert.ToInt32(comboBox1.Text);
     selectedPiece = (Tile)p.hand[i - 1];
     //  Console.WriteLine(selectedPiece);
     this.Refresh();
 }
예제 #2
0
 private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
 {
     int i = Convert.ToInt32(comboBox1.Text);
     selectedPiece = (Tile)p.hand[i - 1];
     this.Refresh();
 }
예제 #3
0
파일: Player.cs 프로젝트: cricket007/Blokus
        public Player()
        {
            if (this.hand == null)
            {
                tg.generate();
                this.hand = tg.hand;
            }

            int random = new Random().Next(0, piecesLeft - 1);
            this.selectedPiece = (Tile)hand[random];
            this.finished = false;
        }
예제 #4
0
파일: Player.cs 프로젝트: cricket007/Blokus
 public void removePiece(Tile piece)
 {
     for (int i = 0; i < hand.Count; i++)
     {
         Tile tileInHand = (Tile)hand[i];
         if (tileInHand.Equals(piece))
         {
             hand.RemoveAt(i);
             break;
         }
     }
 }
예제 #5
0
파일: Tile.cs 프로젝트: cricket007/Blokus
        // Transposes the matrix
        public void transpose()
        {
            if (height == width)
            {
                int temp;

                // Swaps values over left diagonal
                for (int i = 0; i < tile.Count; i++)
                {
                    for (int j = i + 1; j < tile.Count; j++)
                    {
                        temp = tile[i][j];
                        tile[i][j] = tile[j][i];
                        tile[j][i] = temp;
                        //                    board[i][j] = board[j][board.Count - i - 1];
                        //                    board[j][board.Count - i - 1] = temp;
                    }
                }
            }
            else
            {
                Tile newtile = new Tile(this.width, this.height);

                for (int r = 0; r < height; r++)
                {
                    for (int c = 0; c < width; c++)
                    {
                        newtile.tile[c][r] = tile[r][c];
                    }
                }
                tile = newtile.tile;
            }
        }
예제 #6
0
        //        public int[][] tile = new int[5][];
        //        public bool borders(int row, int col)
        //        {
        //            bool b = false;
        //
        //            for (int i = -1; i < 2; i++)
        //            {
        //                for (int j = -1; j < 2; j++)
        //                {
        //                    try
        //                    {
        //                        if ((i + j) % 2 == 0) // ignore the 4 corners and the center
        //                            continue;
        //                        else
        //                        {
        //                            if (tile[row + i][col + j] == 1)
        //                                b = true;
        //                            else b = false;
        //                            if (b) return b;
        //                        }
        //                    }
        //                    catch (IndexOutOfRangeException)
        //                    {
        //                        continue;
        //                    }
        //                }
        //            }
        //            return b;
        //        }
        // create a hand of the 21 blokus pieces
        // Sorted in the order from greatest points to least
        public void generate()
        {
            // 1
            hand.Add(new int[][]
            {
                new int [] {1},
            });
            // 2
            hand.Add(new int[][]
            {
                new int [] {1, 1},
            });
            // 3
            hand.Add(new int[][]
            {
                new int [] {1, 1},
                new int [] {1, 0},
            });
            // 4
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
            });
            // 5
            hand.Add(new int[][]
            {
                new int [] {1, 1},
                new int [] {1, 1},
            });
            // 6
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
                new int [] {0, 1, 0},
            });
            // 7
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1, 1},
            });
            // 8
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
                new int [] {1, 0, 0}
            });
            // 9
            hand.Add(new int[][]
            {
                new int [] {1, 1, 0},
                new int [] {0, 1, 1},
            });
            // 10
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1, 1},
                new int [] {1, 0, 0, 0},
            });
            // 11
            hand.Add(new int[][]
            {
                new int [] {1, 0, 0},
                new int [] {1, 1, 1},
                new int [] {1, 0, 0},
            });
            // 12
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
                new int [] {1, 0, 0},
                new int [] {1, 0, 0},
            });
            // 13
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1, 0},
                new int [] {0, 0, 1, 1},
            });
            // 14
            hand.Add(new int[][]
            {
                new int [] {1, 0, 0},
                new int [] {1, 1, 1},
                new int [] {0, 0, 1},
            });
            // 15
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1, 1, 1},
            });
            // 16
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
                new int [] {1, 1, 0},
            });
            // 17
            hand.Add(new int[][]
            {
                new int [] {1, 1, 0},
                new int [] {0, 1, 1},
                new int [] {0, 0, 1},
            });
            // 18
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1},
                new int [] {1, 0, 1},
            });
            // 19
            hand.Add(new int[][]
            {
                new int [] {1, 0, 0},
                new int [] {1, 1, 1},
                new int [] {0, 1, 0},
            });
            // 20
            hand.Add(new int[][]
            {
                new int [] {0, 1, 0},
                new int [] {1, 1, 1},
                new int [] {0, 1, 0},
            });
            // 21
            hand.Add(new int[][]
            {
                new int [] {1, 1, 1, 1},
                new int [] {0, 1, 0, 0},
            });

            for (int i = 0; i < hand.Count; i++)
            {
                hand[i] = new Tile((int[][])hand[i]);
            }

            hand.Sort(Tile.SortByScore);
            hand.Reverse();
        }
예제 #7
-1
 public PieceTester()
 {
     InitializeComponent();
     p = new Player();
     playerColor = colors[new Random().Next(0, 3)]; // Initialize with a random color instead of black
     selectedPiece = new Tile();
 }