예제 #1
0
 public Corridor(Room room, int size)
 {
     _room = room;
     _prefabSize = room.PrefabSize;
     _corridorLength = size;
     GetCorridorStart();
     BuildCorridor();
     _room.RemoveCorridorWaypoints(CorridorWaypoints);
 }
예제 #2
0
        private void CreateRoomCorridors(int levelSize)
        {
            Rooms = new Room[levelSize];
            Corridors = new Corridor[levelSize - 1];

            var roomSize = Random.Range(minRoomSize, maxRoomSize);

            Rooms[0] = new Room(Vector3.zero, roomSize, PrefabSize);
            Corridors[0] = new Corridor(Rooms[0], roomSize - 1);
            Debug.Log("Build First Room And Corridor");

            try
            {
                for (var i = 1; i < levelSize; i++)
                {
                    roomSize = Random.Range(minRoomSize, maxRoomSize);
                    Rooms[i] = new Room(Corridors[i - 1], roomSize, PrefabSize);
                    Debug.Log("Build " + i + " Room");
                    if (i < levelSize - 1)
                    {
                        Corridors[i] = new Corridor(Rooms[i], roomSize - 1);
                        Debug.Log("Build " + i + " Corridor");
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                throw;
            }

            foreach (Room room in Rooms)
            {
                if (room==null)
                {
                    Debug.Log("missing room");
                }
            }

            foreach (var corr in Corridors)
            {
                if (corr==null)
                {
                    Debug.Log("missing corridor");
                }
            }
        }