Ejemplo n.º 1
0
 public ChessPoint()
 {
     leftUpChesspoint = null;
     upChesspoint = null;
     rightChesspoint = null;
     leftChesspoint = null;
     rightChesspoint = null;
     leftDownChesspoint = null;
     downChesspoint = null;
     rightDownChesspoint = null;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建/初始化棋盘(给棋盘上每个点赋值定义)
        /// </summary>
        private void createChessPoints()
        {
            //必须为每个数组对象创建实例。
            for (int i = 0; i < 5; i++)
            {
                chessPoints[i] = new ChessPoint();
            }
            #region 初始化棋盘可行走的点的属性,并配置各个点之间的关联性
            //绑定棋盘上的点到此类中
            //这将决定了每个点可以走向的点
            //1
            chessPoints[0].DownChesspoint = chessPoints[3];
            chessPoints[0].RightDownChesspoint = chessPoints[2];
            chessPoints[0].ChessPos = chessPos[0];

            //2
            chessPoints[1].LeftDownChesspoint = chessPoints[2];
            chessPoints[1].DownChesspoint = chessPoints[4];
            chessPoints[1].ChessPos = chessPos[1];

            //3
            chessPoints[2].LeftUpChesspoint = chessPoints[0];
            chessPoints[2].RightUpChesspoint = chessPoints[1];
            chessPoints[2].LeftDownChesspoint = chessPoints[3];
            chessPoints[2].RightDownChesspoint = chessPoints[4];
            chessPoints[2].ChessPos = chessPos[2];
            //4
            chessPoints[3].UpChesspoint = chessPoints[0];
            chessPoints[3].RightUpChesspoint = chessPoints[2];
            chessPoints[3].RightChesspoint = chessPoints[4];
            chessPoints[3].ChessPos = chessPos[3];
            //5
            chessPoints[4].UpChesspoint = chessPoints[1];
            chessPoints[4].LeftUpChesspoint = chessPoints[2];
            chessPoints[4].LeftChesspoint = chessPoints[3];
            chessPoints[4].ChessPos = chessPos[4];
            #endregion
        }