现在的位置: 首页 > 综合 > 正文

北大青鸟 中国象棋 实习项目 (项目源代码级说明七)

2014年01月22日 ⁄ 综合 ⁄ 共 1528字 ⁄ 字号 评论关闭
 棋子士:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace chess
{
    /// <summary>
    /// 棋子士
    /// </summary>
    [Serializable()]
    class chessItemShi : ChessItemBase
    {
        /// <summary>
        /// 重写父类限制走法方法
        /// </summary>
        /// <param name="ChessX">坐标点的X坐标</param>
        /// <param name="ChessY">坐标点的Y坐标</param>
        /// <returns>返回结果bool</returns>
        protected override bool LimitPoint(int ChessX, int ChessY)
        {
            //先执行基类中的方法
            if (base.LimitPoint(ChessX, ChessY))
            {
                Point begin = PointToGrid(this.Location.X, this.Location.Y);
                begin.Offset(1, 1);
                Point end = PointToGrid(ChessX, ChessY);
                if (((begin.X - end.X) == 1) || ((begin.X - end.X) == -1))
                {
                    if(((begin.Y-end.Y)==1)||((begin.Y-end.Y)==-1)){
                        if((4<=end.X)&&(end.X<=6)){
                            if (this.chesstype == ChessTypes.black)
                            {
                                if((8<=end.Y)&&(end.Y<=10)){
                                    return true;
                                }
                            }
                            else if (this.chesstype == ChessTypes.blue)
                            {
                                if((1<=end.Y)&&(end.Y<=3)){
                                    return true;
                                }
                            }
                        }
                    }
                }

            }
            return false;
        }
    }
}

抱歉!评论已关闭.