示例#1
0
    public void StartServer()
    {
        string sName = hostServerName.GetComponentsInChildren <Text>()[1].text;
        string sPass = hostServerPass.GetComponentsInChildren <Text>()[1].text;
        string dName = hostDisplayName.GetComponentsInChildren <Text>()[1].text;

        if (sName.Trim() == "")
        {
            hostErrorText.SetActive(true);
            hostErrorText.GetComponentInChildren <Text>().text = "SERVER NAME REQUIRED";
        }
        else if (dName.Trim() == "")
        {
            hostErrorText.SetActive(true);
            hostErrorText.GetComponentInChildren <Text>().text = "DISPLAY NAME REQUIRED";
        }
        else
        {
            hostErrorText.SetActive(false);
            netManager.SetGameName(sName);
            netManager.SetGamePass(sPass);
            netManager.StartServer(dName);

            GotoLobby();
        }
    }
示例#2
0
    // MAIN MENU
    void firstMenu()
    {
        int btnW = 160;
        int btnH = 30;

        int btnX = (Screen.width - btnW) / 2;

        for (int i = 0; i < mainMenuButtons.Length; i++)
        {
            int btnY = (Screen.height / 2) - (btnH * (mainMenuButtons.Length - i)) + (btnPadding * i);

            if (GUI.Button(new Rect(btnX, btnY, btnW, btnH), mainMenuButtons[i]))
            {
                switch (i)
                {
                case 0:
                    Debug.Log("SinglePlayer");
                    networkManager.SetGameName("private game");
                    networkManager.StartPrivateServer();
                    ShowMenu(MenuIndex.GameLobby);
                    break;

                case 1:
                    Debug.Log("Multiplayer");
                    ShowMenu(MenuIndex.ServerList);
                    break;

                case 2:
                    Debug.Log("Controls");
                    break;

                case 3:
                    Debug.Log("Options");
                    break;

                case 4:
                    Debug.Log("ExitGame");
                    Application.Quit();
                    break;

                default:
                    break;
                }
            }
        }
    }