protected void TryMove(int x, int y)
    {
        if (x > Position.X)
        {
            facing = Facing.RIGHT;
        }
        else if (x < Position.X)
        {
            facing = Facing.LEFT;
        }
        else if (y < Position.Y)
        {
            facing = Facing.UP;
        }
        else if (y > Position.Y)
        {
            facing = Facing.DOWN;
        }

        if (mapManager.CanMove(x, y))
        {
            playerState    = PlayerState.MOVING;
            targetPosition = new Position(x, y);
            targetVector   = mapManager.GetTilePosition(targetPosition.X, targetPosition.Y);
            targetVector.y = this.transform.position.y;
            targetVector  += movementOffset;
        }

        UpdateRotation();
    }
Esempio n. 2
0
 public bool CanMove(Vector3 position, eDir dir)
 {
     return(_MapManager.CanMove(transform.position, dir));
 }