Example #1
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
        {
        }
    }
Example #2
0
    public void GameEnd()
    {
        // end game time

        // disconnect clients here
        foreach (var conn in BoltNetwork.connections)
        {
            // create EndGameToken
            EndGameToken endGametoken = new EndGameToken();
            // give it reason: game end
            endGametoken.EndGameReason = "Dis game done, son";

            // figure out who won the game, send that result in a parseable format
            endGametoken.Won = true;
            //conn.DisconnectToken = endGametoken;
            conn.Disconnect(endGametoken);
        }

        // set core gui manager end game state; also, did the server player win the game?
        CoreGUIManager.Instance.SetEndGame(true);

        GameGUIManager.Instance.BoltUnloadGameScene();

        BoltLauncher.Shutdown();

        BoltNetwork.LoadScene(GameManager.Instance.MenuSceneName);
    }
Example #3
0
    public override void BoltStartDone()
    {
        if (SteamHub.LobbyActive != null && SteamManager.Initialized)
        {
            BoltNetwork.RegisterTokenClass <SteamToken>();

            Debug.Log("enteredGame");
            string enterMessage    = "enteredGame" + SteamUser.GetSteamID();
            byte[] enterMsgAsBytes = Encoding.ASCII.GetBytes(enterMessage);
            SteamMatchmaking.SendLobbyChatMsg(SteamHub.LobbyActive.LobbyId, enterMsgAsBytes, enterMsgAsBytes.Length + 1);

            if (GameObject.Find("Main Camera").GetComponent <SteamLobby>().isOwner())
            {
                BoltNetwork.LoadScene(LocalData.ServerScene);
            }
            else
            {
#if !BOLT_CLOUD
                var token = new SteamToken();
                Debug.Log(SteamUser.GetSteamID().m_SteamID);
                token.SteamID = SteamUser.GetSteamID().m_SteamID;
                CSteamID serverID = GameObject.Find("Main Camera").GetComponent <SteamLobby>().getGameServerID();
                BoltNetwork.Connect(serverID.ToEndPoint(), token);
#else
                Debug.LogError("This call is only valid on Bolt Server version");
#endif
            }
        }
    }
Example #4
0
        public IEnumerator ServerCountdownCoroutine()
        {
            float remainingTime = prematchCountdown;
            int   floorTime     = Mathf.FloorToInt(remainingTime);

            LobbyCountdown countdown;

            while (remainingTime > 0)
            {
                yield return(null);

                remainingTime -= Time.deltaTime;
                int newFloorTime = Mathf.FloorToInt(remainingTime);

                if (newFloorTime != floorTime)
                {
                    floorTime = newFloorTime;

                    countdown      = LobbyCountdown.Create(GlobalTargets.Everyone);
                    countdown.Time = floorTime;
                    countdown.Send();
                }
            }

            countdown      = LobbyCountdown.Create(GlobalTargets.Everyone);
            countdown.Time = 0;
            countdown.Send();

            BoltNetwork.LoadScene(gameScene.SimpleSceneName);
        }
Example #5
0
 public static void LoadLevelWithKey(string loadKey)
 {
     if (BoltNetwork.isRunning)
     {
         if (BoltNetwork.isServer)
         {
             LevelInfo levelInfo;
             if (!Instance.LevelLoadMap.TryGetValue(loadKey, out levelInfo))
             {
                 Debug.LogError($"[WordLevelLayout]: Provided LevelKey not found. ({loadKey})");
                 return;
             }
             Instance.OnLoadingStarted?.Raise();
             if (levelInfo.LoadingPrefab != null)
             {
                 var loadingGO = Instantiate(levelInfo.LoadingPrefab);
                 DontDestroyOnLoad(loadingGO);
                 //levelInfo.LoadingPrefab.StartCoroutine ();
             }
             BoltNetwork.LoadScene(levelInfo.Name);
             Instance.OnLevelLoaded?.Raise();
         }
     }
     else
     {
         Debug.Log("[WordLevelLayout]: Non-Network Scene loading not implemented.");
     }
 }
