コード例 #1
0
    public override void OnClientConnect(NetworkConnection conn)
    {
        IntegerMessage msg = new IntegerMessage(playerId);

        ClientScene.AddPlayer(conn, 0, msg);
    }
コード例 #2
0
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        int xpos    = 10 + offsetX;
        int ypos    = 40 + offsetY;
        int spacing = 24;

        //if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
        //{
        //    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Host(H)"))
        //    {
        //        manager.StartHost();
        //    }
        //    if (GUI.Button(new Rect(xpos + 200, ypos - 20, 120, 20), "Add AI player"))
        //    {
        //        manager.aiPlayerCount++;
        //    }
        //    manager.aiPlayerCount = int.Parse(GUI.TextArea(new Rect(xpos + 200, ypos, 120, 20), manager.aiPlayerCount.ToString()));
        //    if (GUI.Button(new Rect(xpos + 200, ypos + 20, 120, 20), "Remove AI player"))
        //    {
        //        if(manager.aiPlayerCount > 0)
        //            manager.aiPlayerCount--;
        //    }
        //    ypos += spacing;

        //    if (GUI.Button(new Rect(xpos, ypos, 105, 20), "LAN Client(C)"))
        //    {
        //        manager.StartClient();
        //    }
        //    manager.networkAddress = GUI.TextField(new Rect(xpos + 100, ypos, 95, 20), manager.networkAddress);
        //    ypos += spacing;

        //    //manager.lobbyPlayerPrefab.name =
        //    //    GUI.TextField(new Rect(xpos + 200, ypos + 40, 200, 40), manager.lobbyPlayerPrefab.name);
        //    this.playerName =
        //        GUI.TextField(new Rect(xpos + 200, ypos + 40, 200, 40), this.playerName);

        //}
        //else
        //{
        //    if (NetworkServer.active)
        //    {
        //        GUI.Label(new Rect(xpos, ypos, 300, 20), "Server: port=" + manager.networkPort);
        //        ypos += spacing;
        //    }
        //    if (NetworkClient.active)
        //    {
        //        GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
        //        ypos += spacing;
        //    }
        //}

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }

        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)"))
            {
                manager.StopHost();
            }
            ypos += spacing;
        }
        //Note if one ever needs to implement internet matchmaking, re-consult the NetworkManagerHUD script
    }
コード例 #3
0
 private void OnClientConnected(NetworkMessage netMsg)
 {
     ClientScene.Ready(netMsg.conn);
     ClientScene.AddPlayer(0);
 }
コード例 #4
0
    }//assigen the msg type and the delegte function for the msg pass throw the network

    public override void OnClientSceneChanged(NetworkConnection conn)
    {
        ClientScene.AddPlayer(conn, 0);
    }
コード例 #5
0
        void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }

            int xpos    = 10 + offsetX;
            int ypos    = 40 + offsetY;
            int spacing = 120;

            if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
            {
                if (GUI.Button(new Rect(xpos, ypos, 800, 80), "LAN Host(H)", myStyle))
                {
                    manager.StartHost();
                }
                ypos += spacing;

                if (GUI.Button(new Rect(xpos, ypos, 805, 80), "LAN Client(C)", myStyle))
                {
                    manager.StartClient();
                }
                manager.networkAddress = GUI.TextField(new Rect(xpos + 800, ypos, 500, 100), manager.networkAddress);
                ypos += spacing;

                if (GUI.Button(new Rect(xpos, ypos, 400, 40), "LAN Server Only(S)", myStyle))
                {
                    manager.StartServer();
                }
                ypos += spacing;
            }
            else
            {
                if (NetworkServer.active)
                {
                    GUI.Label(new Rect(xpos, ypos, 900, 90), "Server: port=" + manager.networkPort, myStyle);
                    ypos += spacing;
                }
                if (NetworkClient.active)
                {
                    GUI.Label(new Rect(xpos, ypos, 900, 90), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort, myStyle);
                    ypos += spacing;
                }
            }

            if (NetworkClient.active && !ClientScene.ready)
            {
                if (GUI.Button(new Rect(xpos, ypos, 800, 80), "Client Ready", myStyle))
                {
                    ClientScene.Ready(manager.client.connection);

                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer(0);
                    }
                }
                ypos += spacing;
            }

            if (NetworkServer.active || NetworkClient.active)
            {
                if (GUI.Button(new Rect(xpos, ypos, 800, 80), "Stop (X)", myStyle))
                {
                    manager.StopHost();
                }
                ypos += spacing;
            }
        }
コード例 #6
0
 public override void OnLobbyServerConnect(NetworkConnection conn)
 {
     SceneManager.LoadScene("HostScene");
     ClientScene.Ready(conn);
     ClientScene.AddPlayer(conn, 0);
 }
コード例 #7
0
 public void OnClientConnected(NetworkMessage netMsg)
 {
     ClientScene.AddPlayer(netMsg.conn, 1);
 }
