示例#1
0
        private O_Co Tim_Kiem_Nuoc_Di()
        {
            O_Co _ocoResult = new O_Co();
            long _Diem_Max  = 0;

            for (int i = 0; i < _Ban_Co.NRow; i++)
            {
                for (int j = 0; j < _Ban_Co.NCoLumn; j++)
                {
                    if (_Mang_O_Co[i, j].Own == 0)
                    {
                        long _Diem_TC       = DTC_DuyetDoc(i, j) + DTC_DuyetNgang(i, j) + DTC_DuyetCheoXuoi(i, j) + DTC_DuyetCheoNguoc(i, j);
                        long _Diem_PT       = DPT_DuyetNgang(i, j) + DPT_DuyetDoc(i, j) + DPT_DuyetCheoXuoi(i, j) + DPT_DuyetCheoNguoc(i, j);
                        long _Diem_Tam_Thoi = _Diem_TC > _Diem_PT? _Diem_TC:_Diem_PT;
                        long _Diem_Tong     = (_Diem_PT + _Diem_TC) > _Diem_Tam_Thoi ? (_Diem_PT + _Diem_TC) : _Diem_Tam_Thoi;
                        if (_Diem_Max < _Diem_Tong)
                        {
                            _Diem_Max  = _Diem_Tong;
                            _ocoResult = new O_Co(_Mang_O_Co[i, j].Row, _Mang_O_Co[i, j].Column, _Mang_O_Co[i, j].Location, _Mang_O_Co[i, j].Own);
                        }
                    }
                }
            }
            return(_ocoResult);
        }
示例#2
0
 public void KTM_O_Co()
 {
     for (int i = 0; i < _Ban_Co.NRow; i++)
     {
         for (int j = 0; j < _Ban_Co.NCoLumn; j++)
         {
             _Mang_O_Co[i, j] = new O_Co(i, j, new Point(j * O_Co._Width, i * O_Co._Height), 0);
         }
     }
 }
示例#3
0
 };                                                                     // Điểm phòng thủ
 public void StartCom(Graphics g)
 {
     if (Stack_Cac_Nuoc_Da_Di.Count == 0)
     {
         Danh_Co(_Ban_Co.NRow / 2 * O_Co._Height + 1, _Ban_Co.NCoLumn / 2 * O_Co._Width + 1, g);
     }
     else
     {
         O_Co _o_co = Tim_Kiem_Nuoc_Di();
         Danh_Co(_o_co.Location.X + 1, _o_co.Location.Y + 1, g);
     }
 }
示例#4
0
        public bool Danh_Co(int MouseX, int MouseY, Graphics g)
        {
            if (MouseX % O_Co._Width == 0 || MouseY % O_Co._Height == 0)
            {
                return(false);
            }
            int Column = MouseX / O_Co._Width;
            int Row    = MouseY / O_Co._Height;

            if (_Mang_O_Co[Row, Column].Own != 0)
            {
                return(false);
            }
            m = Row;
            n = Column;
            switch (_Luot_Di)
            {
            case 1:
                _Mang_O_Co[Row, Column].Own = 1;
                _Ban_Co.VeO(g, _Mang_O_Co[Row, Column].Location);
                _Luot_Di = 2;
                O++;
                break;

            case 2:
                _Mang_O_Co[Row, Column].Own = 2;
                _Ban_Co.VeX(g, _Mang_O_Co[Row, Column].Location);
                _Luot_Di = 1;
                X++;
                break;

            default:
                MessageBox.Show("Có lỗi xảy ra.", "Thông báo");
                break;
            }
            O_Co _oco = new O_Co(_Mang_O_Co[Row, Column].Row, _Mang_O_Co[Row, Column].Column,
                                 _Mang_O_Co[Row, Column].Location, _Mang_O_Co[Row, Column].Own);

            Stack_Cac_Nuoc_Undo = new Stack <O_Co>();
            Stack_Cac_Nuoc_Da_Di.Push(_oco);
            return(true);
        }
示例#5
0
 public void Redo(Graphics g)
 {
     if (Stack_Cac_Nuoc_Undo.Count != 0)
     {
         O_Co _o_co = Stack_Cac_Nuoc_Undo.Pop();
         Stack_Cac_Nuoc_Da_Di.Push(new O_Co(_o_co.Column, _o_co.Row, _o_co.Location, _o_co.Own));
         if (_o_co.Own == 1)
         {
             _Ban_Co.VeO(g, _o_co.Location);
             _Luot_Di = 2;
             _Mang_O_Co[_o_co.Row, _o_co.Column].Own = 1;
         }
         else if (_o_co.Own == 2)
         {
             _Ban_Co.VeX(g, _o_co.Location);
             _Luot_Di = 1;
             _Mang_O_Co[_o_co.Row, _o_co.Column].Own = 2;
         }
     }
 }
示例#6
0
 // Undo, Redo
 #region Undo, Redo
 public void Undo(Graphics g, Color clr)
 {
     if (Stack_Cac_Nuoc_Da_Di.Count != 0 && _San_Sang == true)
     {
         O_Co _o_co = Stack_Cac_Nuoc_Da_Di.Pop();
         Stack_Cac_Nuoc_Undo.Push(new O_Co(_o_co.Column, _o_co.Row, _o_co.Location, _o_co.Own));
         if (_o_co.Own == 1)
         {
             _Ban_Co.Xoa_Quan_Co_O(g, _o_co.Location, clr);
             _Luot_Di = 1;
             _Mang_O_Co[_o_co.Row, _o_co.Column].Own = 0;
         }
         else if (_o_co.Own == 2)
         {
             _Ban_Co.Xoa_Quan_Co_X(g, _o_co.Location, clr);
             _Luot_Di = 2;
             _Mang_O_Co[_o_co.Row, _o_co.Column].Own = 0;
         }
     }
 }