Example #1
0
        public override bool Deserialize(byte[] bytes)
        {
            var result = base.Deserialize(bytes);

            if (!result)
            {
                return(result);
            }

            Op = (EOperate)(Args[0] as PackageArgument_Int).Value;

            var arg_transformList = (Args[1] as PackageArgument_TransformList).Value;

            TransformList.Clear();
            for (int i = 0; i < arg_transformList.Count; i++)
            {
                var arg_transformInfo = arg_transformList[i];
                var item = new SyncTransformData();
                item.NetworkID = arg_transformInfo.ID;
                item.Pos_X     = arg_transformInfo.Pos_X;
                item.Pos_Y     = arg_transformInfo.Pos_Y;
                item.Pos_Z     = arg_transformInfo.Pos_Z;
                item.Euler_X   = arg_transformInfo.Euler_X;
                item.Euler_Y   = arg_transformInfo.Euler_Y;
                item.Euler_Z   = arg_transformInfo.Euler_Z;
                item.SCALE_X   = arg_transformInfo.SCALE_X;
                item.SCALE_Y   = arg_transformInfo.SCALE_Y;
                item.SCALE_Z   = arg_transformInfo.SCALE_Z;
                TransformList.Add(item);
            }

            return(result);
        }
Example #2
0
        void FetchSelfTransforms(List <SyncTransforms_TransformMono> transformsList, UDPBox udpBox, IPEndPoint ipEndPoint, bool isFetchAll = false)
        {
            UDPBox_GameThreadMediator.Instance?.EnqueueToUpdateQueue(() =>
            {
                var package = new SyncTransformsPackage(mTemplate.HeadBytes);
                package.Op  = SyncTransformsPackage.EOperate.Push;

                for (int i = 0, iMax = transformsList.Count; i < iMax; i++)
                {
                    var transformMono = transformsList[i];
                    if (!transformMono.isSelfControl && !isFetchAll)
                    {
                        continue;
                    }

                    var transformInfo = new SyncTransformData();

                    transformInfo.NetworkID = transformMono.networkID;
                    transformInfo.Pos_X     = transformMono.transform.position.x;
                    transformInfo.Pos_Y     = transformMono.transform.position.y;
                    transformInfo.Pos_Z     = transformMono.transform.position.z;
                    transformInfo.Euler_X   = transformMono.transform.eulerAngles.x;
                    transformInfo.Euler_Y   = transformMono.transform.eulerAngles.y;
                    transformInfo.Euler_Z   = transformMono.transform.eulerAngles.z;
                    transformInfo.SCALE_X   = transformMono.transform.localScale.x;
                    transformInfo.SCALE_Y   = transformMono.transform.localScale.y;
                    transformInfo.SCALE_Z   = transformMono.transform.localScale.z;

                    package.TransformList.Add(transformInfo);
                }

                var transformPackageBytes = package.Serialize();
                udpBox.SendMessage(transformPackageBytes, ipEndPoint);
            });
        }