예제 #1
0
    IEnumerator UpdateSessionInfo()
    {
        while (true)
        {
            IProtocolToken token = null;

            switch (Random.Range(1, 3))
            {
            case 1:
                token = new RoomProtocolToken()
                {
                    ArbitraryData = string.Format("My DATA :: {0}", Random.Range(1, 100)),
                    password      = "******"
                };

                break;

            case 2:
                token = new PhotonRoomProperties();

                ((PhotonRoomProperties)token).AddRoomProperty("t", Random.Range(1, 100));
                ((PhotonRoomProperties)token).AddRoomProperty("m", Random.Range(1, 100));

                break;
            }

            if (token != null)
            {
                BoltNetwork.SetServerInfo(null, token);
            }

            yield return(new WaitForSeconds(30));
        }
    }
예제 #2
0
    public override void BoltStartDone()
    {
        //bool headless = IsHeadlessMode();
        //if (headless == true || StartEvenIfNotHeadless == true)
        //{
        if (BoltNetwork.IsServer)
        {
            BoltNetwork.SetServerInfo(myID, null);

            string SceneName = "game";
            if (SceneToLoad == "CubeWorld")
            {
                SceneName = "game";
            }
            else if (SceneToLoad == "SphereWorld")
            {
                SceneName = "game2";
            }

            BoltNetwork.LoadScene(SceneName);
        }
        else
        {
        }
    }
예제 #3
0
        public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
        {
            if (BoltNetwork.IsServer)
            {
                if (full == false)
                {
                    full = true;

                    PhotonRoomProperties roomProperties = new PhotonRoomProperties
                    {
                        IsOpen    = false,
                        IsVisible = true
                    };

                    var matchName = Guid.NewGuid().ToString();

                    BoltNetwork.SetServerInfo(matchName, roomProperties);
                    BoltNetwork.Accept(endpoint);

                    Debug.Log("Accept Client");
                }
                else
                {
                    BoltNetwork.Refuse(endpoint);

                    Debug.Log("Refuse Client");
                }
            }
        }
예제 #4
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.isServer)
        {
            // Create some room custom properties
            PhotonRoomProperties roomProperties = new PhotonRoomProperties();

            roomProperties.AddRoomProperty("t", GameType); // ex: game type
            roomProperties.AddRoomProperty("m", Map);      // ex: map id

            roomProperties.IsOpen    = true;
            roomProperties.IsVisible = true;

            // If RoomID was not set, create a random one
            if (RoomID.Length == 0)
            {
                RoomID = new Guid().ToString();
            }

            // Create the Photon Room
            BoltNetwork.SetServerInfo(RoomID, roomProperties);

            // Load the requested Level
            BoltNetwork.LoadScene(Map);
        }
    }
예제 #5
0
        public override void BoltStartDone()
        {
            if (!BoltNetwork.isRunning)
            {
                return;
            }

            if (BoltNetwork.isServer)
            {
                RoomProtocolToken token = new RoomProtocolToken()
                {
                    ArbitraryData = "My DATA",
                };

                BoltLog.Info("Starting Server");
                // Start Photon Room
                BoltNetwork.SetServerInfo(_matchName, token);

                // Setup Host
                infoPanel.gameObject.SetActive(false);
                ChangeTo(lobbyPanel);

                backDelegate = Stop;
                SetServerInfo("Host", "");

                // Build Server Entity
                //BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);
                //entity.TakeControl();
            }
            else if (BoltNetwork.isClient)
            {
                backDelegate = Stop;
                SetServerInfo("Client", "");
            }
        }
예제 #6
0
    public override void ConnectRequest(UdpEndPoint endpoint, IProtocolToken token)
    {
        if (BoltNetwork.IsServer)
        {
            if (full == false)
            {
                full = true;
                PhotonRoomProperties myToken = new PhotonRoomProperties
                {
                    IsOpen    = false,
                    IsVisible = false,
                };

                myToken.AddRoomProperty("t", 3);

                var matchName = staticData.lobbyName;

                BoltNetwork.SetServerInfo(matchName, myToken);

                BoltNetwork.Accept(endpoint);
            }
            else
            {
                BoltNetwork.Refuse(endpoint);
            }
        }
    }