コード例 #8
0
    void Update()
    {
        // show if connected, not in world, not in charcreation
        if (manager.IsClientConnected() && !Utils.ClientLocalPlayer() && !uiCharacterCreation.IsVisible())
        {
            panel.SetActive(true);

            // characters available message received already?
            if (manager.charactersAvailableMsg != null)
            {
                // instantiate/destroy enough slots
                CharactersAvailableMsg.CharacterPreview[] characters = manager.charactersAvailableMsg.characters;
                UIUtils.BalancePrefabs(slotPrefab.gameObject, characters.Length, content);

                // refresh all
                List <Player> prefabs = manager.GetPlayerClasses();
                for (int i = 0; i < characters.Length; ++i)
                {
                    Player prefab = prefabs.Find(p => p.name == characters[i].className);
                    UICharacterSelectionSlot slot = content.GetChild(i).GetComponent <UICharacterSelectionSlot>();

                    // name and icon
                    slot.nameText.text = characters[i].name;
                    slot.image.sprite  = prefab.GetComponent <Player>().classIcon;

                    // select button: calls AddPLayer which calls OnServerAddPlayer
                    int icopy = i; // needed for lambdas, otherwise i is Count
                    slot.selectButton.onClick.SetListener(() => {
                        CharacterSelectMsg message = new CharacterSelectMsg {
                            index = icopy
                        };
                        ClientScene.AddPlayer(manager.client.connection, 0, message);

                        // make sure we can't select twice and call AddPlayer twice
                        panel.SetActive(false);
                    });

                    // delete button: sends delete message
                    slot.deleteButton.onClick.SetListener(() => {
                        CharacterDeleteMsg message = new CharacterDeleteMsg {
                            index = icopy
                        };
                        manager.client.Send(CharacterDeleteMsg.MsgId, message);
                    });
                }

                createButton.interactable = characters.Length < manager.characterLimit;
                createButton.onClick.SetListener(() => {
                    panel.SetActive(false);
                    uiCharacterCreation.Show();
                });

                quitButton.onClick.SetListener(() => { NetworkManagerMMO.Quit(); });
            }

            // addon system hooks
            Utils.InvokeMany(typeof(UICharacterSelection), this, "Update_");
        }
        else
        {
            panel.SetActive(false);
        }
    }
コード例 #9
0
 public void OnConnected(NetworkMessage m)
 {
     Debug.Log("Connect!");
     ClientScene.AddPlayer(myClient.connection, 1);
 }
コード例 #10
0
ファイル: NetworkLobbyGUI.cs プロジェクト: avc94/BH
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        int xpos    = 10 + offsetX;
        int ypos    = 40 + offsetY;
        int spacing = 24;

        if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Start Host (H)"))
            {
                manager.StartHost();
            }
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Connect (C)"))
            {
                manager.StartClient();
            }
            manager.networkAddress = GUI.TextField(new Rect(xpos + 100, ypos, 100, 20), manager.networkAddress);
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Start Server Only (S)"))
            {
                manager.StartServer();
            }
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "To Main Menu (Esc)"))
            {
                ToMainMenu();
            }
            ypos += spacing;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300, 20), "Server: port=" + manager.networkPort);
                ypos += spacing;
            }
            if (NetworkClient.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                ypos += spacing;
            }
        }

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }

        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)"))
            {
                manager.StopHost();
            }
            ypos += spacing;
        }
    }
コード例 #11
0
ファイル: connect.cs プロジェクト: cnorfleet/Checkers
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        int xpos    = 10 + offsetX;
        int ypos    = 10 + offsetY;
        int spacing = 24;

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }

        if (NetworkServer.active || NetworkClient.active)
        {
            if (!clientSetup)
            {
                myClient = manager.client; SetupClient(); clientSetup = true;
            }

            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Disconnect"))
            {
                manager.StopHost();
                gm.leaveGame();
            }
            ypos += spacing;
        }

        if (!NetworkServer.active && !NetworkClient.active)
        {
            clientSetup = false;
            if (manager.matchInfo == null)
            {
                if (manager.matches == null)
                {
                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Create Match"))
                    {
                        manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", "", "", 0, 0, manager.OnMatchCreate);
                        gm.begin(1);
                    }
                    ypos += spacing;

                    GUI.Label(new Rect(xpos, ypos, 100, 20), "Room Name:");
                    manager.matchName = GUI.TextField(new Rect(xpos + 100, ypos, 100, 20), manager.matchName);
                    ypos += spacing;

                    ypos += 10;

                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Find Match"))
                    {
                        manager.matchMaker.ListMatches(0, 20, "", true, 0, 0, manager.OnMatchList);
                    }
                    ypos += spacing;
                }
                else
                {
                    foreach (var match in manager.matches)
                    {
                        if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Join Match:" + match.name))
                        {
                            manager.matchName = match.name;
                            manager.matchSize = (uint)match.currentSize;
                            manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined);
                            gm.begin(2);
                        }
                        ypos += spacing;
                    }

                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Back"))
                    {
                        manager.matches = null;
                    }
                    ypos += spacing;
                }
            }

            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Change MM server"))
            {
                showServer = !showServer;
            }
            if (showServer)
            {
                ypos += spacing;
                if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Local"))
                {
                    manager.SetMatchHost("localhost", 1337, false);
                    showServer = false;
                }
                ypos += spacing;
                if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Internet"))
                {
                    manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                    showServer = false;
                }
                ypos += spacing;
                if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Staging"))
                {
                    manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                    showServer = false;
                }
            }

            ypos += spacing;

            try { GUI.Label(new Rect(xpos, ypos, 300, 20), "MM Uri: " + manager.matchMaker.baseUri); }
            catch { }
            ypos += spacing;
        }
    }
