public void SynchronizationData(GameObject g, SerializeUDP infomation) { BaseTank operatingObj = g.GetComponent <BaseTank>(); // g.transform.position = new Vector3(infomation.x, infomation.y, infomation.z); operatingObj.setDirection(infomation.angle); if (!destinationList.ContainsKey(g)) { destinationList.Add(g, new Vector3(infomation.x, infomation.y, infomation.z)); } else { destinationList[g] = new Vector3(infomation.x, infomation.y, infomation.z); } // SyncPosition(g, new Vector3(infomation.x, infomation.y, infomation.z)); //operatingObj.frie(infomation.state[0]); abandoned operating }
//process incoming position data public override void processMessage(byte[] Udpdata, IPEndPoint ipinfo) { /* print("ipinfo.Address.ToString() " + ipinfo.Address.ToString() ); * Debug.Log( * " IpToObj[ipinfo.Address.ToString()]="+IpToObj[ipinfo.Address.ToString()].ToString()); */ if (!IPtoId.ContainsKey(ipinfo)) { string address = ipinfo.Address.ToString(); int IPid = int.Parse(address.Split('.')[3]); IPtoId.Add(ipinfo, IPid + 1); } obj = synchronizationObj["玩家1" + IPtoId[ipinfo]]; SerializeUDP clientInfo = (SerializeUDP)BytesToOBJ(Udpdata); operatingObj = obj.GetComponent <BaseTank>(); // obj.transform.position = new Vector3(clientInfo.x, clientInfo.y,clientInfo.z); SyncPosition(operatingObj.transform.gameObject, new Vector3(clientInfo.x, clientInfo.y, clientInfo.z)); operatingObj.setDirection(clientInfo.angle); }