示例#1
0
 public Room(Corridor originCorridor, int roomSize, int prefabSize)
 {
     _originCorridorWaypoints = originCorridor.CorridorWaypoints;
     Vector3 origin = originCorridor.CorridorWaypoints.Last();
     _roomSize = roomSize;
     PrefabSize = prefabSize;
     AddToRoom(origin);
     BuildRoom();
 }
示例#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");
                }
            }
        }