Beispiel #1
0
    public void Setup(BP_NetworkManager aNetworkManager)
    {
        networkManager = aNetworkManager;
        broadcastKey   = Mathf.Abs(aNetworkManager.broadcastIdentifier.GetHashCode());//Make sure broadcastKey matches client
        isOpen         = false;
        numPlayers     = 0;

        broadcastDataObject        = new BeerPongBroadcastData();
        broadcastDataObject.peerId = networkManager.peerId;
        UpdateBroadcastData();
    }
Beispiel #2
0
    private void OnDataCompleteReceived(int transmissionId, byte[] data)
    {
        BP_NetworkManager networkManager = NetworkManager.singleton as BP_NetworkManager;
        BP_PlayerScript   p = networkManager.localPlayer as BP_PlayerScript;

        if (p != null)
        {
            //deserealize data and relocalize
            StartCoroutine(p.RelocateDevice(data));
        }
    }
Beispiel #3
0
 public override void OnStartClient()
 {
     networkManager = NetworkManager.singleton as BP_NetworkManager;
     if (networkManager)
     {
         networkManager.lobbySlots[slot] = this;
         OnClientEnterLobby();
     }
     else
     {
         Debug.LogError("BeerPongPlayer could not find a BP_NetworkManager.");
     }
 }
Beispiel #4
0
    // Update is called once per frame
    public void Update()
    {
        if (networkManager == null)
        {
            networkManager          = FindObjectOfType(typeof(BP_NetworkManager)) as BP_NetworkManager;
            networkManager.listener = listener;

            if (networkManager.verboseLogging)
            {
                Debug.Log("#BeerPong# !! RECONNECTING !!");
            }
        }
    }
Beispiel #5
0
    public override void OnStartLocalPlayer()
    {
        networkManager             = NetworkManager.singleton as BP_NetworkManager;
        networkManager.localPlayer = this;

        #if UNITY_ANDROID
        deviceName = SystemInfo.deviceModel;
#else
        deviceName = SystemInfo.deviceName;
#endif

        version     = VERSION;
        deviceId    = networkManager.deviceId;
        peerId      = networkManager.peerId;
        playerIndex = slot;
        ready       = false;

        CmdSetBasePlayerInfo(version, deviceName, deviceId, peerId, playerIndex);
    }
Beispiel #6
0
    public void Awake()
    {
        ValidateConfig();

        //Create network manager
        networkManager = (Instantiate(Resources.Load("BeerPongNetworkManager")) as GameObject).GetComponent <BP_NetworkManager>();
        if (networkManager != null)
        {
            //networkManager.logLevel = 0;

            networkManager.name                = "BeerPongNetworkManager";
            networkManager.runInBackground     = false; //runInBackground is not recommended on iOS
            networkManager.broadcastIdentifier = broadcastIdentifier;
            networkManager.minPlayers          = minPlayers;
            networkManager.SetMaxPlayers(maxPlayers); //Setting maxPlayers and maxConnections
            networkManager.allReadyCountdownDuration = countdownDuration;
            networkManager.forceServer = forceServer;

            //I'm just using a single scene for everything
            networkManager.offlineScene = "";
            networkManager.onlineScene  = "";

            networkManager.playerPrefab   = playerPrefab.gameObject;
            networkManager.listener       = listener;
            networkManager.verboseLogging = verboseLogging;

            //Optionally create Debug GUI
            if (useDebugGUI)
            {
                networkManager.GetComponent <BeerPongDebugGUI>().enabled = true;
            }
        }
        else
        {
            Debug.LogError("#BeerPong# Error creating network manager");
        }
    }
 public void Awake()
 {
     beerPong       = FindObjectOfType(typeof(BeerPong)) as BeerPong;
     networkManager = GetComponent <BP_NetworkManager>();
 }
Beispiel #8
0
 public void Setup(BP_NetworkManager aNetworkManager)
 {
     networkManager = aNetworkManager;
     broadcastKey   = Mathf.Abs(aNetworkManager.broadcastIdentifier.GetHashCode());//Make sure broadcastKey matches server
 }