コード例 #1
0
    public bool MoveGrid(Direction direction)
    {
        if (!currentGrid.CanMoveDirection(gridCell, direction))
        {
            return(false);
        }

        Vector2Int newGridCell = gridCell;

        switch (direction)
        {
        case Direction.North:
            newGridCell = newGridCell + Vector2Int.up;
            break;

        case Direction.South:
            newGridCell = newGridCell + Vector2Int.down;
            break;

        case Direction.East:
            newGridCell = newGridCell + Vector2Int.right;
            break;

        case Direction.West:
            newGridCell = newGridCell + Vector2Int.left;
            break;
        }

        currentGrid.MoveObject(this, newGridCell);
        gridCell = newGridCell;

        return(true);
    }