コード例 #12
0
ファイル: Client.cs プロジェクト: nQuantums/UNetWebSocket
    /// <summary>
    /// 開始時の処理
    /// </summary>
    void Start()
    {
        // もしクライアントとして実行中じゃなかったら何もしない
        if (!Global.Instance.IsClient)
        {
            return;
        }

        // 物理演算があるので常時処理しておきたい
        Application.runInBackground = true;

        // ネットワーク越しに座標など同期する必要があるプレハブを登録する
        foreach (var kvp in Global.Instance.NetPrefabs)
        {
            ClientScene.RegisterSpawnHandler(
                kvp.Key,
                (position, assetId) => {
                return(GameObject.Instantiate <GameObject>(kvp.Value));
            },
                (spawned) => GameObject.Destroy(spawned)
                );
        }

        // サーバーアドレスの取得
        string address;

        if (string.IsNullOrEmpty(Application.absoluteURL))
        {
            address = "localhost";
        }
        else
        {
            address = new Uri(Application.absoluteURL).GetComponents(UriComponents.Host, UriFormat.Unescaped);
        }

        // サーバーへ接続する
        _Client = new NetworkClient();
        _Client.Connect(address, this.Port);
        _Client.RegisterHandler(
            MsgType.Connect,
            (netMsg) => {
            ClientScene.Ready(netMsg.conn);
            ClientScene.AddPlayer(0);
        }
            );

        // ギミック無効化要求ハンドラ登録
        _Client.RegisterHandler(
            MyMsgType.DisableGimmick,
            (netMsg) => {
            var gimmicks = Server.Instance.GetComponentsInChildren <Gimmick>(true);
            for (int i = 0; i < gimmicks.Length; i++)
            {
                var gimmick = gimmicks[i];
                var c       = gimmick.GetComponent <Collider2D>();
                if (c != null)
                {
                    c.enabled = false;                             // 一旦衝突判定を無効化しておかないとクライアント側で正しい初期位置に戻ってくれない
                }
                gimmick.gameObject.SetActive(false);
                //gimmick.Initialize();
            }
        }
            );

        // ギミック有効化要求ハンドラ登録
        _Client.RegisterHandler(
            MyMsgType.EnableGimmick,
            (netMsg) => {
            var gimmicks = Server.Instance.GetComponentsInChildren <Gimmick>(true);
            for (int i = 0; i < gimmicks.Length; i++)
            {
                gimmicks[i].gameObject.SetActive(true);
            }
        }
            );

        // ギミック衝突判定有効化要求ハンドラ登録
        _Client.RegisterHandler(
            MyMsgType.EnableGimmickCollision,
            (netMsg) => {
            var gimmicks = Server.Instance.GetComponentsInChildren <Gimmick>(true);
            for (int i = 0; i < gimmicks.Length; i++)
            {
                var gimmick = gimmicks[i];
                var c       = gimmick.GetComponent <Collider2D>();
                if (c != null)
                {
                    c.enabled = true;
                }
            }
        }
            );
    }
    void Update()
    {
        // show while in lobby and while not creating a character
        if (manager.state == NetworkState.Lobby && !uiCharacterCreation.IsVisible())
        {
            panel.SetActive(true);

            // characters available message received already?
            if (manager.charactersAvailableMsg != null)
            {
                // instantiate/destroy enough slots
                CharactersAvailableMsg.CharacterPreview[] characters = manager.charactersAvailableMsg.characters;
                UIUtils.BalancePrefabs(slotPrefab.gameObject, characters.Length, content);

                // refresh all
                List <Player> prefabs = manager.GetPlayerClasses();
                for (int i = 0; i < characters.Length; ++i)
                {
                    Player prefab = prefabs.Find(p => p.name == characters[i].className);
                    UICharacterSelectionSlot slot = content.GetChild(i).GetComponent <UICharacterSelectionSlot>();

                    // name and icon
                    slot.nameText.text = characters[i].name;
                    slot.image.sprite  = prefab.GetComponent <Player>().classIcon;

                    // select button: calls AddPlayer which calls OnServerAddPlayer
                    // -> button sends a request to the server
                    // -> if we press button again while request hasn't finished
                    //    then we will get the error:
                    //    'ClientScene::AddPlayer: playerControllerId of 0 already in use.'
                    //    which will happen sometimes at low-fps or high-latency
                    // -> internally ClientScene.AddPlayer adds to localPlayers
                    //    immediately, so let's check that first
                    slot.selectButton.interactable = ClientScene.localPlayer == null;
                    int icopy = i; // needed for lambdas, otherwise i is Count
                    slot.selectButton.onClick.SetListener(() => {
                        CharacterSelectMsg message = new CharacterSelectMsg {
                            index = icopy
                        };
                        ClientScene.AddPlayer(manager.client.connection, message);

                        // make sure we can't select twice and call AddPlayer twice
                        panel.SetActive(false);
                    });

                    // delete button: sends delete message
                    slot.deleteButton.onClick.SetListener(() => {
                        CharacterDeleteMsg message = new CharacterDeleteMsg {
                            index = icopy
                        };
                        manager.client.Send(CharacterDeleteMsg.MsgId, message);
                    });
                }

                createButton.interactable = characters.Length < manager.characterLimit;
                createButton.onClick.SetListener(() => {
                    panel.SetActive(false);
                    uiCharacterCreation.Show();
                });

                quitButton.onClick.SetListener(() => { NetworkManagerMMO.Quit(); });
            }
        }
        else
        {
            panel.SetActive(false);
        }
    }