예제 #7
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         BoltNetwork.SetServerInfo("Test", null);
         BoltNetwork.LoadScene("Clash");
     }
 }
예제 #8
0
 //Create Host Game Room
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         string matchName = "Test Match";
         BoltNetwork.SetServerInfo(matchName, null);
         BoltNetwork.LoadScene("SampleScene");
     }
 }
예제 #9
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            string matchName = "Test Realm";

            BoltNetwork.SetServerInfo(matchName, null);
            BoltNetwork.LoadScene("Tutorial1");
        }
    }
예제 #10
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.isServer)
        {
            string matchName = Guid.NewGuid().ToString();

            BoltNetwork.SetServerInfo(matchName, null);
            BoltNetwork.LoadScene("GettingStarted");
        }
    }
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            string matchName = Guid.NewGuid().ToString();

            BoltNetwork.SetServerInfo(matchName, null);
            // lets load the level here, with the name of the level
            BoltNetwork.LoadScene("2019_MultiplayerTestLevel");
        }
    }
        public override void BoltStartDone()
        {
            if (BoltNetwork.isServer)
            {
                var id        = Guid.NewGuid().ToString().Split('-')[0];
                var matchName = string.Format("{0} - {1}", id, map);

                BoltNetwork.SetServerInfo(matchName, null);
                BoltNetwork.LoadScene(map);
            }
        }
예제 #13
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            var id            = Guid.NewGuid().ToString().Split('-')[0];
            var nombrePartida = string.Format("{0} - {1}", id, juegoActivo);

            BoltNetwork.SetServerInfo(nombrePartida, null);
            BoltNetwork.LoadScene(juegoActivo);
        }
    }
 public override void BoltStartDone()
 {
     //bool headless = IsHeadlessMode();
     //if (headless == true || StartEvenIfNotHeadless == true)
     //{
     if (BoltNetwork.IsServer)
     {
         BoltNetwork.SetServerInfo("MyGameLiftGame", null);
         BoltNetwork.LoadScene("game");
     }
     else
     {
     }
 }
예제 #15
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            if (BoltNetwork.IsServer)
            {
                int    randomInt = UnityEngine.Random.Range(0, 9999);
                string matchName = "Test Match" + randomInt;

                BoltNetwork.SetServerInfo(matchName, null);
                BoltNetwork.LoadScene("MainScene");
            }
        }
    }
예제 #16
0
        public override void BoltStartDone()
        {
            if (BoltNetwork.IsServer)
            {
                PhotonRoomProperties token = new PhotonRoomProperties();
                token.IsOpen    = true;
                token.IsVisible = true;

                var matchName = Guid.NewGuid().ToString();

                BoltNetwork.SetServerInfo(matchName, token);
                BoltNetwork.LoadScene("Game");
            }
        }
예제 #17
0
    public static void SetLobbyData(LobbyData lobbyData)
    {
        if (BoltNetwork.IsRunning && BoltNetwork.IsServer)
        {
            BoltNetwork.RegisterTokenClass <LobbyToken>();

            LobbyToken token = new LobbyToken().BuildData(lobbyData);
            BoltNetwork.SetServerInfo(lobbyData.ServerName, token);
            Debug.Log("Lobby data set.");
        }
        else
        {
            Debug.LogWarning("Can't set data if Bolt is not running.");
        }
    }
예제 #18
0
        public override void Disconnected(BoltConnection connection)
        {
            if (full == true)
            {
                full = false;

                PhotonRoomProperties roomProperties = new PhotonRoomProperties
                {
                    IsOpen = true, IsVisible = true
                };

                var matchName = Guid.NewGuid().ToString();

                BoltNetwork.SetServerInfo(matchName, roomProperties);
            }
        }
