Esempio n. 1
0
        private void Quan_Click(object sender, EventArgs e)
        {
            QuanCo tot = sender as QuanCo;

            if (currentChess.Text.Equals("Tướng"))
            {
                Cons.map[(currentChess.Location.Y - 15) / 100, (currentChess.Location.X - 15) / 100] = 2;
                Cons.map[(tot.Location.Y - 15) / 100, (tot.Location.X - 15) / 100] = 0;
                currentChess.Location = tot.Location;
                this.Controls.Remove(tot);
            }
            currentChess = tot;
        }
Esempio n. 2
0
        private void DrawChess()
        {
            Point location;

            for (int i = 0; i <= Cons.MAX_COL + Cons.SMALL_DIAMON_HEIGH; i++)
            {
                for (int j = 0; j <= Cons.MAX_ROW; j++)
                {
                    // Swap i, j to normal because it's nature
                    location = new Point(Cons.MARGIN + j * Cons.CELL_SIZE - Cons.CHESS_SIZE / 2, Cons.MARGIN + i * Cons.CELL_SIZE - Cons.CHESS_SIZE / 2);
                    //QuanCo chess = new QuanCo() {
                    //    Location = location,
                    //    Size = new Size(Cons.CHESS_SIZE, Cons.CHESS_SIZE),

                    //};
                    if (Cons.map[i, j] == Cons.CHESS_VALUE)
                    {
                        QuanCo chess = new QuanCo()
                        {
                            Location  = location,
                            Text      = "Tốt",
                            Size      = new Size(Cons.CHESS_SIZE, Cons.CHESS_SIZE),
                            ForeColor = Color.Blue
                        };
                        this.Controls.Add(chess);
                        chess.Click += Quan_Click;
                    }
                    else if (Cons.map[i, j] == 2)
                    {
                        QuanCo tuong = new QuanCo()
                        {
                            Location  = location,
                            Text      = "Tướng",
                            Size      = new Size(Cons.CHESS_SIZE, Cons.CHESS_SIZE),
                            BackColor = Color.Red
                        };
                        this.Controls.Add(tuong);
                        tuong.Click += Tuong_Click;
                    }
                }
            }
        }
Esempio n. 3
0
        private void Tuong_Click(object sender, EventArgs e)
        {
            QuanCo tuong = sender as QuanCo;

            tuong.FlatAppearance.BorderColor = Color.Red;
            tuong.FlatAppearance.BorderSize  = 2;
            currentChess = tuong;

            int i, j;

            i = (tuong.Location.Y - 15) / 100;
            j = (tuong.Location.X - 15) / 100;

            Cons.map[i, j] = 0;

            List <Point> list     = checker.getListMove(i, j);
            Point        nextMove = list[0];


            Point p = new Point(15 + nextMove.Y * 100, 15 + nextMove.X * 100);

            foreach (var item in this.Controls)
            {
                if (item.GetType() == typeof(QuanCo))
                {
                    QuanCo c = (QuanCo)item;
                    if (c.Location.X == p.X && c.Location.Y == p.Y && c.Text == "Tốt")
                    {
                        this.Controls.Remove(c);
                    }
                }
            }

            tuong.Location = new Point(15 + nextMove.Y * 100, 15 + nextMove.X * 100);

            Cons.map[nextMove.X, nextMove.Y] = 2;

            //tuong.Location = new Point(15 + 2 * 100, 15 + 3 * 100);

            //this.Controls.Remove()
        }