コード例 #14
0
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        int xpos            = 10 + offsetX;
        int ypos            = 10 + offsetY;
        int buttonWidth     = Screen.width - 20;
        int buttonHeight    = Screen.height / 5;
        int squareButtonDim = Screen.width / 12;
        int spacing         = buttonHeight;

        // Setup Button style
        GUIStyle aButton = new GUIStyle(GUI.skin.button);

        aButton.fontSize = fontSize;
        // Setup TextField style
        GUIStyle someText = new GUIStyle(GUI.skin.textField);

        someText.fontSize  = fontSize;
        someText.alignment = TextAnchor.MiddleCenter;
        // Set Text font size
        GUIStyle someLabel = new GUIStyle(GUI.skin.label);

        someLabel.fontSize = fontSize;

        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect(xpos, ypos, squareButtonDim, squareButtonDim), "X"))
            {
                manager.StopHost();
            }
            ypos += spacing;
        }

        // Initial connection menu
        if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
        {
            /*
             * if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Host(H)"))
             * {
             *  manager.StartHost();
             * }
             * ypos += spacing;
             */

            // Lan client button
            if (GUI.Button(new Rect(xpos, ypos, buttonWidth / 2, buttonHeight), "LAN Client (C)", aButton))
            {
                manager.StartClient();
            }
            // IP input
            manager.networkAddress = GUI.TextField(new Rect(xpos + buttonWidth / 2, ypos, buttonWidth / 2, buttonHeight), manager.networkAddress, someText);
            ypos += spacing;

            // Start Server
            if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Server Only (S)", aButton))
            {
                manager.StartServer();
            }
            ypos += spacing;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Server: port=" + manager.networkPort, someLabel);
                ypos += spacing;
            }
            if (NetworkClient.active)
            {
                GUI.Label(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort, someLabel);
                ypos += spacing;
            }
        }

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }
    }
コード例 #15
0
ファイル: MyManager.cs プロジェクト: DiegoOya/PracticasVR
    public override void OnClientConnect(NetworkConnection conn)
    {
        IntegerMessage msg = new IntegerMessage(playerPrefabIndex);

        ClientScene.AddPlayer(conn, 0, msg); //Comunicamos al server con un mensaje de red el identificador de la opción elegida
    }
コード例 #16
0
 private void AddBot()
 {
     ClientScene.AddPlayer(1);
 }
コード例 #17
0
    //public override void OnClientConnect(NetworkConnection conn)
    //{
    //    SceneManager.LoadScene("HostScene");
    //    ClientScene.Ready(conn);
    //    ClientScene.AddPlayer(conn, 0);
    //}
    //
    //public override void OnClientSceneChanged(NetworkConnection conn)
    //{
    //    SceneManager.LoadScene("Matthew'sScene");
    //    ClientScene.Ready(conn);
    //    ClientScene.AddPlayer(conn, 0);
    //}
    //
    //public override void OnServerSceneChanged(string sceneName)
    //{
    //    ServerChangeScene("HostScene");
    //    //SceneManager.LoadScene("HostScene");
    //}

    public override void OnLobbyClientConnect(NetworkConnection conn)
    {
        SceneManager.LoadScene("Matthew'sScene");
        ClientScene.Ready(conn);
        ClientScene.AddPlayer(conn, 0);
    }
