Inheritance: Object
    private void JoinServer(HostData hostData)
    {
        Network.Connect (hostData);

        recoClient = GameObject.Find ("VoiceTranslation");;
        recoClient.GetComponentInChildren<UDP_RecoServer> ().StartServer ();
    }
 private void JoinServer(HostData hostData)
 {
     #if UNITY_ANDROID
     //AndroidJNI.CallIntMethod ();
     #endif
     Network.Connect (hostData);
 }
	public void RetrievePing(HostData host)
	{
		testing = true;
		Network.Connect(host);
		PingLabel.text = "--";
		ip = string.Concat(host.ip);
	}
Exemple #4
0
    private void JoinServer(HostData hostData)
    {
        Debug.Log("Joining to server: "+hostData.gameName+" | "+hostData.ip[0]+":"+hostData.port.ToString());

        clientState=ClientState.ClientJoin;
        Network.Connect(hostData);
    }
 void OnListItemUnselected(ComboBox.ComboItem unselectedItem)
 {
     if (selectedHost == (HostData)unselectedItem.value)
     {
         selectedHost = null;
     }
 }
        private void CreateClientButton(Type type, HostData hostData, int carNumber, float x, float y)
        {
            Texture2D texture;
            if (carNumber == 0)
            {
                texture = type == typeof(Driver) ? _textureDriverRed : _textureThrottlerRed;
            }
            else
            {
                texture = type == typeof(Driver) ? _textureDriverBlue : _textureThrottlerBlue;
            }

            if (DrawTextureButton(new Rect(x, y, ButtonWidth, ButtonHeight), texture))
            {
                MainScript.SelfType = MainScript.PlayerType.Client;
                MainScript.SelfCar = new Car(carNumber);

                //Based on: http://stackoverflow.com/a/755
                MainScript.SelfPlayer = new Player(MainScript.SelfCar, (IPlayerRole)Activator.CreateInstance(type));
                MainScript.SelfPlayer.Role.Initialize();

                MainScript.Client.ChooseJobWhenConnected(type.Name, carNumber);
                if (hostData == null)
                {
                    Network.Connect(GameData.IP, GameData.PORT);
                }
                else
                {
                    Network.Connect(hostData);
                }
                NetworkController.Connected = true;
            }
        }
    public void SetServer(HostData data)
    {
        info = data;

        label.text = data.gameName;
        comment.text = data.comment;
        comment.text += data.connectedPlayers + "/" + data.playerLimit;
    }
 void ConnectToServer(HostData hostData)
 {
     var err = Network.Connect(hostData);
     if (err != NetworkConnectionError.NoError) {
         Debug.Log(string.Format("error initializing server {0}", err));
         return;
     }
 }
Exemple #9
0
	public void Join(HostData host) {
		if(!host.passwordProtected)
			Network.Connect(host);
		else{
			Protected = true;
			select = host;
		}
	}
 void HandleOnServerSelected(HostData selectedServer)
 {
     //When the "Connect" button is pressed in the MasterServerInterface behavior, this is called
     if(selectedServer != null) {
         //Join and hide the host list interface
         JoinServer(selectedServer);
     }
 }
Exemple #11
0
 private void JoinServer(HostData hostData)
 {
     GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
     for (int i = 0; i<players.Length; i++)
     {
         Destroy(players[i]);
     }
     Network.Connect(hostData);
 }
 public static string getDebugName(HostData host)
 {
     string hostName = host.gameType + " " + host.gameName + " " + host.comment + " [" + host.guid + "]";
     string players = "(" + host.connectedPlayers + "/" + host.playerLimit + ")";
     string addresses = "{" + string.Join(":", host.ip) + ":" + host.port + "}";
     string nat = "N:" + host.useNat;
     string password = "******" + host.passwordProtected;
     return string.Join(" ", new string[] {hostName, players, addresses, nat, password});
 }
Exemple #13
0
    private void JoinServer(HostData hostData)
    {
        hostList = null;

        if (selectingIP) {
            Network.Connect (hostData.ip [0], hostData.port);
        } else {
            Network.Connect(hostData);
        }
    }
