Exemplo n.º 1
0
    /// <summary>
    /// Initiates a coroutine based on the given direction
    /// </summary>
    /// <param name="direction">Direction to move to</param>
    public void Move(Direction direction)
    {
        // do not stack movements on the bear
        if (_going != null)
        {
            return;
        }

        // check if the given direction would be legal
        if (!board.IsLegalMove(this.LogicalPosition, direction))
        {
            return;
        }


        var destination = this.transform.position + directions[direction];

        float speed = MoveDistance / MoveDuration;

        _movingCoroutine = gameManager.navigator.PlayerMove(MoveDuration, speed, destination, this.transform,
                                                            () => { _going = direction; }, // before
                                                            () =>
        {
            UpdateBoardPosition();

            // signal the board (parent) for orb collisions
            // signal the board (parent) for tile state changes
            board.PlayerMoved();
            board.ActOnPreviousTile(direction);

            _going = null;
        },
                                                            // TODO: challenge access denial only when tiles are lowering in irrelevant locations
                                                            // no need to challenge access as long as the move is legal and the lock of lowering tiles is ignored
                                                            () => false
                                                            );
    }