예제 #1
0
파일: Maze.cs 프로젝트: kgobes/InclusioGame
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab;

        if (Random.value < eventProbability && eventCounter > 0)
        {
            //if(eventCounter > 0){
            eventCounter--;
            prefab = eventPrefab;
            MazePassage chal = Instantiate(prefab) as EventTrigger;
            chal.Initialize(cell, otherCell, direction);
            chal.GetComponent <EventTrigger>().SetChallengeManagerRef(challengeManagerInst);
            prefab = passagePrefab;
            chal   = Instantiate(prefab) as MazePassage;
            chal.Initialize(otherCell, cell, direction.GetOpposite());
        }
        else
        {
            prefab = passagePrefab;
            //MazePassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab;
            MazePassage passage = Instantiate(prefab) as MazePassage;
            passage.Initialize(cell, otherCell, direction);
            passage = Instantiate(prefab) as MazePassage;
            passage.Initialize(otherCell, cell, direction.GetOpposite());
        }
    }
예제 #2
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab = null;

        if (cell.room.cells.Count > maxRoomSize)
        {
            prefab = doorPrefab;
        }
        else
        {
            prefab = Random.value < doorProbability ? doorPrefab : passagePrefab;
        }
        MazePassage passage = Instantiate(prefab, this.transform) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab, this.transform) as MazePassage;
        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        else
        {
            otherCell.Initialize(cell.room);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #3
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        //Create objective every once in a while
        if (step % 80 == 0)
        {
            MazeObjective objective = Instantiate(objectivePrefab);
            Vector3       size      = objective.transform.localScale;
            objective.transform.parent        = cell.transform;
            objective.transform.localPosition = new Vector3(0, 0.5f, 0);
            objective.transform.localScale    = size;
            objective.name = "Objective";
            objectiveCount++;
        }

        //Create passages either in the form of archways or passages
        MazePassage prefab  = Random.value < archProb ? archPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;
        Vector3     scale   = passage.transform.localScale; //All passages have same scale

        passage.Initialize(cell, otherCell, direction);
        passage.transform.localScale = scale;

        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
        passage.transform.localScale = scale;

        step++;
    }
예제 #4
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab;
        //if(prefab == passagePrefab)
        //{
        //    prefab = Random.value < ennemyProbability ? ennemyPrefab : passagePrefab;
        //}

        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.transform.localScale = passage.transform.localScale * scale;

        passage.Initialize(cell, otherCell, direction);

        passage = Instantiate(prefab) as MazePassage;
        passage.transform.localScale = passage.transform.localScale * scale;
        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        else
        {
            otherCell.Initialize(cell.room);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #5
0
파일: Maze.cs 프로젝트: JLSaake/Night-Light
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
        if (Random.value < ghostProbabiliy && Ghost.GhostCountGet() < ghostMax && !AtSpawn(cell))
        {
            float temp = Random.Range(0, 3);
            if (temp >= 0 && temp < 1)
            {
                CreateGhost(ghostPrefabRed, cell);
            }
            else
            if (temp >= 1 && temp < 2)
            {
                CreateGhost(ghostPrefabBlue, cell);
            }
            else
            {
                CreateGhost(ghostPrefabGreen, cell);
            }
            Debug.Log("Ghosts: " + Ghost.GhostCountGet());
        }
        else
        if (Random.value < campfireProbability && campfireCount < campfireMax && !AtSpawn(cell))
        {
            CreateCampfire(cell);
            Debug.Log("Campfire" + campfireCount + " at " + cell.coordinates.x + ", " + cell.coordinates.z);
        }
    }
예제 #6
0
 private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
 {
     MazePassage passage = Instantiate(passagePrefab) as MazePassage;
     passage.Initialize(cell, otherCell, direction);
     passage = Instantiate(passagePrefab) as MazePassage;
     passage.Initialize(otherCell, cell, direction.GetOpposite());
 }
예제 #7
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab;

        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        Vector3 localScale = new Vector3(1, 1, 1);

        if (passage is MazeDoor)
        {
            passage.transform.localScale = localScale;
        }

        passage = Instantiate(prefab) as MazePassage;

        // create room different from the one of cell ...
        if (passage is MazeDoor)
        {
            passage.transform.localScale = localScale;
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        // or add next cell to same room
        else
        {
            otherCell.Initialize(cell.room);
        }

        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #8
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorProbability ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        //passage = Instantiate(prefab) as MazePassage;

        if (cell.room != otherCell.room && otherCell.room != null)
        {
            MazeRoom roomToAssimilate = otherCell.room;
            cell.room.Assimilate(roomToAssimilate);
            rooms.Remove(roomToAssimilate);
            Destroy(roomToAssimilate);
        }

        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        else
        {
            otherCell.Initialize(cell.room);
        }

        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #9
0
    void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction) //creates empty passage between two cells and initializes it for both sides
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #10
0
    /**
     * create instance of wall and passage
     */
    private void CreatePassage(MazeCell source, MazeCell sink, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(source, sink, direction);
        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(sink, source, direction.GetOpposite());
    }
