示例#1
0
        private IEnumerator WaitForConnectedAsClient()
        {
            var  timer          = 0f;
            bool timerExceedeed = false;

            BoltLauncher.StartClient();
            while (!BoltNetwork.IsClient && !timerExceedeed)
            {
                timer += Time.deltaTime;
                if (timer > 10f)
                {
                    timerExceedeed = true;
                }
                yield return(new WaitForEndOfFrame());
            }

            if (BoltNetwork.IsClient)
            {
                if (OnLookingForLobby != null)
                {
                    OnLookingForLobby.Invoke();
                    Debug.Log("[BOLT] Bolt now running as client.");
                }
                StartLookingForGame();
            }
            else if (timerExceedeed)
            {
                Debug.LogWarning("[BOLT] Took too long to connect as client.");
            }
        }
示例#2
0
        private void OnGUI()
        {
            if (IsHeadlessMode() == true)
            {
                return;
            }

            if (BoltNetwork.IsRunning == false)
            {
                GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

                if (GUILayout.Button("Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
                {
                    BoltLauncher.StartServer();
                }

                if (GUILayout.Button("Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
                {
                    BoltLauncher.StartClient();
                }

                GUILayout.EndArea();
            }

            if (BoltNetwork.IsClient)
            {
                State_SelectRoom();
            }
        }
示例#3
0
    public void ConnectToIP(InputField IPfield)
    {
        var list = IPfield.text.Split('.');

        if (IPfield.text == "" || list.Length <= 3)
        {
            //CoreGUIManager.Instance.Hide("Notification");
            //CoreGUIManager.Instance.SetNotificationSubmitText("Please enter valid IP Address");
            //CoreGUIManager.Instance.Show("NotificationSubmit");
            //StartMenuGUIManager.Instance.GetComponent<GUIAnimationEvents>().turnInteractableOff();
            return;
        }

        ConnectIP   = IPfield.text;
        displayName = DisplayNameText.text;

        Credentials.DisplayName = displayName;
        Credentials.UserName    = displayName;

        BoltLauncher.StartClient();

        //StartMenuGUIManager.Instance.FSM.Transition("Server_Lobby");

        ServerManager.Instance.InitGameSession();

        Messenger.Broadcast("UserAddedToLobby", Credentials.DisplayName);

        ServerManager.Instance.AddToSession(Credentials);
    }
示例#4
0
    public void ConnectToIP(string IPfield)
    {
        var list = IPfield.Split('.');

        if (IPfield == "" || list.Length <= 3)
        {
            //CoreGUIManager.Instance.Hide("Notification");
            //CoreGUIManager.Instance.SetNotificationSubmitText("Please enter valid IP Address");
            //CoreGUIManager.Instance.Show("NotificationSubmit");
            //StartMenuGUIManager.Instance.GetComponent<GUIAnimationEvents>().turnInteractableOff();
            return;
        }

        ConnectIP   = IPfield;
        displayName = DisplayNameText.text;

        Credentials.DisplayName = displayName;
        Credentials.UserName    = displayName;

        BoltLauncher.StartClient();

        //StartMenuGUIManager.Instance.FSM.Transition("Server_Lobby");

        ServerManager.Instance.InitGameSession();

        ServerManager.Instance.AddToSession(Credentials);

        //BoltNetwork.Connect(UdpKit.UdpEndPoint.Parse(ip));
    }
 public void StartServer(string levelName)
 {
     //TODO: Ensure we're not already in a game or hosting
     BoltLauncher.StartServer(UdpKit.UdpEndPoint.Any);
     SceneManager.Instance.GoToScene(levelName, true, OnServerLevelLoaded);
     currentLevel = levelName;
 }
示例#6
0
        public void CountDownTask()
        {
            _nextStop--;

            ModAPI.Log.Write($"nextStop: {_nextStop}");

            if (_conf.getCountdownMessage(_nextStop) != String.Empty)
            {
                string msg = _conf.getCountdownMessage(_nextStop);
                if (msg != String.Empty)
                {
                    msg = msg.Replace("%typ", _conf.getString(_conf.getString("action")));
                    ModAPI.Log.Write(msg);
                    SendChatMessage(msg);
                }
            }
            else if (_nextStop == 0)
            {
                BoltLauncher.Shutdown();
                System.Threading.Thread.Sleep(5000);
                CoopSteamServer.Shutdown();
                CoopSteamClient.Shutdown();
                CoopTreeGrid.Clear();
                if (_conf.getString("action").Contains("restart"))
                {
                    System.Threading.Thread.Sleep(5000);
                    SceneManager.LoadScene("SteamDedicatedBootstrapScene", LoadSceneMode.Single);
                }
                else
                {
                    Application.Quit();
                }
            }
        }
        public override void OnEnter()
        {
            UdpEndPoint endpoint = new UdpEndPoint(UdpIPv4Address.Parse(host.Value), (ushort)port.Value);

            BoltLauncher.StartServer(endpoint);
            Finish();
        }
示例#8
0
 public void OnClickBackFromJoin()
 {
     joinOnlineGamePanel.SetActive(false);
     mainMenuPanel.SetActive(true);
     BoltLauncher.Shutdown();
     SlowerSun();
 }
示例#9
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);
    }
示例#10
0
    private void OnEnable()
    {
        TheForest.Utils.Input.SetState(InputState.World, false);
        TheForest.Utils.Input.SetState(InputState.Menu, true);
        this.BreadCrumbLevel0();
        CoopSteamNGUI coopSteamNGUI = UnityEngine.Object.FindObjectOfType <CoopSteamNGUI>();

        if (coopSteamNGUI)
        {
            UnityEngine.Object.Destroy(coopSteamNGUI.gameObject);
        }
        if (BoltNetwork.isRunning)
        {
            BoltLauncher.Shutdown();
        }
        if (MenuMain.exiting)
        {
            Application.Quit();
        }
        else
        {
            MenuMain.exitingToMenu = false;
        }
        TheForest.Utils.Input.UnLockMouse();
    }
示例#11
0
 public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason)
 {
     registerDoneCallback(() =>
     {
         BoltLauncher.StartServer();
     });
 }
示例#12
0
    private void Start()
    {
        this._serverEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, (ushort)BoltRuntimeSettings.instance.debugStartPort);
        this._clientEndPoint = new UdpEndPoint(UdpIPv4Address.Localhost, 0);
        BoltConfig configCopy = BoltRuntimeSettings.instance.GetConfigCopy();

        configCopy.connectionTimeout         = 60000000;
        configCopy.connectionRequestTimeout  = 500;
        configCopy.connectionRequestAttempts = 1000;
        if (!string.IsNullOrEmpty(BoltRuntimeSettings.instance.debugStartMapName))
        {
            if (BoltDebugStartSettings.startServer)
            {
                BoltLauncher.StartServer(this._serverEndPoint, configCopy);
            }
            else if (BoltDebugStartSettings.startClient)
            {
                BoltLauncher.StartClient(this._clientEndPoint, configCopy);
            }
            BoltDebugStartSettings.PositionWindow();
        }
        if (BoltNetwork.isClient || !BoltNetwork.isServer)
        {
        }
    }
        // Use this for initialization
        void Start()
        {
            // Get custom arguments from command line
            Map      = GetArg("-m", "-map") ?? Map;
            GameType = GetArg("-t", "-gameType") ?? GameType; // ex: get game type from command line
            RoomID   = GetArg("-r", "-room") ?? RoomID;

            // Validate the requested Level
            var validMap = false;

            foreach (string value in BoltScenes.AllScenes)
            {
                if (SceneManager.GetActiveScene().name != value)
                {
                    if (Map == value)
                    {
                        validMap = true;
                        break;
                    }
                }
            }

            if (!validMap)
            {
                BoltLog.Error("Invalid configuration: please verify level name");
                Application.Quit();
            }

            // Start the Server
            BoltLauncher.StartServer();
            DontDestroyOnLoad(this);
        }
