Пример #1
0
        private void OnConsoleCommand(IConsole console, string cmd, params string[] args)
        {
            if (cmd == "launch")
            {
                TestGameInitArgs gameInitArgs = new TestGameInitArgs();
                if (args.Length > 2)
                {
                    gameInitArgs.MapName = args[2];
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (args.Length > 0)
                {
                    int.TryParse(args[0], out gameInitArgs.PlayersCount);
                    gameInitArgs.PlayersCount = Mathf.Clamp(gameInitArgs.PlayersCount, 0, GameConstants.MaxLocalPlayers);
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (args.Length > 1)
                {
                    int.TryParse(args[1], out gameInitArgs.BotsCount);
                    gameInitArgs.BotsCount = Mathf.Clamp(gameInitArgs.BotsCount, 0, GameConstants.MaxPlayers - gameInitArgs.BotsCount);
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (Dependencies.Navigation != null)
                {
                }
                DontDestroyOnLoadManager.DestroyAll();
                Dependencies.State.SetValue("Battlehub.VoxelGame.TestGameInitArgs", gameInitArgs);
                Dependencies.Navigation.Navigate("Game");
            }
        }
Пример #2
0
        private void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> payload)
        {
            m_gameServer = Dependencies.GameServer;

            TestGameInitArgs gameInitArgs = Dependencies.State.GetValue <TestGameInitArgs>("Battlehub.VoxelGame.TestGameInitArgs");

            if (gameInitArgs == null)
            {
                gameInitArgs = new TestGameInitArgs();
            }
            Dependencies.State.SetValue("Battlehub.VoxelGame.TestGameInitArgs", null);

            bool isConnected = false;

            if (m_remoteGameServer != null)
            {
                m_remoteGameServer.ConnectionStateChanged -= OnConnectionStateChanged;
                isConnected = m_remoteGameServer.IsConnected;
            }

            TestGameInit.Init(gameInitArgs.MapName, gameInitArgs.PlayersCount, gameInitArgs.BotsCount, isConnected, () =>
            {
            }, initError => m_notification.ShowError(initError));
        }