예제 #19
0
        public override void BoltStartDone()
        {
            BoltConsole.Write("BoltStartDone breh");
            if (!BoltNetwork.IsRunning)
            {
                return;
            }

            if (BoltNetwork.IsServer)
            {
                RoomProtocolToken token = new RoomProtocolToken()
                {
                    ArbitraryData = "My DATA",
                };

                BoltLog.Info("Starting Server");
                // Start Photon Room
                BoltNetwork.SetServerInfo(_matchName, token);
                //BoltNetwork.EnableLanBroadcast();
                // Setup Host
                infoPanel.gameObject.SetActive(false);
                //PanelHolder.instance.hideConnectingPanel();
                ChangeTo(lobbyPanel);

                backDelegate = Stop;
                SetServerInfo("Host", "");
                connection_spellcaster = new Dictionary <string, int>();
                //SoundManager.instance.musicSource.Play();

                // Build Server Entity

                characterSelection = BoltNetwork.Instantiate(BoltPrefabs.CharacterSelectionEntity);
                characterSelection.TakeControl();

                gameStateEntity = BoltNetwork.Instantiate(BoltPrefabs.GameState);
                gameStateEntity.TakeControl();
                gameStateEntity.GetComponent <NetworkGameState>().onCreateRoom(_matchName);

                numPlayersInfo.text = gameStateEntity.GetComponent <NetworkGameState>().onPlayerJoined() + "";
            }
            else if (BoltNetwork.IsClient)
            {
                backDelegate = Stop;
                SetServerInfo("Client", "");
            }
        }
예제 #20
0
        public override void BoltStartDone()
        {
            if (BoltNetwork.IsServer)
            {
                string roomName = Guid.NewGuid().ToString();

                // Set up the Photon Cloud Room on Photons servers, expecting
                // new peers connect to this room and join the game.
                BoltNetwork.SetServerInfo(roomName, null);

                // Load the main scene.
                // We only want to load this on the server right now (i.e. running the game).
                BoltNetwork.LoadScene("Main");
            }

            if (BoltNetwork.IsSinglePlayer)
            {
                // Load the main scene.
                BoltNetwork.LoadScene("Main");
            }
        }
예제 #21
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            PhotonRoomProperties token = new PhotonRoomProperties();
            token.IsOpen    = true;
            token.IsVisible = true;

            if (blueTeam == true)
            {
                token.AddRoomProperty("t", 1);
            }

            if (redTeam == true)
            {
                token.AddRoomProperty("t", 2);
            }
            staticData.lobbyName = Guid.NewGuid().ToString();
            var matchName = staticData.lobbyName;

            BoltNetwork.SetServerInfo(matchName, token);
            BoltNetwork.LoadScene("game");
        }
    }
예제 #22
0
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

            switch (_state)
            {
            // starting Bolt is the same regardless of the transport layer
            case State.SelectMode:
                if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartServer();
                    _state = State.ModeServer;
                }

                if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartClient();
                    _state = State.ModeClient;
                }

                break;

            // Publishing a session into the matchmaking server
            case State.ModeServer:
                if (BoltNetwork.isRunning && BoltNetwork.isServer)
                {
                    if (GUILayout.Button("Publish HostInfo And Load Map", GUILayout.ExpandWidth(true)))
                    {
                        // Normal Token
                        //RoomProtocolToken token = new RoomProtocolToken()
                        //{
                        //    ArbitraryData = "My DATA",
                        //    password = "******"
                        //};

                        // Use to pass custom properties to your room
                        PhotonRoomProperties roomProperties = new PhotonRoomProperties();

                        roomProperties.AddRoomProperty("t", 1);     // ex: game type
                        roomProperties.AddRoomProperty("m", 4);     // ex: map id

                        roomProperties.IsOpen    = true;
                        roomProperties.IsVisible = true;

                        string matchName = "MyPhotonGame #" + UnityEngine.Random.Range(1, 100);

                        BoltNetwork.SetServerInfo(matchName, roomProperties);
                        BoltNetwork.LoadScene("Level1");
                    }
                }
                break;

            // for the client, after Bolt is innitialized, we should see the list
            // of available sessions and join one of them
            case State.ModeClient:

                if (BoltNetwork.isRunning && BoltNetwork.isClient)
                {
                    GUILayout.Label("Session List");

                    var oldList = (from item in internalSessionList
                                   where (DateTime.Now - item.Value.receivedAt).TotalSeconds > SessionTimeout
                                   select item);

                    foreach (var item in oldList)
                    {
                        internalSessionList.Remove(item.Key);
                    }

                    ShowSessionList(internalSessionList);
                }
                break;
            }

            GUILayout.EndArea();
        }
