Beispiel #1
0
    public void Connect()
    {
        string playerName = GameObject.Find("Name Field").GetComponent <InputField>().text;

        connectToAddress = GameObject.Find("Address Field").GetComponent <InputField>().text;
        if (playerName == "")
        {
            Debug.LogWarning("You must have a name!");
            playerName = PlayerName.GetName();
        }
        PlayerName.SetName(playerName);

        NetworkTransport.Init();
        ConnectionConfig cc = new ConnectionConfig();

        reliableChannel   = cc.AddChannel(QosType.Reliable);
        unreliableChannel = cc.AddChannel(QosType.Unreliable);

        HostTopology topo = new HostTopology(cc, MAX_CONNECTION);

        hostId       = NetworkTransport.AddHost(topo, 0);
        connectionId = NetworkTransport.Connect(hostId, connectToAddress, port, 0, out error);

        connectionTime = Time.time;
        isConnected    = true;

        packMan.ClearPacks();

        Debug.Log("Started Client! : Error " + error + " : Port " + port);
    }
Beispiel #2
0
    void Start()
    {
        GameObject.Find("Address Field").GetComponent <InputField>().text = Network.player.ipAddress.ToString();

        PlayerName.Init();
        playerName = PlayerName.GetName();
        GameObject.Find("Name Field").GetComponent <InputField>().text = playerName;
    }
Beispiel #3
0
    void CreateHostPlayer()
    {
        PlayerName.SetName(hostName);

        ServerClient c = new ServerClient();

        c.connectionId = 0;
        c.playerName   = PlayerName.GetName();
        clients.Add(c);

        UpdateClientsList();
    }