示例#14
0
        private void OnGUI()
        {
            if (!_showGui)
            {
                return;
            }

            GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

            if (GUILayout.Button("Start Single Player", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                // START SINGLE PLAYER
                BoltLauncher.StartSinglePlayer();
            }

            if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                // START SERVER
                BoltLauncher.StartServer();
            }

            if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                // START CLIENT
                BoltLauncher.StartClient();
            }

            GUILayout.EndArea();
        }
 public void CreateServer()
 {
     if (IsValidSessionId(startServerSessionIdInputField.text))
     {
         BoltLauncher.StartServer();
     }
 }
 public void JoinServer()
 {
     if (IsValidSessionId(joinServerSessionIdInputField.text))
     {
         BoltLauncher.StartClient();
     }
 }
示例#17
0
 private static void Initialize(BoltNetworkModes modes, UdpEndPoint endpoint, BoltConfig config)
 {
     BoltNetworkInternal.DebugDrawer   = new UnityDebugDrawer();
     BoltNetworkInternal.UsingUnityPro = true;
     if (BoltLauncher.< > f__mg$cache0 == null)
     {
         BoltLauncher.< > f__mg$cache0 = new Func <int, string>(BoltLauncher.GetSceneName);
     }
     BoltNetworkInternal.GetSceneName = BoltLauncher.< > f__mg$cache0;
     if (BoltLauncher.< > f__mg$cache1 == null)
     {
         BoltLauncher.< > f__mg$cache1 = new Func <string, int>(BoltLauncher.GetSceneIndex);
     }
     BoltNetworkInternal.GetSceneIndex = BoltLauncher.< > f__mg$cache1;
     if (BoltLauncher.< > f__mg$cache2 == null)
     {
         BoltLauncher.< > f__mg$cache2 = new Func <List <STuple <BoltGlobalBehaviourAttribute, Type> > >(BoltLauncher.GetGlobalBehaviourTypes);
     }
     BoltNetworkInternal.GetGlobalBehaviourTypes = BoltLauncher.< > f__mg$cache2;
     if (BoltLauncher.< > f__mg$cache3 == null)
     {
         BoltLauncher.< > f__mg$cache3 = new Action(BoltNetworkInternal_User.EnvironmentSetup);
     }
     BoltNetworkInternal.EnvironmentSetup = BoltLauncher.< > f__mg$cache3;
     if (BoltLauncher.< > f__mg$cache4 == null)
     {
         BoltLauncher.< > f__mg$cache4 = new Action(BoltNetworkInternal_User.EnvironmentReset);
     }
     BoltNetworkInternal.EnvironmentReset = BoltLauncher.< > f__mg$cache4;
     BoltNetworkInternal.__Initialize(modes, endpoint, config, BoltLauncher.CreateUdpPlatform(), null);
 }
    private IEnumerator Start()
    {
        PlayerPrefs.Save();
        CoopTreeGrid.Init();
        LoadSave.OnGameStart += this.OnGameStart;
        yield return(CoopPeerStarter.PrefabDbResource);

        if (!CoopPeerStarter.Dedicated)
        {
            CoopLobby.Instance.SetServer(SteamGameServer.GetSteamID());
        }
        BoltConfig config = base.GetConfig();

        config.serverConnectionLimit = ((!CoopPeerStarter.Dedicated) ? (CoopLobby.Instance.Info.MemberLimit - 1) : SteamDSConfig.ServerPlayers);
        if (CoopPeerStarter.Dedicated)
        {
            BoltLauncher.SetUdpPlatform(new DotNetPlatform());
            BoltLauncher.StartServer(SteamDSConfig.EndPoint, config);
        }
        else
        {
            BoltLauncher.StartServer(SteamGameServer.GetSteamID().ToEndPoint(), config);
        }
        try
        {
            BoltNetwork.AddGlobalEventListener(CoopAckChecker.Instance);
        }
        catch
        {
        }
        yield break;
    }