Exemple #14
0
 public MyHostData Start(HostData hd)
 {
     this.hd = hd;
     foreach (var ip in hd.ip)
     {
         var p = new Ping(ip);
         pp.Add(p);
     }
     return this;
 }
    public static void Connect(HostData host)
    {
        CurrentPlayerIsHost = false;

        NetworkConnectionError code =  Network.Connect(host);

        if(code == NetworkConnectionError.NoError)
        {
            Connected();
        }
    }
 void ConnectTo(HostData hostData)
 {
     // Set NAT functionality based on the host information
     //		Network.useNat = hostData.useNat;
     //		if (Network.useNat)
     //			log.Add("Using Nat punchthrough to connect to host");
     //		else
     //			log.Add("Connecting directly to host: " + string.Join(" ", hostData.ip));
     Network.Connect(hostData.ip, hostData.port);
     Application.LoadLevel(Networking.STARTING_LEVEL);
 }
Exemple #17
0
 void ConnectToServer(HostData server, string password)
 {
     last_tried_server_ = server;
     game_name_ = server.gameName;
     SetState(State.JOINING);
     NetworkConnectionError err = Network.Connect(server, password);
     if(err != NetworkConnectionError.NoError){
         display_err_ = ""+err;
         SetState(State.JOIN_FAIL);
     }
 }
Exemple #18
0
 //Shows a single row of valid server.
 void connectionRow(HostData host)
 {
     GUILayout.BeginHorizontal();
         GUILayout.Label(host.gameName + " (" + host.connectedPlayers + " / " + host.playerLimit + ")");
         GUILayout.Label(host.comment);
         if (GUILayout.Button("Connect", GUILayout.MaxWidth(Screen.width/10)))
         {
             Network.Connect(host);	//Uses unitys server connection protocal
         }
     GUILayout.EndHorizontal();
 }
Exemple #19
0
	void OnGUI(){
		if(hostData != null){
			for (int i = 0; i<hostData.Length; i++) {
				if(GUI.Button(new Rect(Screen.width/2 - buttonWidth/2, 100+(buttonHeight*i), buttonWidth, buttonHeight), hostData[i].gameName)){
					hostGame = hostData[i];
					Application.LoadLevel(int.Parse(hostGame.comment));
					//Network.Connect(hostData[i]);
				}
			} 
		} 
	}
    /*
     * @brief		Connects to a specified server
     * @param
     * @return	void
     */
    public void ConnectWithServer(HostData hostToConnect)
    {
        if(hostToConnect != null) {

            Network.Connect(hostToConnect);
        }
        else {

            Network.Connect(connectToIP, networkConnectPort);
        }
    }
 public static void ConnectToServer(HostData server)
 {
     if (server != null)
     {
         Network.Connect(server);
     }
     else
     {
         Debug.LogError("Missing Host Data");
     }
 }
 public void JoinGame(HostData hd)
 {
     //Network.Connect(hd);
     //Debug.Log("Turning off SetSendingEnabled");
     //Network.SetSendingEnabled(0, false);
     //Debug.Log("Turning off isMessageQueueRunning");
     //Network.isMessageQueueRunning = false;
     //Debug.Log("Loading main level");
     locHD = hd;
     Application.LoadLevel(2);
 }
Exemple #23
0
 /// <summary>
 ///   <para>Connect to the host represented by a HostData structure returned by the Master Server.</para>
 /// </summary>
 /// <param name="hostData"></param>
 /// <param name="password"></param>
 public static NetworkConnectionError Connect(HostData hostData, [DefaultValue("\"\"")] string password)
 {
     if (hostData == null)
     {
         throw new NullReferenceException();
     }
     if (hostData.guid.Length > 0 && hostData.useNat)
     {
         return(Network.Connect(hostData.guid, password));
     }
     return(Network.Connect(hostData.ip, hostData.port, password));
 }
    private void JoinServer(HostData hostData)
    {
        Debug.Log ("joining server: ");
        Network.Connect(hostData);
        foreach (var host in hostData.ip) {
            Debug.Log (host + ":" + hostData.port + " " );
        }

        //saves the meteor DB url
        GameObject.Find ("GameManager").GetComponent<ClientInitialization> ().setMeteorURL (hostData.ip [0]);
        GameObject.Find ("ChooseSessionCanvas").SetActive (false);
    }
    static bool Network_Connect__HostData(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.HostData arg0 = (UnityEngine.HostData)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setEnum((int)JSApi.SetType.Rval, (int)UnityEngine.Network.Connect(arg0));
        }

        return(true);
    }