コード例 #18
0
        void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }

            GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
            if (!NetworkClient.isConnected && !NetworkServer.active)
            {
                if (!NetworkClient.active)
                {
                    /*
                     * // LAN Host
                     * if (Application.platform != RuntimePlatform.WebGLPlayer)
                     * {
                     *  if (GUILayout.Button("LAN Host"))
                     *  {
                     *      manager.StartHost();
                     *  }
                     * }
                     */

                    // LAN Client + IP
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("LAN Client"))
                    {
                        manager.StartClient();
                    }
                    manager.networkAddress = GUILayout.TextField(manager.networkAddress);
                    GUILayout.EndHorizontal();

                    // LAN Server Only
                    if (Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        // cant be a server in webgl build
                        GUILayout.Box("(  WebGL cannot be server  )");
                    }
                    else
                    {
                        if (GUILayout.Button("LAN Server Only"))
                        {
                            manager.StartServer();
                        }
                    }
                }
                else
                {
                    // Connecting
                    GUILayout.Label("Connecting to " + manager.networkAddress + "..");
                    if (GUILayout.Button("Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                // server / client status message
                if (NetworkServer.active)
                {
                    GUILayout.Label("Server: active. Transport: " + Transport.activeTransport);
                }
                if (NetworkClient.isConnected)
                {
                    GUILayout.Label("Client: address=" + manager.networkAddress);
                }
            }

            // client ready
            if (NetworkClient.isConnected && !ClientScene.ready)
            {
                if (GUILayout.Button("Client Ready"))
                {
                    ClientScene.Ready(NetworkClient.connection);

                    if (ClientScene.localPlayer == null)
                    {
                        ClientScene.AddPlayer();
                    }
                }
            }

            // stop
            if (NetworkServer.active || NetworkClient.isConnected)
            {
                if (GUILayout.Button("Stop"))
                {
                    manager.StopHost();
                }
            }

            GUILayout.EndArea();
        }
コード例 #19
0
ファイル: NetworkManager.cs プロジェクト: div5yesh/8ballpool
 public override void OnClientConnect(NetworkConnection conn)
 {
     //base.OnClientConnect(conn);
     ClientScene.AddPlayer(conn, 0);
 }
コード例 #20
0
ファイル: NetworkOJ.cs プロジェクト: itsMatoosh/Lake-of-Vape
 public override void OnClientConnect(NetworkConnection conn)
 {
     //ClientScene.Ready (conn);
     ClientScene.AddPlayer(0);
 }
コード例 #21
0
ファイル: LeapNet.cs プロジェクト: wsycarlos/OrionClient
 public override void OnClientConnect(NetworkConnection conn)
 {
     ClientScene.AddPlayer(client.connection, 0);
     Debug.Log("Server Connected!");
 }
コード例 #22
0
 public void TargetRpcAddCar(NetworkConnection connect)
 {
     Debug.Log("Spawning Player (in PlayerInLobby");
     ClientScene.AddPlayer(connect, 0);
 }
コード例 #23
0
 public override void OnClientConnect(NetworkConnection conn)
 {
     base.OnClientConnect(conn);
     Debug.Log("Connected successfully to server, now to set up other stuff for the client...");
     ClientScene.AddPlayer(0);
 }
コード例 #24
0
ファイル: NetworkManager.cs プロジェクト: pdxparrot/ggj2019
        public void AddLocalPlayer(short playerControllerId)
        {
            Debug.Log($"[NetworkManager]: Adding local player {playerControllerId}!");

            ClientScene.AddPlayer(playerControllerId);
        }
コード例 #25
0
 private void OnConnect(NetworkMessage msg)
 {
     Debug.Log("client: connected");
     ClientScene.Ready(msg.conn);
     ClientScene.AddPlayer(0);
 }
コード例 #26
0
    private void OnGUI()
    {
        if (!this.showGUI)
        {
            return;
        }
        zoomRatio = Screen.height / 400f;
        GUI.skin.label.fontSize     = (int)zoomRatio * 15;
        GUI.skin.button.fontSize    = (int)zoomRatio * 15;
        GUI.skin.textField.fontSize = (int)zoomRatio * 15;
        //GUI.skin = customSkin;
        int num1 = 10 + this.offsetX;
        int num2 = 40 + this.offsetY;
        int num3 = 24;

        if (!NetworkClient.active && !NetworkServer.active &&
            (UnityEngine.Object) this.manager.matchMaker == (UnityEngine.Object)null)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           string.Format("LAN Host({0})", Network.player.ipAddress)))
            {
                this.manager.StartHost();
            }
            int num4 = num2 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 105f * zoomRatio, 20f * zoomRatio),
                           "LAN Client(C)"))
            {
                this.manager.StartClient();
                (manager as UManager).SavedIP = manager.networkAddress;
            }
            this.manager.networkAddress =
                GUI.TextField(
                    new Rect((float)(num1 + 100) * zoomRatio, (float)num4 * zoomRatio, 95f * zoomRatio, 20f * zoomRatio),
                    this.manager.networkAddress);
            int num5 = num4 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "LAN Server Only(S)"))
            {
                this.manager.StartServer();
            }
            num2 = num5 + num3;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio),
                          "Server: port=" + (object)this.manager.networkPort);
                num2 += num3;
            }
            if (NetworkClient.active)
            {
                Rect     position = new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio);
                object[] objArray = new object[4];
                int      index1   = 0;
                string   str1     = "Client: address=";
                objArray[index1] = (object)str1;
                int    index2         = 1;
                string networkAddress = this.manager.networkAddress;
                objArray[index2] = (object)networkAddress;
                int    index3 = 2;
                string str2   = " port=";
                objArray[index3] = (object)str2;
                int index4 = 3;
                // ISSUE: variable of a boxed type
                int local = this.manager.networkPort;
                objArray[index4] = (object)local;
                string text = string.Concat(objArray);
                GUI.Label(position, text);
                num2 += num3;
            }
        }
        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Client Ready"))
            {
                ClientScene.Ready(this.manager.client.connection);
                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer((short)0);
                }
            }
            num2 += num3;
        }
        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num2 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Stop (X)"))
            {
                this.manager.StopHost();
            }
            num2 += num3;
        }
        if (NetworkServer.active || NetworkClient.active)
        {
            return;
        }
        int num6 = num2 + 10;
        int num7;

        if ((UnityEngine.Object) this.manager.matchMaker == (UnityEngine.Object)null)
        {
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Enable Match Maker (M)"))
            {
                this.manager.StartMatchMaker();
            }
            num7 = num6 + num3;
        }
        else
        {
            if (this.manager.matchInfo == null)
            {
                if (this.manager.matches == null)
                {
                    if (
                        GUI.Button(
                            new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                            "Create Internet Match"))
                    {
                        this.manager.matchMaker.CreateMatch(this.manager.matchName, this.manager.matchSize, true,
                                                            string.Empty,
                                                            new NetworkMatch.ResponseDelegate <CreateMatchResponse>(this.manager.OnMatchCreate));
                    }
                    int num4 = num6 + num3;
                    GUI.Label(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                              "Room Name:");
                    this.manager.matchName =
                        GUI.TextField(
                            new Rect((float)(num1 + 100) * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio,
                                     20f * zoomRatio), this.manager.matchName);
                    int num5 = num4 + num3 + 10;
                    if (
                        GUI.Button(
                            new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                            "Find Internet Match"))
                    {
                        this.manager.matchMaker.ListMatches(0, 20, string.Empty,
                                                            new NetworkMatch.ResponseDelegate <ListMatchResponse>(this.manager.OnMatchList));
                    }
                    num6 = num5 + num3;
                }
                else
                {
                    using (List <MatchDesc> .Enumerator enumerator = this.manager.matches.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            MatchDesc current = enumerator.Current;
                            if (
                                GUI.Button(
                                    new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio,
                                             20f * zoomRatio), "Join Match:" + current.name))
                            {
                                this.manager.matchName = current.name;
                                this.manager.matchSize = (uint)current.currentSize;
                                this.manager.matchMaker.JoinMatch(current.networkId, string.Empty,
                                                                  new NetworkMatch.ResponseDelegate <JoinMatchResponse>(this.manager.OnMatchJoined));
                            }
                            num6 += num3;
                        }
                    }
                }
            }
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Change MM server"))
            {
                this.showServer = !this.showServer;
            }
            if (this.showServer)
            {
                int num4 = num6 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num4 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Local"))
                {
                    this.manager.SetMatchHost("localhost", 1337, false);
                    this.showServer = false;
                }
                int num5 = num4 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num5 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Internet"))
                {
                    this.manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                    this.showServer = false;
                }
                num6 = num5 + num3;
                if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num6 * zoomRatio, 100f * zoomRatio, 20f * zoomRatio),
                               "Staging"))
                {
                    this.manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                    this.showServer = false;
                }
            }
            int num8 = num6 + num3;
            GUI.Label(new Rect((float)num1 * zoomRatio, (float)num8 * zoomRatio, 300f * zoomRatio, 20f * zoomRatio),
                      "MM Uri: " + (object)this.manager.matchMaker.baseUri);
            int num9 = num8 + num3;
            if (GUI.Button(new Rect((float)num1 * zoomRatio, (float)num9 * zoomRatio, 200f * zoomRatio, 20f * zoomRatio),
                           "Disable Match Maker"))
            {
                this.manager.StopMatchMaker();
            }
            num7 = num9 + num3;
        }
    }
