Пример #1
0
        public void DigTunnel(BoardGenerator boardGenerator, GridPosition startPosition, GridPosition tunnelGoal)
        {
            GridPosition currentDigPosition = startPosition;

            for (int i = 0; i < maxLengthPerTunnel; i++)
            {
                if (currentDigPosition.x < tunnelGoal.x)
                {
                    currentDigPosition.x++;
                }
                else if (currentDigPosition.x > tunnelGoal.x)
                {
                    currentDigPosition.x--;
                }
                else
                {
                    if (spawnRoomsAtTunnelEnds)
                    {
                        SpawnRoomTemplateAtTunnelEnd(boardGenerator, currentDigPosition);
                    }

                    break;
                }

                for (int j = 0; j < tunnelWidth; j++)
                {
                    boardGenerator.WriteToBoardGrid(currentDigPosition.x, currentDigPosition.y + j, GetCharToWriteForTunnel(boardGenerator), true, true);
                }
            }
            for (int k = 0; k < maxLengthPerTunnel; k++)
            {
                if (currentDigPosition.y < tunnelGoal.y)
                {
                    currentDigPosition.y++;
                }
                else if (currentDigPosition.y > tunnelGoal.y)
                {
                    currentDigPosition.y--;
                }
                else
                {
                    if (spawnRoomsAtTunnelEnds)
                    {
                        SpawnRoomTemplateAtTunnelEnd(boardGenerator, currentDigPosition);
                    }
                    break;
                }
                for (int s = 0; s < tunnelWidth; s++)
                {
                    boardGenerator.WriteToBoardGrid(currentDigPosition.x + s, currentDigPosition.y, GetCharToWriteForTunnel(boardGenerator), true, true);
                }
            }
        }
Пример #2
0
 void RandomFillMap(BoardGenerator boardGenerator)
 {
     for (int x = 0; x < boardGenerator.boardGenerationProfile.boardHorizontalSize; x++)
     {
         for (int y = 0; y < boardGenerator.boardGenerationProfile.boardVerticalSize; y++)
         {
             boardGenerator.WriteToBoardGrid(x, y, (Random.Range(0, 100) < randomFillPercent) ? charForFill : emptySpaceChar, overwriteFilledSpaces, false);
         }
     }
 }
Пример #3
0
        void SmoothMap(BoardGenerator boardGenerator)
        {
            for (int x = 0; x < boardGenerator.boardGenerationProfile.boardHorizontalSize; x++)
            {
                for (int y = 0; y < boardGenerator.boardGenerationProfile.boardVerticalSize; y++)
                {
                    int neighbourWallTiles = GetSurroundingWallCount(x, y, boardGenerator);

                    if (neighbourWallTiles > 4)
                    {
                        boardGenerator.WriteToBoardGrid(x, y, charForFill, overwriteFilledSpaces, false);
                    }
                    else if (neighbourWallTiles < 4)
                    {
                        boardGenerator.WriteToBoardGrid(x, y, emptySpaceChar, overwriteFilledSpaces, false);
                    }
                }
            }
        }
Пример #4
0
        private void WriteChainRoomToGrid(BoardGenerator boardGenerator, RoomChain roomChainComponent, Vector2 roomOrigin, RoomTemplate roomTemplate, int chainNumber, bool isOnPath)
        {
#if UNITY_EDITOR
            roomChainComponent.GenerateRoomPlaceHolderGameObject(boardGenerator, roomOrigin, roomTemplate, chainNumber, isOnPath, "Chain Room");
#endif
            int charIndex = 0;
            for (int i = 0; i < roomSizeX; i++)
            {
                for (int j = 0; j < roomSizeY; j++)
                {
                    char selectedChar = roomTemplate.roomChars[charIndex];
                    if (selectedChar != '\0')
                    {
                        Vector2 spawnPos = new Vector2(i, j) + roomOrigin;

                        int x = (int)spawnPos.x;
                        int y = (int)spawnPos.y;

                        boardGenerator.WriteToBoardGrid(x, y, selectedChar, overwriteFilledSpaces, isOnPath);
                    }
                    charIndex++;
                }
            }
        }