private void updateExitOrientations(int numberOfRotations)
 {
     for (int i = 0; i < exits.Length; i++)
     {
         ExplorableSectionExit currentExit = exits[i].GetComponent <ExplorableSectionExit>();
         currentExit.ExitOrientation = getNewDirectionFromRotations(numberOfRotations, currentExit.ExitOrientation);
     }
 }
    private void rotateToAttach(GameObject exitToAttachTo, GameObject thisSectionExit)
    {
        ExplorableSectionExit toAttachExit = exitToAttachTo.GetComponent <ExplorableSectionExit>();
        ExplorableSectionExit ownedExit    = thisSectionExit.GetComponent <ExplorableSectionExit>();

        ExplorableSectionExit.ExitDirection directionToRotateTo = getDirectionOpposite(toAttachExit.ExitOrientation);
        int numberOfRotations = getNumberOfRotationsRequired(ownedExit.ExitOrientation, directionToRotateTo);

        transform.Rotate(0, 0, numberOfRotations * 90);
        updateExitOrientations(numberOfRotations);
    }
Пример #3
0
 void Awake()
 {
     createdRooms = new List <GameObject>();
     CreateRoomBuildingPool();
     startingRoom = Instantiate(startingRoomPrefab, transform.position, Quaternion.identity);
     ExplorableSectionExit.ExitDirection startingPlayerExit = ExplorableSectionExit.ExitDirection.west;
     GameObject[] startingRoomExits = startingRoom.GetComponent <ExplorableSection>().Exits;
     for (int i = 0; i < startingRoomExits.Length; i++)
     {
         ExplorableSectionExit startingRoomExit = startingRoomExits[i].GetComponent <ExplorableSectionExit>();
         if (startingRoomExit.ExitOrientation == startingPlayerExit)
         {
             playerStartPoint = startingRoomExits[i];
         }
     }
 }
Пример #4
0
    public List <GameObject> BuildRooms()
    {
        // playerStartPoint is the side of the room that the player starts in, currently it should only support
        // east or west (as that is what the hallway is by default). Later this should be changed to allow the starting
        // room type to be rotated as the game call for it
        ExplorableSection currentRoomExplorable = startingRoom.GetComponent <ExplorableSection>();
        List <GameObject> pendingExits          = new List <GameObject>();

        for (int i = 0; i < currentRoomExplorable.Exits.Length; i++)
        {
            if (currentRoomExplorable.Exits[i] != playerStartPoint)
            {
                pendingExits.Add(currentRoomExplorable.Exits[i]);
            }
        }

        createdRooms.Add(startingRoom);

        for (int i = 0; i < buildIterations; i++)
        {
            List <GameObject> newExits = new List <GameObject>();
            for (int j = 0; j < pendingExits.Count; j++)
            {
                ExplorableSectionExit      sectionExit    = pendingExits[j].GetComponent <ExplorableSectionExit>();
                ExplorableSection.RoomType connectingType = sectionExit.ConnectableRoomTypes[Random.Range(0, sectionExit.ConnectableRoomTypes.Length)];
                currentRoomExplorable = PlaceRoom(connectingType, pendingExits[j]);
                if (currentRoomExplorable != null)
                {
                    for (int k = 0; k < currentRoomExplorable.Exits.Length; k++)
                    {
                        if (currentRoomExplorable.RoomAttachedExitLocation != currentRoomExplorable.Exits[k])
                        {
                            newExits.Add(currentRoomExplorable.Exits[k]);
                        }
                    }
                }
            }
            pendingExits = newExits;
        }
        RemoveRoomBuildingPool();
        return(createdRooms);
    }