Exemplo n.º 1
0
 /// <summary>
 /// Called when we successfully created a room.
 /// </summary>
 public override void OnCreatedRoom()
 {
     base.OnCreatedRoom();
     if (PhotonNetwork.isMasterClient && (m_MapIndexWhenCreateRoom >= 0 && m_MapIndexWhenCreateRoom <= GameMapManager.GetMapCount))
     {
         PhotonNetwork.LoadLevel(GameMapManager.GetGameMap(m_MapIndexWhenCreateRoom).GameMapSceneIndex);
         m_MapIndexWhenCreateRoom = -1;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all the necessary data that is needed to load the next round or map.
        /// </summary>
        public void LoadNextRound()
        {
            // Only the master client can reload the scene
            if (PhotonNetwork.isMasterClient)
            {
                Room      currentRoom     = PhotonNetwork.room;
                HashTable resetProperties = new HashTable();
                // Game mode keep it as it is.
                resetProperties.Add(RoomProperties.GameModeIndex, (int)currentRoom.customProperties[RoomProperties.GameModeIndex]);
                // Reset the round start time.
                resetProperties.Add(RoomProperties.RoundStartTime, PhotonNetwork.time);
                // Round time limit won't change
                resetProperties.Add(RoomProperties.RoundTimeLimit, (int)currentRoom.customProperties[RoomProperties.RoundTimeLimit]);
                // Reset both TeamA's and TeamB's score.
                resetProperties.Add(RoomProperties.TeamAScore, 0);
                resetProperties.Add(RoomProperties.TeamBScore, 0);
                // The room name of cause is the same.
                resetProperties.Add(RoomProperties.RoomName, (string)currentRoom.customProperties[RoomProperties.RoomName]);
                // The mapIndex is the same.

                int nextMap = (int)currentRoom.customProperties[RoomProperties.MapIndex] + 1;
                if (nextMap >= GameMapManager.GetMapCount)
                {
                    nextMap = 0;
                }

                resetProperties.Add(RoomProperties.MapIndex, nextMap);
                // The room create data won't change.
                resetProperties.Add(RoomProperties.RoomCreateDate, (double)currentRoom.customProperties[RoomProperties.RoomCreateDate]);

                resetProperties.Add(RoomProperties.HealthLimit, (int)currentRoom.customProperties[RoomProperties.HealthLimit]);

                // Reset these information in the rooms custom properties
                currentRoom.SetCustomProperties(resetProperties);

                // Reload the next round scene
                // PhotonNetwork.LoadLevel(SceneManager.GetActiveScene().buildIndex);
                PhotonNetwork.LoadLevel(GameMapManager.GetGameMap(nextMap).GameMapSceneIndex);
            }
        }