[英]c# algorithm to find nearest tile with specific type
Sorry for the title but i didn't know how to describe my problem in one sentence. 对不起,标题,但是我不知道如何用一句话描述我的问题。
So basicly i am trying to create something to make random dungeons. 因此,基本上,我正在尝试创建一些东西来制作随机的地牢。 I make rooms at random positions on a 2d grid and add doors to every room. 我在2D网格上的任意位置放置房间,并为每个房间添加门。 Then I get the first door and try to find the closest other door but I can't find a good algorithm to this, I tried a modified version of a* and also looked at flood-fill but that isnt what I need. 然后我得到了第一扇门,并试图找到最接近的另一扇门,但是我找不到一个合适的算法,我尝试了a *的修改版本,还查看了洪水填充,但这不是我所需要的。 I was thinking of some sort of spiral around the first door and check every tile we pass to see if its a door. 我在想第一扇门周围的螺旋形,检查我们经过的每块瓷砖,看看它是否是一扇门。 I have a list of all the doors in the level if that helps but there are a lot so i don't think it's a good idea to check the distance to every door. 如果有帮助,我会列出该级别中所有门的列表,但是列表很多,所以我认为检查到每个门的距离不是一个好主意。
Does anyone know if there is a good algorithm for this? 有谁知道这是否有一个好的算法?
If a game stores its objects in a quadtree , searching of existing items in a scene prioritized by proximity could be done. 如果游戏将其对象存储在四叉树中 ,则可以在按优先级排序的场景中搜索现有项目。 Instead of searching for a collision, one can search for an object of a specific type. 无需搜索冲突,而是可以搜索特定类型的对象。 This can be done with the is
operator in C#. 可以使用C#中的is
运算符来完成。 This question may be better suited for the Game Development Stack Exchange . 这个问题可能更适合于Game Development Stack Exchange 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.