Example #6
0
        public IEnumerator ServerCountdownCoroutine()
        {
            float remainingTime = 4f;//prematchCountdown;
            int   floorTime     = Mathf.FloorToInt(remainingTime);

            LobbyCountdown countdown;

            ChangeTo(countdownPanel.GetComponent <RectTransform>());
            while (remainingTime > 0)
            {
                yield return(null);

                remainingTime -= Time.deltaTime;
                int newFloorTime = Mathf.FloorToInt(remainingTime);

                if (newFloorTime != floorTime)
                {
                    floorTime = newFloorTime;

                    countdown      = LobbyCountdown.Create(GlobalTargets.Everyone);
                    countdown.Time = floorTime;
                    countdown.Send();
                }
            }

            countdown      = LobbyCountdown.Create(GlobalTargets.Everyone);
            countdown.Time = 0;
            countdown.Send();

            BoltNetwork.LoadScene(gameScene.SimpleSceneName);
            LoadHandler.instance.sceneBuildIndex = LoadHandler.instance.mainSceneIndex;
        }
Example #7
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);
        }
    }
Example #8
0
        public override void BoltStartDone()
        {
            if (BoltNetwork.IsSinglePlayer)
            {
                BoltNetwork.LoadScene("Tutorial1_Game");
            }

            if (BoltNetwork.IsServer)
            {
                string matchName = Guid.NewGuid().ToString();

                var props = new PhotonRoomProperties();

                props.IsOpen    = true;
                props.IsVisible = true;

                props["type"] = "game01";
                props["map"]  = "Tutorial1";

                BoltMatchmaking.CreateSession(
                    sessionID: matchName,
                    sceneToLoad: "Tutorial1_Game",
                    token: props
                    );
            }

            if (BoltNetwork.IsClient)
            {
                // This will start a server after 10secs of wait
                // if no server was found
                _timerRoutine = StartCoroutine(ShutdownAndStartServer());
            }
        }
Example #9
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         BoltNetwork.SetServerInfo("Test", null);
         BoltNetwork.LoadScene("Clash");
     }
 }
Example #10
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         BoltMatchmaking.CreateSession(serverName);
         BoltNetwork.LoadScene("DisCo-Scene");
     }
 }
Example #11
0
 //Create Host Game Room
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         string matchName = "Test Match";
         BoltNetwork.SetServerInfo(matchName, null);
         BoltNetwork.LoadScene("SampleScene");
     }
 }
Example #12
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         string matchName = Guid.NewGuid().ToString() + serverName.text;
         BoltMatchmaking.CreateSession(matchName, null);
         BoltNetwork.LoadScene(levelsselect.captionText.text);
     }
 }
Example #13
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            string matchName = lobbyname.GetComponent <UnityEngine.UI.Text>().text;

            BoltMatchmaking.CreateSession(matchName);
            BoltNetwork.LoadScene("Main");
        }
    }
Example #14
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            string matchName = "Test Realm";

            BoltNetwork.SetServerInfo(matchName, null);
            BoltNetwork.LoadScene("Tutorial1");
        }
    }
Example #15
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)
     {
         BoltNetwork.LoadScene(Scene);
     }
     else
     {
         BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(Endpoint));
     }
 }
Example #17
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer || BoltNetwork.IsSinglePlayer)
     {
         BoltNetwork.LoadScene(BoltRuntimeSettings.instance.debugStartMapName);
     }
     else if (BoltNetwork.IsClient)
     {
         BoltNetwork.Connect((ushort)BoltRuntimeSettings.instance.debugStartPort);
     }
 }
Example #18
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.isServer)
     {
         BoltNetwork.LoadScene("Level 4");
     }
     else
     {
         BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse("127.0.0.1:27000"));
     }
 }
Example #19
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.isServer)
     {
         BoltNetwork.LoadScene("_MainScene");
     }
     else
     {
         BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(_ipAddress));
     }
 }
Example #20
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.isServer)
     {
         BoltNetwork.LoadScene(BoltRuntimeSettings.instance.debugStartMapName);
     }
     else
     {
         BoltNetwork.Connect(_serverEndPoint);
     }
 }