示例#19
0
 public override void BoltShutdownBegin(AddCallback registerDoneCallback)
 {
     registerDoneCallback(() =>
     {
         BoltLauncher.StartServer();
     });
 }
示例#20
0
        private IEnumerator StartServerRoutine(ServerRoomToken serverToken, Action onStartSuccess, Action onStartFail)
        {
            if (BoltNetwork.IsRunning && !BoltNetwork.IsServer)
            {
                BoltLauncher.Shutdown();

                yield return(new WaitUntil(NetworkIsInactive));
            }

            state = State.Starting;

            BoltLauncher.StartServer(config);
            yield return(new WaitUntil(NetworkIsIdle));

            for (int i = 0; i < 3; i++)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (BoltNetwork.IsServer)
            {
                onStartSuccess?.Invoke();

                BoltMatchmaking.CreateSession(Guid.NewGuid().ToString(), serverToken, serverToken.Map);
            }
            else
            {
                onStartFail?.Invoke();
            }
        }
        private IEnumerator StartClientRoutine(Action onStartSuccess, Action onStartFail, bool forceRestart)
        {
            if (BoltNetwork.IsRunning && !BoltNetwork.IsClient || BoltNetwork.IsRunning && forceRestart)
            {
                BoltLauncher.Shutdown();

                yield return(new WaitUntil(NetworkIsInactive));
            }

            if (!BoltNetwork.IsClient)
            {
                state = State.Starting;

                BoltLauncher.StartClient(config);
                yield return(new WaitUntil(NetworkIsIdle));
            }

            if (BoltNetwork.IsClient)
            {
                onStartSuccess?.Invoke();
            }
            else
            {
                onStartFail?.Invoke();
            }
        }