コード例 #27
0
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        /*int xpos = 10 + offsetX;
        *  int ypos = 40 + offsetY;*/

        int buttonWidth  = Screen.width / 4;
        int buttonHeight = Screen.height / 8;

        int xpos    = (Screen.width / 2) - (buttonWidth / 2);
        int ypos    = (Screen.height / 2) - (buttonHeight / 2);
        int spacing = buttonHeight + 20;

        if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
        {
            if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Host(H)"))
            {
                manager.StartHost();
            }
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Client(C)"))
            {
                manager.StartClient();
            }
            manager.networkAddress = "192.168.1.104";
            //GUI.TextField(new Rect(xpos + 100, ypos, buttonWidth, buttonHeight), manager.networkAddress);
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, buttonWidth, buttonHeight), "LAN Server Only(S)"))
            {
                manager.StartServer();
            }
            ypos += spacing;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300, 20), "Server: port=" + manager.networkPort);
                ypos += spacing;
            }
            if (NetworkClient.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                ypos += spacing;
            }
        }

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }

        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)"))
            {
                manager.StopHost();
            }
            ypos += spacing;
        }

        if (!NetworkServer.active && !NetworkClient.active)
        {
            ypos += 10;

            if (manager.matchMaker == null)
            {
                /*if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Enable Match Maker (M)"))
                 * {
                 *      manager.StartMatchMaker();
                 * }
                 * ypos += spacing;*/
            }
            else
            {
                if (manager.matchInfo == null)
                {
                    if (manager.matches == null)
                    {
                        if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Create Internet Match"))
                        {
                            manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", manager.OnMatchCreate);
                        }
                        ypos += spacing;

                        GUI.Label(new Rect(xpos, ypos, 100, 20), "Room Name:");
                        manager.matchName = GUI.TextField(new Rect(xpos + 100, ypos, 100, 20), manager.matchName);
                        ypos += spacing;

                        ypos += 10;

                        if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Find Internet Match"))
                        {
                            manager.matchMaker.ListMatches(0, 20, "", manager.OnMatchList);
                        }
                        ypos += spacing;
                    }
                    else
                    {
                        foreach (var match in manager.matches)
                        {
                            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Join Match:" + match.name))
                            {
                                manager.matchName = match.name;
                                manager.matchSize = (uint)match.currentSize;
                                manager.matchMaker.JoinMatch(match.networkId, "", manager.OnMatchJoined);
                            }
                            ypos += spacing;
                        }
                    }
                }

                if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Change MM server"))
                {
                    showServer = !showServer;
                }
                if (showServer)
                {
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Local"))
                    {
                        manager.SetMatchHost("localhost", 1337, false);
                        showServer = false;
                    }
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Internet"))
                    {
                        manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                        showServer = false;
                    }
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Staging"))
                    {
                        manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                        showServer = false;
                    }
                }

                ypos += spacing;

                GUI.Label(new Rect(xpos, ypos, 300, 20), "MM Uri: " + manager.matchMaker.baseUri);
                ypos += spacing;

                if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Disable Match Maker"))
                {
                    manager.StopMatchMaker();
                }
                ypos += spacing;
            }
        }
    }
