/// <param name="eBoardStyle">Kiểu bàn cờ</param> /// <param name="ePieceStyle">Kiểu quân cờ</param> /// <param name="eOwnSide">Quân Mà Người Chơi Chọn</param> /// <param name="eGameMode">Chế Độ Chơi</param> /// <param name="CellSize">Kích thước ô cờ</param> /// <param name="PieceSize">Kích thước quân cờ (Mặc định nếu =0)</param> /// <param name="bPlaySound">Âm Thanh</param> /// <param name="strFEN">Forsyth-Edwards Notation</param> /// Chơi Với Người public UcChessBoard(ChessBoardStyle eBoardStyle, ChessPieceStyle ePieceStyle, ChessSide eOwnSide, GameMode eGameMode, int CellSize, int PieceSize, bool bPlaySound, string strFEN) { InitializeComponent(); this.Size = new Size(CellSize * 8, CellSize * 8); this._BlackCellBitmap = clsImageProcess.GetChessBoardBitMap(ChessSide.Black, eBoardStyle); this._WhiteCellBitmap = clsImageProcess.GetChessBoardBitMap(ChessSide.White, eBoardStyle); this._CellSize = CellSize; this._PieceSize = PieceSize; this._PieceStyle = ePieceStyle; this._BoardStyle = eBoardStyle; this._PlaySound = bPlaySound; this._OwnSide = eOwnSide; this._GameMode = eGameMode; CreateChessBoard(); //Tạo các ô cờ kingsideCastling = true; //Nhập thành gần, quân đen queensideCastling = true; //Nhập thành xa, quân đen KINGsideCastling = true; //Nhập thành gần, quân trắng QUEENsideCastling = true; //Nhập thành xa, quân trắng _EnPassantPoint = new Point(); clsFEN.SetFEN(this, strFEN); AddChessPiece(ePieceStyle, this._BoardState); }
public clsOptions() { this._CellSize = 80; this._PieceSize = 64; this._PieceStyle = ChessPieceStyle.Classic; this._BoardStyle = ChessBoardStyle.Metal; this.PlaySound = true; LoadOptions(); }
public UcChessPiece(ChessSide Side, ChessPieceType Type, ChessPieceStyle Style, int intCellSize, int intPieceSize) { InitializeComponent(); this._Side = Side; this._Type = Type; this._Style = Style; this._image = clsImageProcess.GetChessPieceBitMap(_Side, _Type, _Style); this._CellSize = intCellSize; this._PieceSize = intPieceSize; this.Size = new Size(this._PieceSize, this._PieceSize); }
public UcChessPiece(ChessSide Side, ChessPieceType Type, ChessPieceStyle Style, int intCellSize, int intPieceSize, int PositionX, int PositionY, UcChessCell UcOnCell) { InitializeComponent(); this._Side = Side; this._Type = Type; this._Style = Style; this._image = clsImageProcess.GetChessPieceBitMap(_Side, _Type, _Style); this._PieceSize = intPieceSize; this._CellSize = intCellSize; this.Size = new Size(this._PieceSize, this._PieceSize); this._PositionX = PositionX; this._PositionY = PositionY; this._ucOnCell = UcOnCell; }
public void LoadOptions() { if (File.Exists(path) == false) { clsXMLProcess.CreateNewOptions(path); SaveOptions(); } else { DataTable tbl = clsXMLProcess.GetTable(path); DataRow r = tbl.Rows[0]; this._CellSize = Convert.ToInt32(r["CELLSIZE"]); this._PieceSize = Convert.ToInt32(r["PIECESIZE"]); this._BoardStyle = (ChessBoardStyle )Convert.ToInt32(r["BOARDSTYLE"]); this._PieceStyle = (ChessPieceStyle )Convert.ToInt32(r["PIECESTYLE"]); this._PlaySound = Convert.ToBoolean(r["PLAYSOUND"]); } }
private void cboBoardStyle_SelectedIndexChanged(object sender, EventArgs e) { if (cboBoardStyle.SelectedIndex == -1 || cboPieceStyle.SelectedIndex == -1) { return; } try { ChessBoardStyle BoardStyle = (ChessBoardStyle)(cboBoardStyle.SelectedIndex + 1); ChessPieceStyle PieceStyle = (ChessPieceStyle)(cboPieceStyle.SelectedIndex + 1); UcChessBoard Board = new UcChessBoard(BoardStyle, PieceStyle, ChessSide.White, GameMode.VsNetWorkPlayer, 48, 48, false, "KQRBNP2/kqrbnp2/8/8/8/8/8/8"); pictureBox1.Image = Board.TakePicture(pictureBox1.Width, pictureBox1.Height); Board.Dispose(); } catch { } }
private void AddChessPiece(ChessPieceStyle ePieceStyle, int[,] BoardState) { //************************Add Tot********************** //Quân Tốt Trắng nằm ở dòng 2 //Quân Tốt Đen nằm ở dòng 7 //***************************************************** if (this._PieceSize == 0) { this._PieceSize = this._CellSize; } for (int y = 1; y <= 8; y++) { for (int x = 1; x <= 8; x++) { if (BoardState[x, y] > 0) { ChessPieceType eType = (ChessPieceType)(BoardState[x, y] / 10); ChessSide eSide = (ChessSide)(BoardState[x, y] % 10); arrChessCell[x, y].ChessPiece = new UcChessPiece(eSide, eType, ePieceStyle, this._CellSize, this._PieceSize, x, y, arrChessCell[x, y]); } } } }
/* * Hàm này trả về tên của hình ảnh quân cờ chứa trong resource * VD: Muon lay quan Mã màu Đen Style Classic * Bitmap img=GetChessPieceBitMap(ChessPieceSide.Black,ChessPieceType.Knight,ChessPieceStyle.Classic); * Hàm này lấy hình ảnh trong Resource có tên là "Black_K_1"; */ public static Bitmap GetChessPieceBitMap(ChessSide Side, ChessPieceType Type, ChessPieceStyle Style) { string strImg = ""; switch (Side) { case ChessSide.Black: strImg += "Black_"; break; case ChessSide.White: strImg += "White_"; break; } switch (Type) { case ChessPieceType.Pawn: strImg += "P_"; break; case ChessPieceType.Bishop: strImg += "B_"; break; case ChessPieceType.Knight: strImg += "N_"; break; case ChessPieceType.Rook: strImg += "R_"; break; case ChessPieceType.Queen: strImg += "Q_"; break; case ChessPieceType.King: strImg += "K_"; break; } strImg += (int)Style; Bitmap img = (Bitmap)Properties.Resources.ResourceManager.GetObject(strImg); return(img); }