Exemple #26
0
 public static NetworkConnectionError Connect(HostData hostData, [DefaultValue("\"\"")] string password)
 {
     if (hostData == null)
     {
         throw new NullReferenceException();
     }
     if ((hostData.guid.Length > 0) && hostData.useNat)
     {
         return Connect(hostData.guid, password);
     }
     return Connect(hostData.ip, hostData.port, password);
 }
    static bool Network_Connect__HostData__String(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 2)
        {
            UnityEngine.HostData arg0 = (UnityEngine.HostData)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.String        arg1 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            JSApi.setEnum((int)JSApi.SetType.Rval, (int)UnityEngine.Network.Connect(arg0, arg1));
        }

        return(true);
    }
Exemple #28
0
    public NetworkConnectionError ConnectToHostIndex( int _index )
    {
        if ( _index < 0 || _index >= this.gameHosts.Length )
        {
            DebugConsole.Error( "Index out of range: " + _index, this );
            return NetworkConnectionError.ConnectionFailed;
        }

        this.connectionHost = this.gameHosts[ _index ];
        this.gameName = this.connectionHost.gameName;
        this.gameComment = this.connectionHost.comment;
        return this.Connect( this.connectionHost.ip[0], this.connectionHost.port, "" );
    }
Exemple #29
0
    public ServerData(HostData hostData)
    {
        this.ParseServerDataSeparatedString(hostData.comment);

        /* * /
        // We could also overwrite it with this, by why...
        this.guid = hostData.guid;
        this.serverName = WWW.UnEscapeURL(hostData.gameName);

        this.pwProtected = hostData.passwordProtected;

        this.connectedPlayers = hostData.connectedPlayers;
        this.playerLimit = hostData.playerLimit;
        /* */
    }
    public void JoinRoom(HostData hostData)
    {
        roomToJoin = hostData;
        int i = 1;
        roomToJoinIP = roomToJoin.ip[0];

        while (i < roomToJoin.ip.Length)
        {
            roomToJoinIP += "." + roomToJoin.ip[i];
            i++;
        }
        //Debug.Log("Room IP: " + roomToJoinIP);
        JoinedRoomFlag = 0; // Set joining status
        MasterServer.RequestHostList(GameName);
        //Network.Connect(hostData);
    }
Exemple #31
0
    public void OnDisconnectedFromServer(NetworkDisconnection info)
    {
        if (UnitZ.chatLog != null)
            UnitZ.chatLog.Clear ();

        UnitZ.gameManager.ClearNetworkGameObject ();
        UnitZ.gameManager.IsPlaying = false;

        if (Application.loadedLevelName != PlayerPrefs.GetString ("landingpage")) {
            Application.LoadLevel (PlayerPrefs.GetString ("landingpage"));
            GameObject.Destroy (this.gameObject);
        }

        ServerSelected = null;
        isConnecting = false;
        Debug.Log ("Disconnected from server!");
    }
Exemple #32
0
    public void StartServer(string gameName)
    {
        ConnectedPlayers = new List<NetworkPlayer>();

        MasterServer.ipAddress = "127.0.0.1";
        MasterServer.port = 23466;
        Network.natFacilitatorIP = "127.0.0.1";
        Network.natFacilitatorPort = 50005;

        bool useNat = !Network.HavePublicAddress();
        Network.InitializeServer(32, 25000, useNat);
        CurrentHost = new HostData()
        {
            gameName = gameName
        };
        MasterServer.RegisterHost(GameName, gameName);
        PlayersCount = 0;
    }
	void Start()
	{
		GameToJoin = null;
		
		_bgRect = new Rect(0, 0, Screen.width, Screen.height);

		// Rectangles pour les boutons
		_startBtnRect = new Rect(
			Screen.width - 250, 
			Screen.height / 2 - 35, 200, 50);
			
		
		_joinBtnRect = new Rect(
			Screen.width - 250, 
			Screen.height / 2 + 35, 200, 50);
			
		_cacheRect = new Rect(0, 0, 200, 50);
	}
Exemple #34
0
 public static NetworkConnectionError Connect(HostData hostData, string password)
 {
     throw new NotSupportedException("The legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.");
 }
Exemple #35
0
        public static NetworkConnectionError Connect(HostData hostData)
        {
            string password = "";

            return(Network.Connect(hostData, password));
        }
Exemple #36
0
        public static NetworkConnectionError Connect(HostData hostData)
        {
            string password = string.Empty;

            return(Connect(hostData, password));
        }
Exemple #37
0
        public static NetworkConnectionError Connect(HostData hostData)
        {
            string empty = string.Empty;

            return(Network.Connect(hostData, empty));
        }