コード例 #28
0
        void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }

            NetworkManager manager = (NetworkManager)this.manager;

            int       xpos    = 10 + offsetX;
            int       ypos    = 40 + offsetY;
            const int spacing = 24;

            bool noConnection = (manager.client == null || manager.client.connection == null ||
                                 manager.client.connection.connectionId == -1);

            if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
            {
                if (noConnection)
                {
                    if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer)
                    {
                        if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Host(H)"))
                        {
                            manager.StartHost();
                        }
                        ypos += spacing;
                    }

                    if (GUI.Button(new Rect(xpos, ypos, 105, 20), "LAN Client(C)"))
                    {
                        manager.StartClient();
                    }

                    manager.networkAddress = GUI.TextField(new Rect(xpos + 100, ypos, 95, 20), manager.networkAddress);
                    ypos += spacing;

                    if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        // cant be a server in webgl build
                        GUI.Box(new Rect(xpos, ypos, 200, 25), "(  WebGL cannot be server  )");
                        ypos += spacing;
                    }
                    else
                    {
                        if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Server Only(S)"))
                        {
                            manager.StartServer();
                        }
                        ypos += spacing;
                    }
                }
                else
                {
                    GUI.Label(new Rect(xpos, ypos, 200, 20), "Connecting to " + manager.networkAddress + ":" + manager.networkPort + "..");
                    ypos += spacing;


                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                if (NetworkServer.active)
                {
                    string serverMsg = "Server: port=" + manager.networkPort;
                    if (manager.useWebSockets)
                    {
                        serverMsg += " (Using WebSockets)";
                    }
                    GUI.Label(new Rect(xpos, ypos, 300, 20), serverMsg);
                    ypos += spacing;
                }
                if (manager.IsClientConnected())
                {
                    GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                    ypos += spacing;
                }
            }

            if (manager.IsClientConnected() && !ClientScene.ready)
            {
                if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Client Ready"))
                {
                    ClientScene.Ready(manager.client.connection);

                    if (ClientScene.localPlayers.Count == 0)
                    {
                        ClientScene.AddPlayer(0);
                    }
                }
                ypos += spacing;
            }

            if (NetworkServer.active || manager.IsClientConnected())
            {
                if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)"))
                {
                    manager.StopHost();
                }
                ypos += spacing;
            }

            if (!NetworkServer.active && !manager.IsClientConnected() && noConnection)
            {
                ypos += 10;

                if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
                {
                    GUI.Box(new Rect(xpos - 5, ypos, 220, 25), "(WebGL cannot use Match Maker)");
                    return;
                }

                if (manager.matchMaker == null)
                {
                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Enable Match Maker (M)"))
                    {
                        manager.StartMatchMaker();
                    }
                    ypos += spacing;
                }
                else
                {
                    if (manager.matchInfo == null)
                    {
                        if (manager.matches == null)
                        {
                            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Create Internet Match"))
                            {
                                manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", "", "", 0, 0, manager.OnMatchCreate);
                            }
                            ypos += spacing;

                            GUI.Label(new Rect(xpos, ypos, 100, 20), "Room Name:");
                            manager.matchName = GUI.TextField(new Rect(xpos + 100, ypos, 100, 20), manager.matchName);
                            ypos += spacing;

                            ypos += 10;

                            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Find Internet Match"))
                            {
                                manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, manager.OnMatchList);
                            }
                            ypos += spacing;
                        }
                        else
                        {
                            for (int i = 0; i < manager.matches.Count; i++)
                            {
                                var match = manager.matches[i];
                                if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Join Match:" + match.name))
                                {
                                    manager.matchName = match.name;
                                    manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined);
                                }
                                ypos += spacing;
                            }

                            if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Back to Match Menu"))
                            {
                                manager.matches = null;
                            }
                            ypos += spacing;
                        }
                    }

                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Change MM server"))
                    {
                        showServer = !showServer;
                    }
                    if (showServer)
                    {
                        ypos += spacing;
                        if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Local"))
                        {
                            manager.SetMatchHost("localhost", 1337, false);
                            showServer = false;
                        }
                        ypos += spacing;
                        if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Internet"))
                        {
                            manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                            showServer = false;
                        }
                        ypos += spacing;
                        if (GUI.Button(new Rect(xpos, ypos, 100, 20), "Staging"))
                        {
                            manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                            showServer = false;
                        }
                    }

                    ypos += spacing;

                    GUI.Label(new Rect(xpos, ypos, 300, 20), "MM Uri: " + manager.matchMaker.baseUri);
                    ypos += spacing;

                    if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Disable Match Maker"))
                    {
                        manager.StopMatchMaker();
                    }
                    ypos += spacing;
                }
            }
        }
