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); } }
public override void init() { string which = adapter.connectionClient[id].Stext; string ip = which.Replace("::ffff:", ""); IpToObj.Add(ip, id); }