예제 #23
0
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

            switch (_state)
            {
            // starting Bolt is the same regardless of the transport layer
            case State.SelectMode:
                if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartServer();
                    _state = State.ModeServer;
                }

                if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartClient();
                    _state = State.ModeClient;
                }

                break;

            // Publishing a session into the matchmaking server
            case State.ModeServer:
                if (BoltNetwork.IsRunning && BoltNetwork.IsServer)
                {
                    if (GUILayout.Button("Publish HostInfo And Load Map", GUILayout.ExpandWidth(true)))
                    {
                        RoomProtocolToken token = new RoomProtocolToken()
                        {
                            ArbitraryData = "My DATA",
                            password      = "******"
                        };

                        // Uncomment if you want to pass custom properties into your room
                        // This is just an example data
                        //PhotonCloudRoomProperties token = new PhotonCloudRoomProperties();
                        //properties.AddRoomProperty("t", 1);
                        //properties.AddRoomProperty("m", 4);

                        string matchName = "MyPhotonGame #" + UnityEngine.Random.Range(1, 100);

                        BoltNetwork.SetServerInfo(matchName, token);
                        BoltNetwork.LoadScene("Level1");
                    }
                }
                break;

            // for the client, after Bolt is innitialized, we should see the list
            // of available sessions and join one of them
            case State.ModeClient:

                if (BoltNetwork.IsRunning && BoltNetwork.IsClient)
                {
                    GUILayout.Label("Session List");

                    foreach (var session in BoltNetwork.SessionList)
                    {
                        // Simple session
                        UdpSession udpSession = session.Value as UdpSession;

                        // Skip if is not a Photon session
                        if (udpSession.Source != UdpSessionSource.Photon)
                        {
                            continue;
                        }

                        // Photon Session
                        PhotonSession photonSession = udpSession as PhotonSession;

                        string sessionDescription = String.Format("{0} / {1} ({2})",
                                                                  photonSession.Source, photonSession.HostName, photonSession.Id);

                        RoomProtocolToken token = photonSession.GetProtocolToken() as RoomProtocolToken;

                        if (token != null)
                        {
                            sessionDescription += String.Format(" :: {0}", token.ArbitraryData);
                        }
                        else
                        {
                            object value_t = -1;
                            object value_m = -1;

                            if (photonSession.Properties.ContainsKey("t"))
                            {
                                value_t = photonSession.Properties["t"];
                            }

                            if (photonSession.Properties.ContainsKey("m"))
                            {
                                value_t = photonSession.Properties["m"];
                            }

                            sessionDescription += String.Format(" :: {0}/{1}", value_t, value_m);
                        }

                        if (GUILayout.Button(sessionDescription, GUILayout.ExpandWidth(true)))
                        {
                            ServerConnectToken connectToken = new ServerConnectToken
                            {
                                data = "ConnectTokenData"
                            };

                            BoltNetwork.Connect(photonSession, connectToken);
                        }
                    }
                }
                break;
            }

            GUILayout.EndArea();
        }