public override void Generate(BoardGenerator boardGenerator) { char charToWrite; if (!useDefaultEmptyChar) { charToWrite = alternateCharToUse; } else { charToWrite = boardGenerator.boardGenerationProfile.boardLibrary.GetDefaultEmptyChar(); } Vector2 startLocation = startLocations[Random.Range(0, startLocations.Length)]; GridPosition startPosition = boardGenerator.Vector2ToGridPosition(startLocation); GridPosition targetPosition = boardGenerator.GetRandomGridPosition(); GridPosition currentPosition = startPosition; for (int i = 0; i < tunnelMaxLength; i++) { if (RollPercentage(turnPercentChance)) { targetPosition = boardGenerator.GetRandomGridPosition(); } if (spawnRandomRoomsOnTunnel) { if (RollPercentage(roomSpawnChance)) { RoomTemplate randTemplate = roomTemplates[Random.Range(0, roomTemplates.Length)]; boardGenerator.DrawTemplate(currentPosition.x, currentPosition.y, randTemplate, overwriteFilledSpaces, generatesEmptySpace); } } Dig(boardGenerator, currentPosition, targetPosition, charToWrite); } if (spawnRoomOnTunnelEnd) { RoomTemplate randTemplate = roomTemplates[Random.Range(0, roomTemplates.Length)]; boardGenerator.DrawTemplate(currentPosition.x, currentPosition.y, randTemplate, overwriteFilledSpaces, generatesEmptySpace); } }
public override void Generate(BoardGenerator boardGenerator) { char charToWrite; if (!useDefaultEmptyChar) { charToWrite = alternateCharToUse; } else { charToWrite = boardGenerator.boardGenerationProfile.boardLibrary.GetDefaultEmptyChar(); } Vector2 startLocation = startLocations[Random.Range(0, startLocations.Length)]; GridPosition startPosition = boardGenerator.Vector2ToGridPosition(startLocation); GridPosition targetPosition = boardGenerator.GetRandomGridPosition(); GridPosition currentPosition = startPosition; for (int i = 0; i < tunnelLength; i++) { if (RollPercentage(turnPercentChance)) { GridPosition turnPosition = boardGenerator.GetRandomGridPosition(); while (turnPosition.x == targetPosition.x || turnPosition.y == targetPosition.y) { turnPosition = boardGenerator.GetRandomGridPosition(); } targetPosition = turnPosition; } if (spawnRandomRoomsOnTunnel) { if (RollPercentage(roomSpawnChance)) { RoomTemplate randTemplate = roomTemplates[Random.Range(0, roomTemplates.Length)]; boardGenerator.DrawTemplate(currentPosition.x, currentPosition.y, randTemplate, overwriteFilledSpaces, generatesEmptySpace); } } List <GeneratorWanderTunnel> branchTunnelerList = new List <GeneratorWanderTunnel>(); if (RollPercentage(branchPercentChance)) { GeneratorWanderTunnel wanderTunneler = ScriptableObject.CreateInstance <GeneratorWanderTunnel>(); wanderTunneler.tunnelMaxLength = branchTunnel.tunnelMaxLength; wanderTunneler.overwriteFilledSpaces = branchTunnel.overwriteFilledSpaces; wanderTunneler.useDefaultEmptyChar = branchTunnel.useDefaultEmptyChar; wanderTunneler.alternateCharToUse = branchTunnel.alternateCharToUse; wanderTunneler.startLocations = new Vector2[1]; wanderTunneler.startLocations[0] = new Vector2(currentPosition.x, currentPosition.y); wanderTunneler.roomTemplates = branchTunnel.roomTemplates; wanderTunneler.spawnRoomsOnTunnelTurn = branchTunnel.spawnRoomsOnTunnelTurn; wanderTunneler.spawnRoomOnTunnelEnd = branchTunnel.spawnRoomOnTunnelEnd; wanderTunneler.turnNoiseValue = branchTunnel.turnNoiseValue; branchTunnelerList.Add(wanderTunneler); } for (int j = 0; j < branchTunnelerList.Count; j++) { branchTunnelerList[j].Generate(boardGenerator); } Dig(boardGenerator, currentPosition, targetPosition, charToWrite); } if (spawnRandomRoomsOnTunnel) { RoomTemplate randTemplate = roomTemplates[Random.Range(0, roomTemplates.Length)]; boardGenerator.DrawTemplate(currentPosition.x, currentPosition.y, randTemplate, overwriteFilledSpaces, generatesEmptySpace); } }