Beispiel #1
0
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION playerForward = player.direction;
        btBoardSpace     space1        = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerForward);

        if (space1 == null || space1.IsPassable() == true)
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }
        btBoardSpace space2 = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerForward, 2);

        if (space2 == null || space2.IsPassable() == false)
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        player.startSpace = player.currentSpace;        //btTileManager.instance.GetSpace( player.xIndex, player.yIndex );
        player.endSpace   = space2;
        player.tileState  = btTile.TILESTATE.JUMPING;

        this.currentState = btFunctionNode.NODE_STATE.RUNNING;
        return(this.currentState);
    }
Beispiel #2
0
    /// <summary>
    /// Returns whether the given space can be passed
    /// </summary>
    /// <param name="_xIndex">The x index of the space</param>
    /// <param name="_yIndex">The y index of the space</param>
    /// <returns></returns>
    public bool GetIsSpacePassable(int _xIndex, int _yIndex)
    {
        btBoardSpace space = this.GetSpace(_xIndex, _yIndex);

        if (space == null)
        {
            return(false);
        }

        return(space.IsPassable());
    }
Beispiel #3
0
    public override void OnMoveableTileEnter(btTile _tile, DIRECTION _enterDirection)
    {
        btBoardSpace moveToSpace = btTileManager.instance.GetSpaceInDirectionFromTile(this, this.direction, 1);

        if (moveToSpace == null || moveToSpace.IsPassable() == false)
        {
            return;
        }
        _tile.tileState       = btTile.TILESTATE.FORCE_MOVE;
        _tile.forceDirection  = this.direction;
        _tile.currentMovement = 0.0f;
        _tile.startSpace      = this.currentSpace;
        _tile.endSpace        = moveToSpace;
    }
Beispiel #4
0
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION playerLeft = btTileManager.DirectionTurnedLeft(player.direction);
        btBoardSpace     leftSpace  = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerLeft, 1);

        if (leftSpace == null || leftSpace.IsPassable() == false)
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        return(NODE_STATE.SUCCEEDED);
    }
Beispiel #5
0
    public override void OnMoveableTileEnter(btTile _tile, DIRECTION _enterDirection)
    {
        DIRECTION    slideDirection = _enterDirection;
        btBoardSpace adjacentSpace  = btTileManager.instance.GetSpaceInDirectionFromTile(this, slideDirection, 1);

        if (adjacentSpace == null || adjacentSpace.IsPassable() == false)
        {
            return;
        }
        _tile.tileState       = btTile.TILESTATE.SLIDING;
        _tile.slideDirection  = slideDirection;
        _tile.startSpace      = this.currentSpace;
        _tile.endSpace        = adjacentSpace;
        _tile.currentMovement = 0.0f;
    }
Beispiel #6
0
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION forward = player.direction;

        for (int distance = 1; distance <= this.variable; ++distance)
        {
            btBoardSpace space = btTileManager.instance.GetSpaceInDirectionFromTile(player, forward, distance);
            if (space == null ||
                space.IsPassable() == false)
            {
                this.currentState = btFunctionNode.NODE_STATE.FAILED;
                return(this.currentState);
            }
        }

        this.currentState = btFunctionNode.NODE_STATE.SUCCEEDED;
        return(this.currentState);
    }
Beispiel #7
0
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION playerForward = player.direction;
        btBoardSpace     space         = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerForward);

        if (space == null || space.IsPassable() == false)
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }
        player.tileState       = btTile.TILESTATE.MOVING_FORWARD;
        player.startSpace      = player.currentSpace;
        player.endSpace        = space;
        player.currentMovement = 0.0f;

        this.currentState = btFunctionNode.NODE_STATE.RUNNING;
        return(this.currentState);
    }
Beispiel #8
0
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION playerForward = player.direction;
        btBoardSpace     space1        = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerForward, 1);

        if (space1 == null)           // Fail if there is no tile in front of the player
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        List <btBoulderTile> boulders = space1.GetTilesOfType <btBoulderTile>();

        if (boulders.Count == 0) // Fail if there is no boulder in front of the player
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        btBoardSpace space2 = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerForward, 2);

        if (space2 == null || space2.IsPassable() == false)           // Fail if there is no tile in front of the boulder or it is impassable
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        btBoulderTile boulder = boulders[0];

        boulder.tileState       = btTile.TILESTATE.FORCE_MOVE;
        boulder.forceDirection  = player.direction;
        boulder.currentMovement = 0.0f;
        boulder.startSpace      = boulder.currentSpace;
        boulder.endSpace        = space2;

        this.currentState = btFunctionNode.NODE_STATE.RUNNING;
        return(this.currentState);
    }
    public override NODE_STATE TreeExecute()
    {
        btPlayerTile player = btTileManager.instance.playerTile;

        btTile.DIRECTION playerLeft = btTileManager.DirectionTurnedLeft(player.direction);
        btBoardSpace     space      = btTileManager.instance.GetSpaceInDirectionFromTile(player, playerLeft, 1);

        if (space == null || space.IsPassable() == false)
        {
            this.currentState = btFunctionNode.NODE_STATE.FAILED;
            return(this.currentState);
        }

        player.isTurning        = true;
        player.tileState        = btTile.TILESTATE.TURNING_LEFT;
        player.startingRotation = player.GetRotation();
        player.startSpace       = player.currentSpace;
        player.endSpace         = space;
        player.currentMovement  = 0.0f;

        this.currentState = btFunctionNode.NODE_STATE.RUNNING;
        return(this.currentState);
    }