Exemplo n.º 1
0
 void Start()
 {
     playerName = "OldWheels-" + UtilsC.CreateRandomString(5); //Default Random Player Name
     DontDestroyOnLoad(this);
     m_NetwordView       = GetComponent <NetworkView>();
     m_NetwordView.group = 1;
     Application.LoadLevel(sceneOnDisconnect);
 }
Exemplo n.º 2
0
    void Start()
    {
        if (sInst != null)
        {
            throw new System.Exception("there is NetworkConnection exist!!!!");
        }

        sInst = this;
        //playerName = UtilsC.CreateRandomString(5);
        if (PlayerPrefs.HasKey("playerName"))
        {
            playerName = PlayerPrefs.GetString("playerName");
        }
        else
        {
            playerName = UtilsC.CreateRandomString(5);
        }
        DontDestroyOnLoad(this);
        networkView.group = 1;
        Application.LoadLevel(sceneOnDisconnect);
    }
Exemplo n.º 3
0
 void SetGameID()
 {
     gameType = UtilsC.CreateRandomString(30);
 }
Exemplo n.º 4
0
    // 建立比赛房间
    void HostGame()
    {
        GUILayout.BeginArea(new Rect(Screen.width / 2 - 325, Screen.height / 2 - 180, 700, 400));

        GUI.Box(new Rect(0, 20, 650, 300), "");

        GUILayout.Label("CREATE ROOM");
        GUILayout.BeginArea(new Rect(5, 100, 400, 180));
        GUILayout.Label("MAIN");
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        GUILayout.Label("Server Port: ");
        GUILayout.Label("Server Name: ");
        GUILayout.Label("Server Info: ");
        GUILayout.Label("Max connections: ");
        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        networkConnection.connectPort       = int.Parse(GUILayout.TextField(networkConnection.connectPort.ToString()));
        networkConnection.serverName        = GUILayout.TextField(networkConnection.serverName, GUILayout.MinWidth(140));
        networkConnection.serverDescription = GUILayout.TextField(networkConnection.serverDescription, GUILayout.MinWidth(140));
        networkConnection.maxConnections    = int.Parse(GUILayout.TextField(networkConnection.maxConnections.ToString(), GUILayout.MinWidth(140)));
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(10, 240, 190, 250));
        networkConnection.usePassword = GUILayout.Toggle(networkConnection.usePassword, "Use Password");
        if (networkConnection.usePassword)
        {
            networkConnection.password = GUILayout.PasswordField(networkConnection.password, "*"[0], 15, GUILayout.Width(150));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Generate", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(70)))
            {
                networkConnection.password = UtilsC.CreateRandomString(15);
            }
            if (GUILayout.Button("Clear", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(70)))
            {
                networkConnection.password = "";
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(180, 350, 500, 30));
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Start Server", GUILayout.MaxWidth(130)))
        {
            text_ = GameObject.Find("Loading text");
            text_.renderer.enabled = true;
            networkConnection.StartServer(loadLevelInfo[levelIndex].sceneName);
        }
        if (GUILayout.Button("Back To Menu", GUILayout.MaxWidth(130)))
        {
            menuState = "menublock";
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(450, 50, 190, 250));
        GUILayout.Label("ACCESS POINT");
        GUILayout.BeginVertical();
        GUILayout.Label("Point: " + loadLevelInfo[levelIndex].mapName);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Prev", GUILayout.MinWidth(70)))
        {
            if (levelIndex == 0)
            {
                levelIndex = loadLevelInfo.Length - 1;
            }
            else
            {
                levelIndex--;
            }
        }

        if (GUILayout.Button("Next", GUILayout.MinWidth(70)))
        {
            if (levelIndex == loadLevelInfo.Length - 1)
            {
                levelIndex = 0;
            }
            else
            {
                levelIndex++;
            }
        }

        GUILayout.EndHorizontal();
        if (loadLevelInfo[levelIndex].mapPreview)
        {
            GUILayout.Box(loadLevelInfo[levelIndex].mapPreview, GUI.skin.FindStyle("Box"));
        }
        else
        {
            GUILayout.Box("No Image");
        }
        GUILayout.EndVertical();
        GUILayout.EndArea();
        GUILayout.EndArea();
    }