예제 #11
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorPrebability ? doorprefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #12
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction, int type = 2)
    {
        MazePassage prefab  = type == 3 ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #13
0
파일: Maze.cs 프로젝트: AntonTsirov/Theseus
    private void CreatePassageInSameRoom(MazeCellv2 cell, MazeCellv2 otherCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
        if (cell.room != otherCell.room)
        {
        }
    }
예제 #14
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorProbability ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.transform.localScale = new Vector3(scale, scale, scale); //fit scale by teru
        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        passage.transform.localScale = new Vector3(scale, scale, scale); //fit sclae of oposite side by teru
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #15
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction, false);
        //NetworkServer.Spawn (passage.gameObject);

        passage = Instantiate(passagePrefab) as MazePassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite(), false);
        //NetworkServer.Spawn (passage.gameObject);
    }
예제 #16
0
 private void CreatePassageInSameRoom(MazeCell cell, MazeCell otherCell, MazeDirection direction)
 {
     MazePassage passage = Instantiate(passagePrefab) as MazePassage;
     passage.Initialize(cell, otherCell, direction);
     passage = Instantiate(passagePrefab) as MazePassage;
     passage.Initialize(otherCell, cell, direction.GetOpposite());
     if (cell.room != otherCell.room) {
         MazeRoom roomToAssimilate = otherCell.room;
         cell.room.Assimilate(roomToAssimilate);
         rooms.Remove(roomToAssimilate);
         Destroy(roomToAssimilate);
     }
 }
예제 #17
0
    private void CreatePassageInSameRoom(MazeCell parentCell, MazeCell neighbourCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab);

        passage.Initialize(parentCell, neighbourCell, direction);
        passage = Instantiate(passagePrefab);
        passage.Initialize(neighbourCell, parentCell, direction.GetOpposite());
        if (parentCell.room != neighbourCell.room)
        {
            parentCell.room.Assimilate(neighbourCell.room);
            rooms.Remove(neighbourCell.room);
            Destroy(neighbourCell.room);
        }
    }
예제 #18
0
    /// <summary>
    /// Simply instantiate their respective prefabs and initialize them, once for both cells.
    /// </summary>
    /// <param name="mazeCell">Current cell point.</param>
    /// <param name="otherMazeCell">Neighbour cell point.</param>
    /// <param name="mazeDirection">Direction of the passage.</param>
    private void CreatePassage(MazeCell mazeCell, MazeCell otherMazeCell, MazeDirection mazeDirection)
    {
        // Place a door or a passageway.
        MazePassage prefab  = Random.value < _mazeDoorProbability ? _mazeDoorPrefab : _mazePassagePrefab;
        MazePassage passage = Instantiate(prefab);

        passage.Initialize(mazeCell, otherMazeCell, mazeDirection);
        passage = Instantiate(prefab);

        // Check whether a door has been placed.
        // If so, the other cell is the first of a new room.
        // If not, it belongs to the same room as the previous cell.
        otherMazeCell.Initialize(passage is MazeDoor ? CreateRoom(mazeCell.Room.IndexOfSettings) : mazeCell.Room);

        passage.Initialize(otherMazeCell, mazeCell, mazeDirection.GetOpposite());
    }
예제 #19
0
    // create a passage bewteen two cells in the same room
    private void CreateSameRoomPassage(MazeCell firstCell, MazeCell secondCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(firstCell, secondCell, direction);
        //passage = Instantiate(passagePrefab) as MazePassage;
        //passage.Initialize(secondCell, firstCell, direction.GetOpposite());
    }