示例#22
0
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

            if (GUILayout.Button("Single Player", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                BoltLauncher.StartSinglePlayer();
            }

            if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                // START SERVER. Configures this peer as the host of the game.
                // When Bolt is ready, we utilise its callback to create a game room
                // somewhere in Photons cloud for client peers to join.
                BoltLauncher.StartServer();
            }

            if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
            {
                // START CLIENT. Configures this peer as a client that can join games.
                // When Bolt is ready, it will automatically connect to Photons servers and
                // pull information about any visible room that has been registered on the cloud.
                BoltLauncher.StartClient();
            }

            GUILayout.EndArea();
        }
示例#23
0
 public void OnClickJoinOnlineGame()
 {
     joinOnlineGamePanel.SetActive(true);
     mainMenuPanel.SetActive(false);
     //exitJoiningGameButton.SetActive(false);
     BoltLauncher.StartClient();
 }
示例#24
0
 private void Awake()
 {
     this.ResetDSFlags();
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     if (LoadAsync.Scenery)
     {
         Blur blur = (!LoadAsync.Scenery) ? null : LoadAsync.Scenery.GetComponentInChildren <Blur>();
         if (blur)
         {
             blur.enabled = true;
         }
     }
     BoltLauncher.SetUdpPlatform(new SteamPlatform());
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(false, ControllerType.Keyboard, "Default");
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Keyboard, "Menu");
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     if (!SteamManager.Initialized)
     {
         if (GameSetup.IsMpServer)
         {
             this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
         }
         else
         {
             this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
         }
         this.SetLoadingText(UiTranslationDatabase.TranslateKey("STEAM_NOT_INITIALIZED", "Steam not initialized", this._allCapsTexts));
         return;
     }
     this.RefreshUI();
     if (GameSetup.IsMpServer)
     {
         this._hostGameName    = PlayerPrefs.GetString("MpGameName", this._hostGameName);
         this._hostMaxPlayers  = PlayerPrefs.GetInt("MpGamePlayerCount", this.GetHostPlayersMax()).ToString();
         this._hostFriendsOnly = (PlayerPrefs.GetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1) == 1);
         this._lobbySetupScreen._gameNameInput.value     = this._hostGameName;
         this._lobbySetupScreen._playerCountInput.value  = this._hostMaxPlayers;
         this._lobbySetupScreen._privateOnlyToggle.value = this._hostFriendsOnly;
         this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
     }
     else
     {
         CoopLobbyManager.QueryList(this._showFriendGames);
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     if (AutoJoinAfterMPInvite.LobbyID != null && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId.ToString() != AutoJoinAfterMPInvite.LobbyID))
     {
         CoopLobbyInfo lobby = new CoopLobbyInfo(ulong.Parse(AutoJoinAfterMPInvite.LobbyID));
         AutoJoinAfterMPInvite.LobbyID = null;
         if (GameSetup.IsSavedGame)
         {
             this.OnClientContinueGame(lobby);
         }
         else
         {
             this.OnClientNewGame(lobby);
         }
     }
 }
示例#25
0
 public void OnClickBackFromHost()
 {
     GameObject.FindWithTag("NewRoomNameInputField").GetComponent <TMP_InputField>().text = "";
     hostOnlineGamePanel.SetActive(false);
     mainMenuPanel.SetActive(true);
     BoltLauncher.Shutdown();
     SlowerSun();
 }
示例#26
0
    void Awake()
    {
        // Set Bolt to use Photon as transport layer
        // this will connect to Photon using config values from Bolt's settings window


        BoltLauncher.SetUdpPlatform(new PhotonPlatform());
    }
示例#27
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         BoltLauncher.Shutdown();
         SceneManager.LoadSceneAsync("Menu");
     }
 }
 public void StartServer()
 {
     if (BoltNetwork.IsRunning)
     {
         BoltLauncher.Shutdown();
     }
     BoltLauncher.StartServer();
 }
示例#29
0
    private void Start()
    {
        GameEventManager.Subscribe <object>(AnnounceEvent);

        if (!BoltNetwork.IsRunning)
        {
            BoltLauncher.StartServer();
        }
    }
示例#30
0
 public static void StartClient(int port)
 {
     if (port >= 0 && port <= 65535)
     {
         BoltLauncher.StartClient(new UdpEndPoint(UdpIPv4Address.Any, (ushort)port));
         return;
     }
     throw new ArgumentOutOfRangeException(string.Format("'port' must be >= 0 and <= {0}", ushort.MaxValue));
 }