Inheritance: Token
示例#1
0
        private void movecontrol_Knight(Knight t)
        {
            int po_x = t.getX();
            int po_y = t.getY();
            possiblemove.Clear();

            for (int i = 0; i < 8; i++)
            {
                if (po_x + Knight_move[i].X < 8 && po_x + Knight_move[i].X >= 0 && po_y + Knight_move[i].Y >= 0 && po_y + Knight_move[i].Y < 8)
                {
                    if (t_map[getIndex(po_x + Knight_move[i].X, po_y + Knight_move[i].Y)] != null)
                    {
                        if (t_map[getIndex(po_x + Knight_move[i].X, po_y + Knight_move[i].Y)].getSide() != tokenChosed.getSide())
                        {
                            possiblemove.Add(new Point(po_x + Knight_move[i].X, po_y + Knight_move[i].Y));
                        }
                    }
                    else
                    {
                        possiblemove.Add(new Point(po_x + Knight_move[i].X, po_y + Knight_move[i].Y));
                    }
                }
            }
        }
示例#2
0
文件: Form1.cs 项目: tuxoko/pdachess
        private void initTokens()
        {
            for (int i = 0; i < 64; i++)
            {
                t_map[i] = null;
            }
            //castle
            t_map[getIndex(0, 0)] = new Castle(0, 0, "b", Resources.Castle_b_l, Resources.Castle_b_d, Resources.Castle_b_l_p, Resources.Castle_b_d_p, Resources.Castle_b_l_s, Resources.Castle_b_d_s);
            t_map[getIndex(7, 0)] = new Castle(7, 0, "b", Resources.Castle_b_l, Resources.Castle_b_d, Resources.Castle_b_l_p, Resources.Castle_b_d_p, Resources.Castle_b_l_s, Resources.Castle_b_d_s);

            t_map[getIndex(0, 7)] = new Castle(0, 7, "w", Resources.Castle_w_l, Resources.Castle_w_d, Resources.Castle_w_l_p, Resources.Castle_w_d_p, Resources.Castle_w_l_s, Resources.Castle_w_d_s);
            t_map[getIndex(7, 7)] = new Castle(7, 7, "w", Resources.Castle_w_l, Resources.Castle_w_d, Resources.Castle_w_l_p, Resources.Castle_w_d_p, Resources.Castle_w_l_s, Resources.Castle_w_d_s);

            //Knight
            t_map[getIndex(1, 0)] = new Knight(1, 0, "b", Resources.Knight_b_l, Resources.Knight_b_d, Resources.Knight_b_l_p, Resources.Knight_b_d_p, Resources.Knight_b_l_s, Resources.Knight_b_d_s);
            t_map[getIndex(6, 0)] = new Knight(6, 0, "b", Resources.Knight_b_l, Resources.Knight_b_d, Resources.Knight_b_l_p, Resources.Knight_b_d_p, Resources.Knight_b_l_s, Resources.Knight_b_d_s);

            t_map[getIndex(1, 7)] = new Knight(1, 7, "w", Resources.Knight_w_l, Resources.Knight_w_d, Resources.Knight_w_l_p, Resources.Knight_w_d_p, Resources.Knight_w_l_s, Resources.Knight_w_d_s);
            t_map[getIndex(6, 7)] = new Knight(6, 7, "w", Resources.Knight_w_l, Resources.Knight_w_d, Resources.Knight_w_l_p, Resources.Knight_w_d_p, Resources.Knight_w_l_s, Resources.Knight_w_d_s);
            //Bishop
            t_map[getIndex(2, 0)] = new Bishop(2, 0, "b", Resources.Bishop_b_l, Resources.Bishop_b_d, Resources.Bishop_b_l_p, Resources.Bishop_b_d_p, Resources.Bishop_b_l_s, Resources.Bishop_b_d_s);
            t_map[getIndex(5, 0)] = new Bishop(5, 0, "b", Resources.Bishop_b_l, Resources.Bishop_b_d, Resources.Bishop_b_l_p, Resources.Bishop_b_d_p, Resources.Bishop_b_l_s, Resources.Bishop_b_d_s);

            t_map[getIndex(2, 7)] = new Bishop(2, 7, "w", Resources.Bishop_w_l, Resources.Bishop_w_d, Resources.Bishop_w_l_p, Resources.Bishop_w_d_p, Resources.Bishop_w_l_s, Resources.Bishop_w_d_s);
            t_map[getIndex(5, 7)] = new Bishop(5, 7, "w", Resources.Bishop_w_l, Resources.Bishop_w_d, Resources.Bishop_w_l_p, Resources.Bishop_w_d_p, Resources.Bishop_w_l_s, Resources.Bishop_w_d_s);

            //Queen
            t_map[getIndex(3, 0)] = new Queen(3, 0, "b", Resources.Queen_b_l, Resources.Queen_b_d, Resources.Queen_b_l_p, Resources.Queen_b_d_p, Resources.Queen_b_l_s, Resources.Queen_b_d_s);

            t_map[getIndex(3, 7)] = new Queen(3, 7, "w", Resources.Queen_w_l, Resources.Queen_w_d, Resources.Queen_w_l_p, Resources.Queen_w_d_p, Resources.Queen_w_l_s, Resources.Queen_w_d_s);

            //King
            t_map[getIndex(4, 0)] = new King(4, 0, "b", Resources.King_b_l, Resources.King_b_d, Resources.King_b_l_p, Resources.King_b_d_p, Resources.King_b_l_s, Resources.King_b_d_s);

            t_map[getIndex(4, 7)] = new King(4, 7, "w", Resources.King_w_l, Resources.King_w_d, Resources.King_w_l_p, Resources.King_w_d_p, Resources.King_w_l_s, Resources.King_w_d_s);

            //Pawn
            for (int i = 0; i < 8; i++)
            {
                t_map[getIndex(i, 1)] = new Pawn(i, 1, "b", Resources.Pawn_b_l, Resources.Pawn_b_d, Resources.Pawn_b_l_p, Resources.Pawn_b_d_p, Resources.Pawn_b_l_s, Resources.Pawn_b_d_s);
                t_map[getIndex(i, 6)] = new Pawn(i, 6, "w", Resources.Pawn_w_l, Resources.Pawn_w_d, Resources.Pawn_w_l_p, Resources.Pawn_w_d_p, Resources.Pawn_w_l_s, Resources.Pawn_w_d_s);
            }
        }