コード例 #1
0
ファイル: PieceTower.cs プロジェクト: Yauten/Taoex-Archive
    /// <summary>
    /// Searchs the normal moves.
    /// </summary>
    /// <param name="piece">Piece.</param>
    /// <param name="moves">Moves.</param>
    private void SearchNormalMoves(PieceData piece, MoveSet moves)
    {
        TileNode cur = node;

        // extend out by the range and search for more.
        for (int r = 0; r < piece.range; r++)
        {
            // move to next tile
            cur = cur.adjacent[piece.direction];

            // check if current tile is one you can move to
            if (CheckCurrentTileMove(cur))
            {
                moves.AddMove(node, false, cur);
            }

            // check if any more moves can be made after (not including range)
            if (!CheckFurtherMovement(cur))
            {
                break;
            }

            // run checks to see if hooking is possible
            if (CheckHookMove(cur, piece))
            {
                moves.AddMove(node, true, cur, cur.adjacent[hook.direction]);
            }
        }
    }
コード例 #2
0
ファイル: PieceTower.cs プロジェクト: Yauten/Taoex-Archive
    /// <summary>
    /// Returns a set of moves based on random way roll.
    /// </summary>
    /// <param name="roll"></param>
    /// <returns></returns>
    public MoveSet GetWayMove(int roll, int wayLineID)
    {
        MoveSet moves = new MoveSet();
        bool    c     = false;

        if (roll == 9)
        {
            c    = true;
            roll = 5;
            moves.AddMove(node, false, node); // on a c, player can stay
        }
        else if (roll > 4)
        {
            roll -= 4;
        }

        for (int d = 0; d < 6; d++)
        {
            TileNode cur = node;

            if (node.adjacent[d] == null)
            {
                continue;
            }

            // not along the way, look in another direction
            if (wayLineID != node.adjacent[d].wayLine && node.adjacent[d].type != TileNode.Type.WayCross)
            {
                continue;
            }

            // keep going along direction d
            for (int r = 0; r < roll; r++)
            {
                if (cur.adjacent[d] == null || cur.adjacent[d].type == TileNode.Type.Block)
                {
                    break;
                }

                cur = cur.adjacent[d];

                // Can't capture own pieces
                if (cur.tower != null && cur.tower.owningColour == owningColour)
                {
                    continue;
                }

                if (c || r == roll - 1)
                {
                    moves.AddMove(node, false, cur);
                }
            }
        }

        return(moves);
    }
コード例 #3
0
ファイル: PieceTower.cs プロジェクト: Yauten/Taoex-Archive
    /// <summary>
    /// Searchs the reverse hook moves.
    /// </summary>
    /// <param name="piece">Piece.</param>
    /// <param name="moves">Moves.</param>
    private void SearchReverseHookMoves(PieceData piece, MoveSet moves)
    {
        TileNode cur    = node.adjacent[hook.direction];
        TileNode hooked = node.adjacent[hook.direction];

        #region reverse hook condition
        // can't revese hook your own pieces
        if (piece.colour == owningColour)
        {
            return;
        }

        // must have tower of 6 to hook
        if (pieces.Count != 6)
        {
            return;
        }

        // check if able to move on the given tile
        if (!CheckCurrentTileMove(cur))
        {
            return;
        }

        // Can't jump or move along the way
        if (cur.type == TileNode.Type.Way && cur.adjacent[piece.direction] != node)
        {
            return;
        }

        #endregion

        // add hook'd
        //moves.AddMove(node, false, hooked);

        #region move search
        // extend out by the range and search for more.
        for (int r = 0; r < piece.range; r++)
        {
            // move to next tile
            cur = cur.adjacent[piece.direction];

            // check if current tile is one you can move to
            if (CheckCurrentTileMove(cur))
            {
                moves.AddMove(node, true, hooked, cur);
            }

            // check if any more moves can be made after (not including range)
            if (!CheckFurtherMovement(cur))
            {
                break;
            }
        }
        #endregion
    }
コード例 #4
0
        /// <summary>
        /// Returns a move set with the given moves.
        /// </summary>
        public static MoveSet CreateMoveSet(params Move[] moves)
        {
            var moveSet = new MoveSet();

            foreach (var move in moves)
            {
                moveSet.AddMove(move);
            }

            return(moveSet);
        }
コード例 #5
0
 /// <summary>
 /// Adds the given move to the built move set.
 /// </summary>
 /// <param name="move">The move to add.</param>
 public MoveSetBuilder WithMove(Move move)
 {
     _moveSet.AddMove(move);
     return(this);
 }