标题: 用.NET做象棋游戏怎么写车的算法啊 [打印本页] 作者: 1633611968 时间: 2014-6-4 13:44 标题: 用.NET做象棋游戏怎么写车的算法啊 public override void MoveTo(int i, int j)
{
if (CanMoveTo(i, j))
{
this.Location = AppHelper.Axis[i, j];
if (i == 0 && j < 9)
{
Direction = ChinaChess.Controls.Direction.Up;//qian;
}
else if (i <= 8 && j == 0)
{
this.Direction = Direction.UpRight;//you;
}
else if (i==0 && j >0)
{
this.Direction=Direction.
}
else
{
this.Direction = Direction.UpLeftRight;
}
this.ArrayIndex = new KeyValuePair<int, int>(i, j);
}
}
public override bool CanMoveTo(int i, int j)
{
if (Direction == Direction.Up)
{
if ((this.ArrayIndex.Key - i == 1) && (this.ArrayIndex.Value - j == 0))
{
return true;
}
}
else if (Direction == Direction.Right)
{
if ((this.ArrayIndex.Key - i == 0) && (this.ArrayIndex.Value + j == 1))
{
return true;
}
else if ((this.ArrayIndex.Key - i == 1) && (this.ArrayIndex.Value - j == 0))
{
return true;
}
}
return false;
}