コード例 #1
0
        public bool DanhCo(int MouseX, int MouseY, Graphics gr)
        {
            if (MouseX % QuanCo._Width == 0 || MouseY % QuanCo._Height == 0)
            {
                return(false);
            }
            int Cot  = MouseX / QuanCo._Width;
            int Dong = MouseY / QuanCo._Height;

            if (MangOCo[Dong, Cot].SoHuu != 0)
            {
                return(false);
            }
            System.Media.SoundPlayer sound = new SoundPlayer(@"C://Users\pc\Downloads\Documents\Visual Studio 2015\Projects\GameCaro\GameCaro\Resources\DanhCoSound.WAV");
            switch (Luotdi)
            {
            case 1: MangOCo[Dong, Cot].SoHuu = 1;
                _BanCo.VeQuanCo(gr, MangOCo[Dong, Cot].ViTri, ImageO);
                Luotdi = 2;
                sound.Play();
                break;

            case 2: MangOCo[Dong, Cot].SoHuu = 2;
                _BanCo.VeQuanCo(gr, MangOCo[Dong, Cot].ViTri, ImageX);
                Luotdi = 1;
                sound.Play();
                break;
            }
            QuanCo quanco = new QuanCo(MangOCo[Dong, Cot].Row, MangOCo[Dong, Cot].Column, MangOCo[Dong, Cot].ViTri, MangOCo[Dong, Cot].SoHuu);

            StackQuanCoDaDi.Push(quanco);
            return(true);
        }
コード例 #2
0
        private QuanCo TimNuocDi()
        {
            QuanCo QuancoKq = new QuanCo();
            long   DiemMax  = 0;

            for (int i = 0; i < _BanCo.SoDong; i++)
            {
                for (int j = 0; j < _BanCo.SoCot; j++)
                {
                    if (MangOCo[i, j].SoHuu == 0)
                    {
                        long DiemTc   = DiemTc_DuyetNgang(i, j) + DiemTc_DuyetDoc(i, j) + DiemTc_DuyetCheoXuong(i, j) + DiemTc_DuyetCheoLen(i, j);
                        long DiemPn   = DiemPn_DuyetNgang(i, j) + DiemPn_DuyetDoc(i, j) + DiemPn_DuyetCheoXuong(i, j) + DiemPn_DuyetCheoLen(i, j);
                        long DiemTam  = DiemTc > DiemPn ? DiemTc : DiemPn;
                        long DiemTong = (DiemPn + DiemTc) > DiemTam ? (DiemPn + DiemTc) : DiemTam;
                        if (DiemMax < DiemTong)
                        {
                            DiemMax  = DiemTong;
                            QuancoKq = new QuanCo(MangOCo[i, j].Row, MangOCo[i, j].Column, MangOCo[i, j].ViTri, MangOCo[i, j].SoHuu);
                        }
                    }
                }
            }
            return(QuancoKq);
        }
コード例 #3
0
 public void KhoiTaoMangOCo()
 {
     for (int i = 0; i < _BanCo.SoDong; i++)
     {
         for (int j = 0; j < _BanCo.SoCot; j++)
         {
             MangOCo[i, j] = new QuanCo(i, j, new Point(j * QuanCo._Width, i * QuanCo._Height), 0);
         }
     }
 }
コード例 #4
0
 public void KhoiDongCom(Graphics gr)
 {
     if (StackQuanCoDaDi.Count == 0)
     {
         DanhCo(_BanCo.SoCot / 2 * QuanCo._Width + 1, _BanCo.SoDong / 2 * QuanCo._Height + 1, gr);
     }
     else
     {
         QuanCo quanco = TimNuocDi();
         DanhCo(quanco.ViTri.X + 1, quanco.ViTri.Y + 1, gr);
     }
 }
コード例 #5
0
 public void Redo(Graphics g)
 {
     if (StackQuanCoDaUndo.Count != 0)
     {
         QuanCo quanco = StackQuanCoDaUndo.Pop();
         StackQuanCoDaDi.Push(new QuanCo(quanco.Row, quanco.Column, quanco.ViTri, quanco.SoHuu));
         MangOCo[quanco.Row, quanco.Column].SoHuu = quanco.SoHuu;
         if (Luotdi == 1)
         {
             Luotdi = 2;
         }
         else
         {
             Luotdi = 1;
         }
         _BanCo.VeQuanCo(g, quanco.ViTri, quanco.SoHuu == 1 ? ImageO : ImageX);
     }
 }
コード例 #6
0
        public void Undo(Graphics g)
        {
            if (StackQuanCoDaDi.Count != 0)
            {
                QuanCo quanco = StackQuanCoDaDi.Pop();
                StackQuanCoDaUndo.Push(new QuanCo(quanco.Row, quanco.Column, quanco.ViTri, quanco.SoHuu));
                MangOCo[quanco.Row, quanco.Column].SoHuu = 0;
                if (Luotdi == 1)
                {
                    Luotdi = 2;
                }
                else
                {
                    Luotdi = 1;
                }
            }

            VeBanCo(g);
            VeLaiBanCo(g);
        }