예제 #20
0
파일: Maze.cs 프로젝트: AntonTsirov/Theseus
    private void CreatePassage(MazeCellv2 cell, MazeCellv2 otherCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value <= doorProbability ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        else
        {
            otherCell.Initialize(cell.room);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #21
0
    void CreatePassage(MazeCell thisCell, MazeCell thatCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorProbabilty ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(thisCell, thatCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        if (passage is MazeDoor)
        {
            thatCell.Initialize(CreateRoom(thisCell.room.roomID));
        }
        else
        {
            thatCell.Initialize(thisCell.room);
        }
        passage.Initialize(thatCell, thisCell, direction.GetOposite());
    }
예제 #22
0
    private void CreatePassage(MazeCell parentCell, MazeCell neighbourCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorProbability ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab);

        passage.Initialize(parentCell, neighbourCell, direction);
        passage = Instantiate(prefab);
        if (passage is MazeDoor)
        {
            neighbourCell.Initialize(CreateRoom(parentCell.room.settingsIndex));
        }
        else
        {
            neighbourCell.Initialize(parentCell.room);
        }
        passage.Initialize(neighbourCell, parentCell, direction.GetOpposite());
    }
예제 #23
0
    void CreatePassageInSameRoom(MazeCell thisCell, MazeCell thatCell, MazeDirection direction)
    {
        MazePassage passage = Instantiate(passagePrefab) as MazePassage;

        passage.Initialize(thisCell, thatCell, direction);
        passage = Instantiate(passagePrefab) as MazePassage;
        thatCell.Initialize(thisCell.room);
    }
예제 #24
0
    /// <summary>
    /// Creates the passage.
    /// Passage has a Initialize on either side.
    /// </summary>
    /// <param name="currentCell">Current cell.</param>
    /// <param name="neighbor">Neighbor.</param>
    /// <param name="direction">Direction.</param>
    void CreatePassage(MazeCell currentCell, MazeCell neighbor, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < mDoorProbability ? mDoorPrefab : mPassgaePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(currentCell, neighbor, direction);
        passage = Instantiate(prefab) as MazePassage;
        if (passage is MazeDoor)
        {
            neighbor.Initialized(CreateRoom(currentCell.mRoom.mSettingsIndex));
            mRoomCreatedTest += 1;
        }
        else
        {
            neighbor.Initialized(currentCell.mRoom);
        }
        passage.Initialize(neighbor, currentCell, direction.GetOpposite());
    }
예제 #25
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        //Debug.Log("CreatePassage " + cell.name + ", " + otherCell.name + ", " + direction.ToString());
        MazePassage prefab  = (Random.value < doorProbability) ? doorPrefab : passagePrefab; // 0.1 = 10%
        MazePassage passage = Instantiate <MazePassage>(prefab);

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate <MazePassage>(prefab);   // is 2nd needed? if yes then set pos.z = 0.475

        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
        }
        else
        {
            otherCell.Initialize(cell.room);
        }

        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #26
0
    private void CreatePassageInSameRoom(
        MazeCell cell,
        MazeCell otherCell,
        MazeDirection direction)
    {
        MazePassage prefab = passagePrefab;

        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
    }
예제 #27
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        bool createDoor = randomGenerator.NextDouble() < DoorProbability;

        if (createDoor)
        {
            MazePassage door = Instantiate(DoorPrefab) as MazePassage;
            door.Initialize(cell, otherCell, direction);
            MazePassage passage = Instantiate(PassagePrefab);
            passage.Initialize(otherCell, cell, direction.GetOpposite());
            otherCell.Initialize(CreateRoom(cell.Room.settingsIndex));
        }
        else
        {
            MazePassage passage = Instantiate(PassagePrefab) as MazePassage;
            passage.Initialize(cell, otherCell, direction);
            passage = Instantiate(PassagePrefab) as MazePassage;
            otherCell.Initialize(cell.Room);
            passage.Initialize(otherCell, cell, direction.GetOpposite());
        }
    }
    //记录通道(两个cell之间相对位置)
    void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        MazePassage prefab  = Random.value < doorProbability ? doorPrefab : passagePrefab;
        MazePassage passage = Instantiate(prefab) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;

        if (passage is MazeDoor)
        {
            //以门为界限,创建room
            otherCell.Initialize(CreatRoom(cell.room.settingIndex));
        }
        else
        {
            //通道之间颜色相同
            otherCell.Initialize(cell.room);
        }

        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #29
0
    private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
    {
        bool createDecor = Random.value < cell.room.settings.decorProbability ? true : false;

        if (otherCell.coordinates.x == playerCoordinates.x && otherCell.coordinates.z == playerCoordinates.z)
        {
            createDecor = false;
        }

        MazePassage prefab  = Random.value < doorProbability ? doorPrefab[Random.Range(0, doorPrefab.Length)] : passagePrefab;
        MazePassage passage = Instantiate(prefab, cell.transform.position, direction.ToRotation()) as MazePassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(prefab) as MazePassage;
        if (passage is MazeDoor)
        {
            otherCell.Initialize(CreateRoom(cell.room.settingsIndex), false, useShaderMaterials);
        }
        else
        {
            otherCell.Initialize(cell.room, createDecor, useShaderMaterials);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
예제 #30
0
    /// <summary>
    /// Creates a passage between two cells, with no chance of a door.
    /// </summary>
    /// <param name="mazeCell">Current cell point.</param>
    /// <param name="otherMazeCell">Neighbour cell point.</param>
    /// <param name="direction">Direction of the passage.</param>
    private void CreatePassageInSameRoom(MazeCell mazeCell, MazeCell otherMazeCell, MazeDirection direction)
    {
        // Declare variables.
        MazePassage passage = Instantiate(_mazePassagePrefab);

        // Initializing.
        passage.Initialize(mazeCell, otherMazeCell, direction);
        passage = Instantiate(_mazePassagePrefab);
        passage.Initialize(otherMazeCell, mazeCell, direction.GetOpposite());

        // Then we have Maze check whether it's connecting different rooms, in which case it assimilates and removes the
        // other room.
        if (mazeCell.Room == otherMazeCell.Room)
        {
            return;
        }

        MazeRoom roomToAssimilate = otherMazeCell.Room;

        mazeCell.Room.Assimilate(roomToAssimilate);
        _rooms.Remove(roomToAssimilate);

        Destroy(roomToAssimilate);
    }