Ejemplo n.º 1
0
        public static void Change(ref Chess a, ref Chess b)//a子位移到b子
        {
            Chess c = new Chess_blank();

            c.PB = b.PB;
            switch (a.type)
            {
            case chess_type.zu:
                b = new Chess_zu(a.side); break;

            case chess_type.pao:
                b = new Chess_pao(a.side); break;

            case chess_type.che:
                b = new Chess_che(a.side); break;

            case chess_type.ma:
                b = new Chess_ma(a.side); break;

            case chess_type.xiang:
                b = new Chess_xiang(a.side); break;

            case chess_type.shi:
                b = new Chess_shi(a.side); break;

            case chess_type.jiang:
                b = new Chess_jiang(a.side); break;
            }
            b.type     = a.type;
            b.side     = a.side;
            b.PB       = c.PB;
            b.PB.Image = a.PB.Image;
            a.Chess_Toblank(ref a, a.PB);
        }
Ejemplo n.º 2
0
        public Board(Lobby the_lobby, string str)
        {
            lobby = the_lobby;
            pictureBox1.Location  = ChessBoard.Location;
            pictureBox1.Height    = ChessBoard.Height;
            pictureBox1.Width     = ChessBoard.Width;
            pictureBox1.BackColor = Color.Transparent;
            InitializeComponent();
            for (int i = 0; i < 10; i++)
            {
                checkerboard[i] = new Chess[9];//10行9列
            }
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    checkerboard[i][j] = new Chess_blank();
                }
            }
            checkerboard[0][0] = new Chess_che(enemy);
            checkerboard[0][1] = new Chess_ma(enemy);
            checkerboard[0][2] = new Chess_xiang(enemy);
            checkerboard[0][3] = new Chess_shi(enemy);
            checkerboard[0][4] = new Chess_jiang(enemy);
            checkerboard[0][5] = new Chess_shi(enemy);
            checkerboard[0][6] = new Chess_xiang(enemy);
            checkerboard[0][7] = new Chess_ma(enemy);
            checkerboard[0][8] = new Chess_che(enemy);
            checkerboard[2][1] = new Chess_pao(enemy);
            checkerboard[2][7] = new Chess_pao(enemy);
            checkerboard[3][0] = new Chess_zu(enemy);
            checkerboard[3][2] = new Chess_zu(enemy);
            checkerboard[3][4] = new Chess_zu(enemy);
            checkerboard[3][6] = new Chess_zu(enemy);
            checkerboard[3][8] = new Chess_zu(enemy);


            checkerboard[6][0] = new Chess_zu(me);
            checkerboard[6][2] = new Chess_zu(me);
            checkerboard[6][4] = new Chess_zu(me);
            checkerboard[6][6] = new Chess_zu(me);
            checkerboard[6][8] = new Chess_zu(me);
            checkerboard[7][1] = new Chess_pao(me);
            checkerboard[7][7] = new Chess_pao(me);
            checkerboard[9][0] = new Chess_che(me);
            checkerboard[9][1] = new Chess_ma(me);
            checkerboard[9][2] = new Chess_xiang(me);
            checkerboard[9][3] = new Chess_shi(me);
            checkerboard[9][4] = new Chess_jiang(me);
            checkerboard[9][5] = new Chess_shi(me);
            checkerboard[9][6] = new Chess_xiang(me);
            checkerboard[9][7] = new Chess_ma(me);
            checkerboard[9][8] = new Chess_che(me);
            Clearground(this, ref checkerboard);

            for (int i = 0; i != 9; ++i)
            {
                for (int j = 0; j != 10; ++j)
                {
                    ChessBoard.Controls.Add(checkerboard[j][i].PB);
                }
            }
            if (str.Equals("0"))
            {
                me    = player_type.blue;
                enemy = player_type.red;
            }
            else
            {
                me    = player_type.red;
                enemy = player_type.blue;
            }
        }