Exemplo n.º 1
0
        void FetchSelfTransforms(List <SyncGOTransforms_TransformMono> transformsList, UDPBox udpBox, IPEndPoint ipEndPoint, bool isFetchAll = false)
        {
            UDPBox_GameThreadMediator.Instance?.EnqueueToUpdateQueue(() =>
            {
                var package = new SyncGOTransformsPackage(mTemplate.HeadBytes);
                package.Op  = SyncGOTransformsPackage.EOperate.Push;

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

                    var transformInfo = new SyncGOTransformData();

                    transformInfo.NetworkID = transformMono.networkID;
                    transformInfo.Active    = transformMono.gameObject.activeSelf;
                    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);
                }

                udpBox.SendMessage(package.Serialize(), ipEndPoint);
            });
        }
Exemplo n.º 2
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_boolList      = (Args[1] as PackageArgument_BoolList).Value;
            var arg_transformList = (Args[2] as PackageArgument_TransformList).Value;

            TransformList.Clear();
            for (int i = 0; i < arg_transformList.Count; i++)
            {
                var arg_transformInfo = arg_transformList[i];
                var item = new SyncGOTransformData();
                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);
            }

            for (int i = 0; i < arg_boolList.Count; i++)
            {
                var arg_boolInfo = arg_boolList[i];

                var temp = TransformList[i];
                temp.Active      = arg_boolInfo;
                TransformList[i] = temp;
            }

            return(result);
        }