VirtualRoom IdentifyRoom() { VirtualRoomBehavior[] vRoomBhvrs = FindObjectsOfType <VirtualRoomBehavior>(); foreach (VirtualRoomBehavior v in vRoomBhvrs) { virtualRooms.Add(v.room); } GenerateFootprints(); physicalRoom = new PhysicalRoom(MeshAnalyzer.Instance.roomDimensions, MeshAnalyzer.Instance.roomCorners); physicalRoom.GenerateFootprint(); // compare footprints List <KeyValuePair <VirtualRoom, float> > roomDiffList = new List <KeyValuePair <VirtualRoom, float> >(); foreach (VirtualRoom vr in virtualRooms) { roomDiffList.Add(new KeyValuePair <VirtualRoom, float>( vr, physicalRoom.CalculateDifference(vr))); } roomDiffList.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value)); if (roomDiffList[0].Value == float.MaxValue) { ScanProgress.Instance.tts.StartSpeaking("Error. Room not identified."); throw new Exception("Could not identify room."); } return(roomDiffList[0].Key); }
private void SpawnRoom(Direction dir) { if (currentRoomPrefab != null) { Destroy(currentRoomPrefab); } currentRoom = GetRandomRoom(dir); mainCamera.transform.position = currentRoom.cameraPosition; mainCamera.transform.eulerAngles = currentRoom.cameraRotation; currentRoomPrefab = Instantiate(currentRoom.gameObject); Compass.ChangeDirection(currentRoom.whatIsNorth); }