コード例 #1
0
    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
    }
コード例 #2
0
ファイル: Sever.cs プロジェクト: 9MW/SoundsWER
    //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);
    }