Ejemplo n.º 1
0
    /*
     * void LoadingPopup(){
     *      if(UtilsC.IsWebPlayer(){
     *              GUI.Box(new Rect(Screen.width/4+0,Screen.height/2-30,450,50), "");
     *              if(Application.CanStreamedLevelBeLoaded (levelIndex)){
     *                      GUI.Label(new Rect(Screen.width/4+10,Screen.height/2-25,285,150), "Starting the game!");
     *                      //Application.LoadLevel((Application.loadedLevel+1));
     *              }else{
     *                      GUI.Label(new Rect(Screen.width/4+10,Screen.height/2-25,285,150), "Loading the game: "+Mathf.Floor(Application.GetStreamProgressForLevel(levelIndex)*100)+" %");
     *              }
     *      }
     * }
     */

    // 设置玩家名称
    void SetPlayerName()
    {
        GUILayout.BeginArea(new Rect(Screen.width / 2 - 85, Screen.height / 2 - 50, 200, 200));
        GUI.Box(new Rect(0, 40, 200, 80), "", GUI.skin.FindStyle("Box"));
        GUILayout.Label("Player Name", GUI.skin.FindStyle("Lable"));
        GUILayout.BeginHorizontal();
        GUILayout.Space(10);
        networkConnection.playerName = GUILayout.TextField(networkConnection.playerName, 20, GUILayout.MinWidth(180), GUILayout.MaxWidth(250));
        GUILayout.Space(15);
        GUILayout.EndHorizontal();

        if (UtilsC.IsStringCorrect(networkConnection.playerName))
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(50);
            if (GUILayout.Button("Exit", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(100)))
            {
                Application.Quit();
            }
            if (GUILayout.Button("OK", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(100)))
            {
                PlayerPrefs.SetString("playerName", networkConnection.playerName);
                menuState = "setavatarstyle";
            }
            GUILayout.Space(50);
            GUILayout.EndHorizontal();
        }
        else
        {
            GUI.Label(new Rect(12, 90, 185, 30), "Enter your player name!");
        }
        GUILayout.EndArea();
    }
Ejemplo n.º 2
0
 public void OnBtnOKClicked()
 {
     networkConnection.playerName = playerName.text;
     if (UtilsC.IsStringCorrect(networkConnection.playerName))
     {
         PlayerPrefs.SetString("playerName", networkConnection.playerName);
         PlayerPrefs.Save();
         UIManager.GetInst().SetPanelShow("setavatarstyle");
     }
 }
Ejemplo n.º 3
0
    void InGameMenu()
    {
        if (UtilsC.CheckPeerType(NetworkPeerType.Client))
        {
            if (GUILayout.Button("Disconnect"))
            {
                networkConnection.Disconnect(200);
            }
            GUILayout.Label("Ping to server: " + Network.GetAveragePing(Network.connections[0]));
        }

        if (UtilsC.CheckPeerType(NetworkPeerType.Server))
        {
            if (GUILayout.Button("Stop Server", GUILayout.MaxWidth(115)))
            {
                networkConnection.Disconnect(200);
            }

            if (Network.connections.Length > 0)
            {
                GUILayout.Label("Connections: " + Network.connections.Length);

                scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(170), GUILayout.Height(100));
                for (int i = 0; i < Network.connections.Length; i++)
                {
                    GUILayout.Label("Ping to " + i.ToString() + " player: " + Network.GetAveragePing(Network.connections[i]));
                    if (GUILayout.Button("Kick " + i.ToString() + " player", GUILayout.MaxWidth(150)))
                    {
                        networkConnection.Kick(Network.connections[i], true);
                    }
                }
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("No Player Connected");
            }
        }

        GUILayout.Label("You Name: " + networkConnection.playerName);

        if (networkConnection.usePassword && UtilsC.IsStringCorrect(networkConnection.password))
        {
            GUILayout.Label("Server Password: " + networkConnection.password);
        }
    }