Example #21
0
    public override void BoltStartDone()
    {
        if (BoltNetwork.IsServer)
        {
            string matchName = Guid.NewGuid().ToString();

            //BoltNetwork.SetServerInfo(matchName, null);
            BoltMatchmaking.CreateSession(matchName, null);
            BoltNetwork.LoadScene("Main");
        }
    }
Example #22
0
    void OnGUI()
    {
        switch (_state)
        {
        // starting Bolt is the same regardless of the transport layer
        case State.SelectMode:
            if (GUILayout.Button("Start Client"))
            {
                BoltLauncher.StartClient();
                _state = State.ModeClient;
            }

            if (GUILayout.Button("Start Server"))
            {
                BoltLauncher.StartServer();
                _state = State.ModeServer;
            }

            break;

        // Publishing a session into the matchmaking server
        case State.ModeServer:
            if (BoltNetwork.isRunning && BoltNetwork.isServer)
            {
                if (GUILayout.Button("Publish HostInfo And Load Map"))
                {
                    BoltNetwork.SetHostInfo("MyPhotonGame", new RoomProtocolToken {
                        ArbitraryData = "(MyCustomData)"
                    });
                    BoltNetwork.LoadScene("NetworkedPhysicsTest");
                }
            }
            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)
                {
                    var token = session.Value.GetProtocolToken() as RoomProtocolToken;
                    if (GUILayout.Button(session.Value.Source + " / " + session.Value.HostName + " (" + session.Value.Id + ")" + (token != null ? token.ArbitraryData : "")))
                    {
                        BoltNetwork.Connect(session.Value);
                    }
                }
            }
            break;
        }
    }
Example #23
0
    private void DrawServerMenu()
    {
        GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
        GUILayout.Label("Lobby Password:"******"Apply new Password"))
        {
            ServerSideData.Password = tempPassword;
            ServerSideData.UpdateZeusData();
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Game mode:");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        int newGameModeIndex = GUILayout.SelectionGrid(selectedGameMode, GameModeManager.GameModeNames, 1);

        if (newGameModeIndex != selectedGameMode)
        {
            selectedGameMode = newGameModeIndex;
            IGameMode newGameMode = GameModeManager.GameModes[selectedGameMode];
            GameManager.instance.gameMode = newGameMode;
            updateMapList(GameModeManager.GameModeNames[selectedGameMode]);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Map:");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        selectedMap = GUILayout.SelectionGrid(selectedMap, humanReadableMapList, 1);
        GUILayout.EndHorizontal();

        DrawTeamChangeButtons();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Start Game"))
        {
            string sceneName = "ingame_" + mapList[selectedMap] + "_" + GameManager.instance.gameMode.GetType().Name;
            Debug.Log("loading scene \"" + sceneName + "\"");
            BoltNetwork.LoadScene(sceneName);
        }
        GUILayout.EndHorizontal();
    }
Example #24
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.isServer)
     {
         BoltNetwork.LoadScene("testWorld");
     }
     else
     {
         BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ip + ":27550"));
     }
 }
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer || BoltNetwork.IsSinglePlayer)
     {
         BoltNetwork.LoadScene(BoltRuntimeSettings.instance.debugStartMapName);
     }
     else if (BoltNetwork.IsClient)
     {
         StartCoroutine(DelayClientConnect());
     }
 }
Example #26
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.isClient)
     {
         BoltNetwork.Connect(new UdpEndPoint(UdpIPv4Address.Parse(serverAddress), (ushort)serverPort));
     }
     else
     {
         BoltNetwork.LoadScene(map);
     }
 }
Example #27
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()
        {
            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);
            }
        }
    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");
        }
    }
Example #30
0
 public override void BoltStartDone()
 {
     // If we pressed join game, join a random session
     if (BoltNetwork.IsClient)
     {
         BoltMatchmaking.JoinRandomSession();
     }
     else if (offlineMode)
     {
         BoltNetwork.LoadScene(GameData.ScenesInBuild.scenes[1]);
     }
 }