示例#1
0
        private void PerformNextGenerationStep(List <BaseCell> activeCells)
        {
            int index = activeCells.Count - 1;

            index = ip.useFirstIndex ? 0 : index;
            BaseCell currentCell = activeCells[index];

            if (currentCell.IsFullyInitialized)
            {
                activeCells.RemoveAt(index);
                return;
            }
            CompassDirection direction   = currentCell.RandomUninitializedDirection;
            IntVector2       coordinates = currentCell.coordinates + direction.ToIntVector2();

            if (ContainsCoordinates(coordinates))
            {
                BaseCell neighbor = GetCell(coordinates);
                if (neighbor == null)
                {
                    neighbor = CreateCell(coordinates);
                    CreatePassage(currentCell, neighbor, direction);
                    activeCells.Add(neighbor);
                }
                // if we match on room.settingsIndex instead we can merge same rooms
                else if (currentCell.room == neighbor.room)
                {
                    CreatePassageInSameRoom(currentCell, neighbor, direction);
                }
                else
                {
                    CreateWall(currentCell, neighbor, direction);
                }
            }
            else
            {
                CreateWall(currentCell, null, direction);
            }
        }