コード例 #29
0
 public void AddPlayer()
 {
     ClientScene.AddPlayer(1);
 }
コード例 #30
0
ファイル: NetworkUI.cs プロジェクト: BlitzZart/OnoEdge
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        GUI.skin.label.fontSize             =
            GUI.skin.button.fontSize        =
                GUI.skin.textField.fontSize = (int)(8 * scale);

        int xpos    = 10 + offsetX;
        int ypos    = 40 + offsetY;
        int spacing = (int)(24 * scale);

        if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "LAN Host(H)"))
            {
                manager.StartHost();
            }
            ypos += spacing;

            if (GUI.Button(new Rect(xpos, ypos, 105 * scale, 20 * scale), "LAN Client(C)"))
            {
                manager.StartClient();
            }


            manager.networkAddress = GUI.TextField(new Rect((xpos + 100) * scale, ypos, 95 * scale, 20 * scale), manager.networkAddress);
            ypos += spacing;

            //GUI.Label(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Own IP: " + Network.natFacilitatorIP);
            //ypos += spacing;
            GUI.Label(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Own IP: " + Network.player.ipAddress);
            ypos += spacing;


            if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "LAN Server Only(S)"))
            {
                manager.StartServer();
            }
            ypos += spacing;
        }
        else
        {
            if (NetworkServer.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300 * scale, 20 * scale), "Server: port=" + manager.networkPort);
                ypos += spacing;
            }
            if (NetworkClient.active)
            {
                GUI.Label(new Rect(xpos, ypos, 300 * scale, 20 * scale), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort);
                ypos += spacing;
            }
        }

        if (NetworkClient.active && !ClientScene.ready)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Client Ready"))
            {
                ClientScene.Ready(manager.client.connection);

                if (ClientScene.localPlayers.Count == 0)
                {
                    ClientScene.AddPlayer(0);
                }
            }
            ypos += spacing;
        }

        if (NetworkServer.active || NetworkClient.active)
        {
            if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Stop (X)"))
            {
                manager.StopHost();
            }
            ypos += spacing;
        }

        if (!NetworkServer.active && !NetworkClient.active)
        {
            ypos += 10;

            if (manager.matchMaker == null)
            {
                if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Enable Match Maker (M)"))
                {
                    manager.StartMatchMaker();
                }
                ypos += spacing * 2;
                if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Close App"))
                {
                    Application.Quit();
                }
                ypos += spacing;
            }
            else
            {
                if (manager.matchInfo == null)
                {
                    if (manager.matches == null)
                    {
                        if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Create Internet Match"))
                        {
                            manager.matchMaker.CreateMatch(manager.matchName, manager.matchSize, true, "", manager.OnMatchCreate);
                        }
                        ypos += spacing;

                        GUI.Label(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Room Name:");
                        manager.matchName = GUI.TextField(new Rect((xpos + 100) * scale, ypos, 95 * scale, 20 * scale), manager.matchName);
                        ypos += spacing;

                        ypos += 10;

                        if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Find Internet Match"))
                        {
                            manager.matchMaker.ListMatches(0, 20, "", manager.OnMatchList);
                        }
                        ypos += spacing;
                    }
                    else
                    {
                        foreach (var match in manager.matches)
                        {
                            if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Join: " + match.name + " | " + match.currentSize))
                            {
                                manager.matchName = match.name;
                                manager.matchSize = (uint)match.currentSize;
                                manager.matchMaker.JoinMatch(match.networkId, "", manager.OnMatchJoined);
                            }
                            ypos += spacing;
                        }
                    }
                }

                if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Change MM server"))
                {
                    showServer = !showServer;
                }
                if (showServer)
                {
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Local"))
                    {
                        manager.SetMatchHost("localhost", 1337, false);
                        showServer = false;
                    }
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Internet"))
                    {
                        manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
                        showServer = false;
                    }
                    ypos += spacing;
                    if (GUI.Button(new Rect(xpos, ypos, 100 * scale, 20 * scale), "Staging"))
                    {
                        manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
                        showServer = false;
                    }
                }

                ypos += spacing;

                GUI.Label(new Rect(xpos, ypos, 300 * scale, 20 * scale), "MM Uri: " + manager.matchMaker.baseUri);
                ypos += spacing;

                if (GUI.Button(new Rect(xpos, ypos, 200 * scale, 20 * scale), "Disable Match Maker"))
                {
                    manager.StopMatchMaker();
                }
                ypos += spacing;
            }
        }
    }