Beispiel #1
0
 private void CancelConnection()
 {
     if (connecting)
     {
         connecting = false;
         networkHandler.Disconnect();
         gameSystem.SelectServerMenu();
     }
 }
    private void Start()
    {
        versionText.text = "v" + Config.MAJOR_VERSION + "." + Config.MINOR_VERSION + "." + Config.PATCH_VERSION;

        continueButton.onClick.AddListener(() => {
            gameSystem.MainMenu();
        });

        disconnectButton.onClick.AddListener(() => {
            disconnecting = true;
            continueButton.interactable = false;
            networkHandler.Disconnect();
        });

        UIUtilities.Hide(versionScreen);
    }
Beispiel #3
0
    private void Start()
    {
        newGameButton.onClick.AddListener(() => {
            gameSystem.EnterUsername();
        });

        rejoinButton.onClick.AddListener(() => {
            gameSystem.ReconnectionMenu();
        });

        disconnectButton.onClick.AddListener(() => {
            disconnecting = true;
            newGameButton.interactable = false;
            rejoinButton.interactable  = false;
            networkHandler.Disconnect();
        });

        UIUtilities.Hide(mainMenu);
    }
Beispiel #4
0
    void WindowFunction(int windowID)
    {
        GUI.Label(new Rect(10, 20, windowArea.width - 20, 20), "Host Server");
        GUI.Label(new Rect(10, 50, windowArea.width - 220, 20), "Port: ");
        hostPort = GUI.TextField(new Rect(windowArea.width - 210, 50, 200, 20), hostPort);

        string hostText = "Host";

        switch (Network.peerType)
        {
        case NetworkPeerType.Client:
            hostText = "Disconnect to Host";
            break;

        case NetworkPeerType.Server:
            hostText = "Stop Server";
            break;

        case NetworkPeerType.Connecting:
            hostText = "Connecting...";
            break;
        }

        if (GUI.Button(new Rect(10, 80, windowArea.width - 20, 20), hostText))
        {
            if (Network.peerType == NetworkPeerType.Disconnected)
            {
                handler.StartServer(hostPort);
            }
            else if (Network.peerType == NetworkPeerType.Server)
            {
                handler.Disconnect();
            }
        }

        GUI.Label(new Rect(10, 120, windowArea.width - 20, 20), "Connect to Server");
        GUI.Label(new Rect(10, 150, windowArea.width - 220, 20), "IP Address: ");
        clientIP = GUI.TextField(new Rect(windowArea.width - 210, 150, 200, 20), clientIP);
        GUI.Label(new Rect(10, 170, windowArea.width - 220, 20), "Port: ");
        clientPort = GUI.TextField(new Rect(windowArea.width - 210, 170, 200, 20), clientPort);

        string connectText = "Connect";

        switch (Network.peerType)
        {
        case NetworkPeerType.Client:
            connectText = "Disconnect";
            break;

        case NetworkPeerType.Server:
            connectText = "Stop server to Connect";
            break;

        case NetworkPeerType.Connecting:
            connectText = "Connecting...";
            break;
        }

        if (GUI.Button(new Rect(10, 200, windowArea.width - 20, 20), connectText))
        {
            if (Network.peerType == NetworkPeerType.Disconnected)
            {
                handler.Connect(clientIP, clientPort);
            }
            else if (Network.peerType == NetworkPeerType.Client)
            {
                handler.Disconnect();
            }
        }

        Vector2 labelSize = GUI.skin.label.CalcSize(new GUIContent(handler.log));

        logScroll = GUI.BeginScrollView(new Rect(10, 240, windowArea.width - 20, windowArea.height - 260), logScroll, new Rect(0, 0, labelSize.x, labelSize.y));
        GUI.Label(new Rect(0, 0, labelSize.x, labelSize.y), handler.log);     // Read-only
        GUI.EndScrollView();

        GUI.Label(new Rect(10, windowArea.height - 20, windowArea.width - 20, 20), ("Peer Type: " + Network.peerType.ToString()));
        if (Network.isServer && GUI.Button(new Rect(windowArea.width - 100, windowArea.height - 20, 100, 20), "Start Game"))
        {
            handler.networkView.RPC("LoadLevel", RPCMode.All, "dev_scene", 1);
        }

        GUI.DragWindow(new Rect(0, 0, 100000, 20));
    }