Example #1
0
 /// <summary>
 /// Callback when player joins a room. If player is host it starts mapping.
 /// If the player is not the host it updates on screen text according to what state
 /// the room is in. Then it updates the UI with PrepareGame().
 /// </summary>
 override public void OnJoinedRoom()
 {
     SetNetState(NetGameStateId.ConnectedInRoom,
                 (PhotonNetwork.room == null ? "null" : PhotonNetwork.room.Name));
     Debug.Log("------------------------------    OnJoinedRoom:" +
               (PhotonNetwork.room == null ? "null" : PhotonNetwork.room.Name)
               + "------------------------------------------------");
     if (IsHost)
     {
         // Change room status to mapping
         CurrRoomStatus = RoomStatus.Mapping;
         MainMenuUI.LoadingCircle.SetActive(false);  // TODO turn this into a callback in MainMenuUIController
         GameSetup.EnvironmentMappingStart();
         TotalLocalizedPlayers = 0;
     }
     else
     {
         if (PhotonNetwork.room.CustomProperties["MapId"] != null)
         {
             EnvironmentScannerController.Instance.SetLatestMapId(PhotonNetwork.room.CustomProperties["MapId"].ToString());
         }
         if (CurrRoomStatus == RoomStatus.Mapping)
         {
             GameUI.HelperText.text = "Wait while host maps the area!";
         }
         else if (CurrRoomStatus == RoomStatus.Localizing)
         {
             GameUI.HelperText.text = "Move and look to where the map was created to localize.";
             // Load the map
             GameSetup.StartLoadingMap();
         }
         else if (CurrRoomStatus == RoomStatus.Playing)
         {
             GameUI.HelperText.text = "The game has started. You need to localize before you can play!";
             // Load the map
             GameSetup.StartLoadingMap();
         }
         GameController.PrepareGame();
     }
 }