Exemplo n.º 1
0
 public void broadcast(byte[] data, int msgType)
 {
     foreach (int id in adapter.connectionClient.Keys)
     {
         adapter.sendmessage(id, data, msgType);
     }
 }
Exemplo n.º 2
0
    public void init()
    {
        generateDifferColor();//use color to identify players
        uint PN = 0;

        Debug.Log("Entry to init method adapter.connectionClient=" + adapter.connectionClient.Count);
        //instance player
        foreach (int id in adapter.connectionClient.Keys)
        {
            Color tmpc;
            adapter.sendmessage(id, new byte[] { (byte)id }, msgType.SeverSideId);
            Debug.Log("clientId=" + id + " byteId=" + (byte)id);
            tmpc = availableColor.Dequeue();
            byte[] colinfo = NetWorkAdapter.GetBytes(tmpc.r + "," + tmpc.g + "," + tmpc.b);
            adapter.sendmessage(id, colinfo, msgType.color);
            Vector3    spawnPOS = new Vector3(-synchronizationObj.Count + PN, 0);
            GameObject player   = Instantiate(PlayePrefab, spawnPOS, gameObject.transform.rotation);
            player.name = "player" + id;
            player.GetComponent <SpriteRenderer>().color = tmpc;
            synchronizationObj.Add("player" + id, player);
        }
    }