示例#1
0
 public void Initialize(LanConnnectionInfo newGame, Transform panelTransform)
 {
     this.game         = newGame;
     gameNameText.text = game.gameName;
     hostNameText.text = game.hostName;
     transform.SetParent(panelTransform);
     GetComponent <RectTransform>().anchoredPosition = new Vector3(GameObject.Find("GameController").GetComponent <ScrollRectSnap>().GetNextPosition(), 0, 0);
     transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
 }
示例#2
0
 /// <summary>
 /// Start connection as a client to specified LanConnection.
 /// </summary>
 /// <param name="info">Connection infos like IP and port.</param>
 public void StartConnection(LanConnnectionInfo info)
 {
     if (!isConnected)
     {
         SetIP(info.ipAddress);
         SetPort(LanConnnectionInfo.PORT);
         NetworkManager.singleton.StartClient();
         isConnected = true;
     }
 }
    public void EnterSelectedGame()
    {
        // Get selected game
        LanConnnectionInfo game = gameScrollRect.GetSelectedCard().GetGameInfo();

        //SceneManager.LoadScene("WaitingScene");

        // Stop listening
        FindObjectOfType <ConnectionDiscovery>().Stop();
        // Connect to selected game
        FindObjectOfType <CustomNetworkManager>().StartConnection(game);
    }
    /// <summary>
    /// Callback when new broadcastData is received.
    /// </summary>
    /// <param name="fromAddress">The address we receive from.</param>
    /// <param name="data">Additional data (game name)</param>
    public override void OnReceivedBroadcast(string fromAddress, string data)
    {
        base.OnReceivedBroadcast(fromAddress, data);
        Debug.Log("Received broadcast: " + fromAddress + ", " + data);

        data = data.Replace("#", ""); // Remove padded chars

        LanConnnectionInfo info = new LanConnnectionInfo(fromAddress, data);

        Debug.Log(info.gameName + ", " + info.hostName);

        if (!lanAddresses.ContainsKey(info))
        {
            lanAddresses.Add(info, Time.time + EXPIRE_TIMEOUT);
            UpdateMatchInfo();
        }
        else
        {
            lanAddresses[info] = Time.time + EXPIRE_TIMEOUT;
        }
    }