Exemplo n.º 1
0
 public void ResetBoard()
 {
     for (int i = 0; i < GameParams.BoardHeight; i++)
     {
         var indexI     = GetDefaultBoardIndex(i);
         var pieceColor = i < 5 ? PieceColor.Red : PieceColor.Black;
         for (int j = 0; j < GameParams.BoardWidth; j++)
         {
             var indexJ    = 4 - Mathf.Abs(j - 4);
             var pieceType = defaultBoard[indexI, indexJ];
             BoardPieces[j, i] = new PieceInfo(pieceType, pieceColor);
         }
     }
 }
Exemplo n.º 2
0
 public void SetPieceInfo(PiecePoint point, PieceInfo info)
 {
     BoardPieces[point.X, point.Y] = info;
 }
Exemplo n.º 3
0
        private static HashSet <PiecePoint> GetActionPointsAroundEye(
            ChessBoard board,
            ChessPiece piece,
            Direction[] wayDirections,
            PiecePoint eyePoint,
            bool isStepPiece = true,
            bool isCannon    = false,
            bool isKing      = false,
            bool addition    = false)
        {
            var actionWays = new HashSet <PiecePoint>();

            foreach (var wayDirection in wayDirections)
            {
                var wayPoint = eyePoint ?? piece.PiecePoint;
                do
                {
                    wayPoint = wayPoint.GetPointInDirection(wayDirection);
                    var flag = GetLegalFlag(board, piece, wayPoint);
                    if (!IsLegal(flag) || (flag == LegalFlag.Eatting && isCannon && !addition))
                    {
                        break;
                    }
                    actionWays.Add(wayPoint);
                    if (IsLegalPointNotBlank(flag))
                    {
                        break;
                    }
                } while (!isStepPiece);
                if (isCannon)
                {
                    do
                    {
                        wayPoint = wayPoint.GetPointInDirection(wayDirection);
                    }while (IsLegalPoint(board, piece, wayPoint));
                    if (IsLegalPointNotBlank(board, piece, wayPoint))
                    {
                        actionWays.Add(wayPoint);
                    }
                }
            }
            if (isKing)
            {
                var pieceInfo = new PieceInfo();
                var wayPoint  = piece.PiecePoint;
                var direction = wayPoint.Y < 5 ? Direction.Up : Direction.Down;
                do
                {
                    wayPoint = wayPoint.GetPointInDirection(direction);
                    if (!ActionAreaRule.FullArea.IsPointInArea(wayPoint))
                    {
                        break;
                    }
                    pieceInfo = board.GetPieceInfo(wayPoint);
                } while (pieceInfo.IsBlank());
                if (pieceInfo.PieceType == PieceType.King)
                {
                    actionWays.Add(wayPoint);
                }
            }
            return(actionWays);
        }
Exemplo n.º 4
0
 public ChessPiece(PiecePoint point, PieceInfo info)
 {
     PiecePoint = point;
     PieceInfo  = info;
 }
Exemplo n.º 5
0
 public PieceInfo EatOrFusePiece(PieceInfo info)
 {
     return(PieceInfo * info);
 }
Exemplo n.º 6
0
 public PieceInfo Divide(PieceInfo info)
 {
     return(PieceInfo - info);
 }
Exemplo n.º 7
0
 public bool CanFuse(PieceInfo info)
 {
     return(PieceInfo.CanFuse(PieceInfo, info));
 }
Exemplo n.º 8
0
 public bool CanEat(PieceInfo info)
 {
     return(PieceInfo.CanEat(PieceInfo, info));
 }