Untitled
unknown
csharp
a month ago
2.6 kB
5
Indexable
Never
private void CreateCoridors(int offSetX, int offSetY, BiomeRegion region) { int halfRoomH = (int)System.Math.Floor(_roomHeight / 2.0); int halfRoomW = (int)System.Math.Floor(_roomWidth / 2.0); var directions = new Dictionary<string, (Vector2Int checkOffset, Vector2Int removeOffset1, Vector2Int removeOffset2,Vector2Int removeOffset3, Vector2Int placeOffset1, Vector2Int placeOffset2)> { {"LEFT", (new Vector2Int(halfRoomW + 2, 1), new Vector2Int(halfRoomW, 0), new Vector2Int(halfRoomW + 2, 0), new Vector2Int(halfRoomW + 1, 0), new Vector2Int(halfRoomW + 1, 1), new Vector2Int(halfRoomW + 1, -1))}, {"RIGHT", (new Vector2Int(-(halfRoomW + 2), 1), new Vector2Int(-halfRoomW, 0), new Vector2Int(-(halfRoomW + 2), 0), new Vector2Int(-(halfRoomW + 1), 0), new Vector2Int(-(halfRoomW + 1), 1), new Vector2Int(-(halfRoomW + 1), -1))}, {"UP", (new Vector2Int(1, halfRoomH + 2), new Vector2Int(0, halfRoomH), new Vector2Int(0, halfRoomH + 2), new Vector2Int(0, halfRoomH + 1), new Vector2Int(1, halfRoomH + 1), new Vector2Int(-1, halfRoomH + 1))}, {"DOWN", (new Vector2Int(1, -(halfRoomH + 2)), new Vector2Int(0, -halfRoomH), new Vector2Int(0, -(halfRoomH + 2)), new Vector2Int(0, -(halfRoomH + 1)), new Vector2Int(1, -(halfRoomH + 1)), new Vector2Int(-1, -(halfRoomH + 1)))} }; foreach (var direction in directions) { var (checkOffset, removeOffset1, removeOffset2, removeOffset3 ,placeOffset1, placeOffset2) = direction.Value; if (GetWallAtPosition(CalculateReturnVec2(offSetX, offSetY, checkOffset.x, checkOffset.y)) != null) { RemoveWallIfExists(CalculateReturnVec3(offSetX, offSetY, removeOffset1.x, removeOffset1.y)); RemoveWallIfExists(CalculateReturnVec3(offSetX, offSetY, removeOffset2.x, removeOffset2.y)); PlaceWallAtPosition(CalculateReturnVec2(offSetX, offSetY, placeOffset1.x, placeOffset1.y), region); PlaceWallAtPosition(CalculateReturnVec2(offSetX, offSetY, placeOffset2.x, placeOffset2.y), region); PlaceTileAtPosition(CalculateReturnVec2(offSetX, offSetY, removeOffset1.x, removeOffset1.y), region); PlaceTileAtPosition(CalculateReturnVec2(offSetX, offSetY, removeOffset3.x, removeOffset3.y), region); PlaceTileAtPosition(CalculateReturnVec2(offSetX, offSetY, removeOffset2.x, removeOffset2.y), GetWallAtPosition(CalculateReturnVec2(offSetX, offSetY, checkOffset.x, checkOffset.y)).biomeRegion); } } }
Leave a Comment