Exemple #1
0
    void GenerateInit(List <MuseumCell> activeCells)
    {
        MuseumCell cell = CreateCell(RandomCoordinate);

        cell.Initialize(CreateMuseumRoom());
        activeCells.Add(cell);
    }
Exemple #2
0
    private void CreateWall(MuseumCell cell, MuseumCell otherCell, CellDirection direction)
    {
        bool hasPainting = Random.value < paintingDensity;

        MuseumWall wall = Instantiate(wallPrefab) as MuseumWall;

        wall.Initialize(cell, otherCell, direction);
        if (otherCell != null)
        {
            wall = Instantiate(wallPrefab) as MuseumWall;
            wall.Initialize(otherCell, cell, direction.GetOpposite());
        }

        if (hasPainting)
        {
            Painting painting = Instantiate(paintingPrefab) as Painting;
            painting.Initialize(cell, direction);

            if (paintings.Length > 0)
            {
                string paintingName = paintings[(int)Random.Range(0, paintings.Length)];
                painting.LoadTexture(paintingName);
            }
        }
    }
Exemple #3
0
    private void CreatePassageInSameRoom(MuseumCell cell, MuseumCell otherCell, CellDirection direction)
    {
        MuseumRoom room = cell.room;

        bool isDisplayCase = Random.value < displayCaseProbability;

        if (isDisplayCase)
        {
            MuseumDisplayCase displayCase = Instantiate(displayCasePrefab) as MuseumDisplayCase;
            displayCase.Initialize(cell, otherCell, direction);
            displayCase = Instantiate(displayCasePrefab) as MuseumDisplayCase;
            displayCase.Initialize(otherCell, cell, direction.GetOpposite());

            if (paintings.Length > 0)
            {
                string paintingName = paintings[(int)Random.Range(0, paintings.Length)];
                displayCase.LoadTexture(paintingName);
            }
        }
        else
        {
            MuseumPassage passage = Instantiate(passagePrefab) as MuseumPassage;
            passage.Initialize(cell, otherCell, direction);
            passage = Instantiate(passagePrefab) as MuseumPassage;
            passage.Initialize(otherCell, cell, direction.GetOpposite());
        }
    }
Exemple #4
0
 public void Initialize(MuseumCell cell, CellDirection direction)
 {
     this.cell               = cell;
     this.direction          = direction;
     transform.parent        = cell.transform;
     transform.localPosition = Vector3.zero;
     transform.localRotation = direction.ToRotation();
 }
Exemple #5
0
    private MuseumCell CreateCell(Vector2Int gridCoordinate)
    {
        MuseumCell cell = Instantiate(cellPrefab) as MuseumCell;

        floorPlan[gridCoordinate.x, gridCoordinate.y] = cell;
        cell.gridCoordinate          = gridCoordinate;
        cell.name                    = "Museum Cell " + gridCoordinate.x + ", " + gridCoordinate.y;
        cell.transform.parent        = transform;
        cell.transform.localPosition = GridToWorldCoordinate(gridCoordinate);
        return(cell);
    }
Exemple #6
0
    private void CreatePassage(MuseumCell cell, MuseumCell otherCell, CellDirection direction)
    {
        MuseumPassage prefab  = Random.value < entryProbability ? entryPrefab : passagePrefab;
        MuseumPassage passage = Instantiate(prefab) as MuseumPassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MuseumPassage;
        if (passage is MuseumEntry)
        {
            otherCell.Initialize(CreateMuseumRoom());
        }
        else
        {
            otherCell.Initialize(cell.room);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
Exemple #7
0
    void GenerateNext(List <MuseumCell> activeCells)
    {
        int        currIdx  = activeCells.Count - 1;
        MuseumCell currCell = activeCells[currIdx];

        if (currCell.IsFullyInitialized)
        {
            activeCells.RemoveAt(currIdx);
            return;
        }
        CellDirection direction  = currCell.RandomUninitializedDirection;
        Vector2Int    coordinate = currCell.gridCoordinate + direction.ToVector2Int();

        if (InCoordinateRange(coordinate))
        {
            MuseumCell neighbor = GetCell(coordinate);
            if (neighbor == null)
            {
                neighbor = CreateCell(coordinate);
                CreatePassage(currCell, neighbor, direction);
                activeCells.Add(neighbor);
            }
            else if (currCell.room == neighbor.room)
            {
                CreatePassageInSameRoom(currCell, neighbor, direction);
            }
            else
            {
                CreateWall(currCell, neighbor, direction);
            }
        }
        else
        {
            CreateWall(currCell, null, direction);
        }
    }
Exemple #8
0
 public void Add(MuseumCell cell)
 {
     cell.room = this;
     cells.Add(cell);
 }