public void CreateRoom(Multiplayer.RoomButton button)
        {
            if (isMultiplayer.value)
            {
                if (!isConnected.value)
                {
                    // TODO: add logic for when not connected
                }
                else
                {
                    RoomOptions roomOptions = new RoomOptions()
                    {
                        MaxPlayers = 5,
                        CustomRoomPropertiesForLobby = new string[] { "scene" },
                        CustomRoomProperties         = new ExitGames.Client.Photon.Hashtable {
                            { "scene", button.sceneName }
                        }
                    };

                    PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default);
                }
            }
            else // single player
            {
                Multiplayer.Room room = ScriptableObject.CreateInstance <Multiplayer.Room> ();
                room.sceneName = button.sceneName;
                GameManagers.GetResourcesManager().currentRoom.SetRoom(room);
            }

            isInGame = true;
        }
Exemple #2
0
        public void AddMatch(RoomInfo roomInfo)
        {
            GameObject matchPrefabClone = Instantiate(matchPrefab);

            matchPrefabClone.transform.SetParent(matchesParent);

            MatchSpawnPosition randomSpawnPosition = GetSpawnPosition();

            randomSpawnPosition.isUsed            = true;
            matchPrefabClone.transform.position   = randomSpawnPosition.transform.position;
            matchPrefabClone.transform.localScale = Vector3.one;

            RoomButton roomButton = matchPrefabClone.GetComponent <RoomButton> ();

            roomButton.roomInfo      = roomInfo;
            roomButton.isRoomCreated = true;
            roomButton.isValid       = true;

            object sceneObject;

            roomInfo.CustomProperties.TryGetValue("scene", out sceneObject);

            roomButton.room           = ScriptableObject.CreateInstance <Room> ();
            roomButton.room.sceneName = (string)sceneObject;
            roomButton.room.roomName  = roomInfo.Name;

            roomsDictionary.Add(roomInfo.Name, roomButton);
        }
Exemple #3
0
        private RoomButton GetRoomFromDictionary(string key)
        {
            RoomButton result = null;

            roomsDictionary.TryGetValue(key, out result);
            return(result);
        }
 public void SetRoom(RoomButton roomButton)
 {
     if (roomButton.isRoomCreated)
     {
         SetRoom(roomButton.room);
         Managers.MultiplayerLauncher.Singleton.JoinRoom(roomButton.roomInfo);
     }
     else
     {
         Managers.MultiplayerLauncher.Singleton.CreateRoom(roomButton);
     }
 }
Exemple #5
0
        public void AddMatches(RoomInfo[] rooms)
        {
            SetDirtyRooms();
            foreach (RoomInfo roomInfo in rooms)
            {
                RoomButton createdRoom = GetRoomFromDictionary(roomInfo.Name);
                if (createdRoom == null)
                {
                    AddMatch(roomInfo);
                }
                else
                {
                    createdRoom.isValid = true;
                }
            }

            ClearNonValidRooms();
        }
 public void SetRoomButton(RoomButton button)
 {
     roomButtonVariable.value = button;
 }