Exemplo n.º 1
0
    public override 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;
            string which = adapter.connectionClient[id].Stext;
            string ip    = which.Replace("::ffff:", "");
            IpToObj.Add(ip, id);
            synchronizationObj.Add("player" + id, player);
        }
    }
Exemplo n.º 2
0
    public override void init()
    {
        string which = adapter.connectionClient[id].Stext;
        string ip    = which.Replace("::ffff:", "");

        IpToObj.Add(ip, id);
    }