OndrejNepozitek / Edgar-Unity

Unity Procedural Level Generator
https://ondrejnepozitek.github.io/Edgar-Unity/docs/introduction
MIT License
820 stars 70 forks source link

How to copy the outline tiles of a room? #87

Closed longtran2904 closed 3 years ago

longtran2904 commented 3 years ago

In your level map tutorial in the dead cells example, you copy all the tiles of the wall layer. But I just want to copy the perimeter of the layer like in the Rogue Legacy map. image How to do that?

OndrejNepozitek commented 3 years ago

Each RoomInstance has an OutlinePolygon property which gives you an instance of Polygon2D class. And Polygon2D has a GetOutlinePoints() method to get all the points on the outline. These points already have the correct position so you don't have to add the position of the room to them.

longtran2904 commented 3 years ago

But the GetOutlinePoints only return the corners a room. Is there a way to get all the outline points?

OndrejNepozitek commented 3 years ago

You're correct. The method is supposed to return all the outline points but it returns only the corners instead. I fixed the behaviour in the last commit and it'll be included in the next release.

In the meantime, you can manually apply the fix. To do so, locate the "Assets\Edgar\Runtime\Utils\Polygon2D.cs" file and replace its content with the following code - https://github.com/OndrejNepozitek/Edgar-Unity/blob/b8d9557337bc3826052d0f99291d3bb6d10d8130/Runtime/Utils/Polygon2D.cs. This step expects that you have the latest version of Edgar. If that's not the case, let me know.

longtran2904 commented 3 years ago

Rather than replace it, you should have two functions, one for each.

OndrejNepozitek commented 3 years ago

There are now 3 functions:

longtran2904 commented 3 years ago

You should change the name from GetPoints() to GetCornerPoints()

OndrejNepozitek commented 3 years ago

I might change the names before I release the next update. The current naming is consistent with what's used in the underlying geometry types but you're correct that it may be better to use a different name to make the purpose of the method clearer.