Exemple #1
0
        public bool Undo()
        {
            if (PlaytimeLine.Count <= 0)
            {
                return(false);
            }
            playInfo oldPoint = PlaytimeLine.Pop();
            Button   btn      = Matrix[oldPoint.Point.Y][oldPoint.Point.X];

            btn.BackgroundImage = null;
            btn.Enabled         = true;
            xoaSinhNuocDi();
            if (!(PlaytimeLine.Count <= 0))
            {
                oldPoint = PlaytimeLine.Peek();
            }
            timViTri();
            return(true);
        }
Exemple #2
0
        private void Btn_Click(object sender, EventArgs e)  // btn click thêm quân mã đã đi, hiện quân mã gợi ý
        {
            Button btn = sender as Button;

            btn.BackgroundImage = quanMa_dadi;

            PlaytimeLine.Push(new playInfo(getChessPoint(btn)));   // luu point

            xoaSinhNuocDi();

            if (isEndGame(btn))
            {
                Endgame();
            }
            if (btn.BackgroundImage != null)
            {
                return;
            }
        }
Exemple #3
0
        public void timViTri()  //tim vi tri quan ma, sau khi undo
        {
            playInfo oldPoint = PlaytimeLine.Peek();
            int      i        = 0;

            while (i < 8)
            {
                int ty = oldPoint.Point.X + dy[i];
                int tx = oldPoint.Point.Y + dx[i];
                if ((ty >= 0 && ty < N && tx >= 0 && tx < N && banCo[ty, tx] == 0) && (Matrix[tx][ty].BackgroundImage != quanMa))
                {
                    if (!(Matrix[tx][ty].BackgroundImage == quanMa_dadi))
                    {
                        Matrix[tx][ty].BackgroundImage = quanMa;
                        Matrix[tx][ty].Enabled         = true;
                    }
                }
                i++;
            }
        }