void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state)
        {
            for (int i = 1; i < attributeList.Length; ++i)
            {
                if (!getObservedState(i))
                {
                    continue;
                }
                switch (i)
                {
                case 1:    //position
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.position);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.position = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        appendNewPos(BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 2:    //rotation
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendQuaternion(_transform.rotation);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        appendNewRotation(BufferedNetworkUtilsClient.ReadQuaternion(ref state));
                    }
                    break;

                case 3:    //scale
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.localScale);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        appendNewScale(BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;
                }
            }
        }
        //解析需要创建和销毁的数据 并通知对应类完成创建和销毁工作
        public override NetworkState.NETWORK_STATE_TYPE Deserialize()
        {
            NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS;
            string  sceneName = BufferedNetworkUtilsClient.ReadString(ref state);
            int     count = BufferedNetworkUtilsClient.ReadInt(ref state);
            int     viewId, assetId, subViewCount, viewObCount;
            Vector3 position; Quaternion rotation;
            string  path;

            for (int i = 0; i < count; i++)
            {
                viewId   = BufferedNetworkUtilsClient.ReadInt(ref state);
                assetId  = BufferedNetworkUtilsClient.ReadInt(ref state);
                position = BufferedNetworkUtilsClient.ReadVector3(ref state);
                rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                path     = BufferedNetworkUtilsClient.ReadString(ref state);
                ClusterGameObjectCreatePara para = new ClusterGameObjectCreatePara(viewId, assetId, position, rotation, path);

                viewObCount = BufferedNetworkUtilsClient.ReadInt(ref state);
                if (viewObCount > 0)
                {
                    para.viewFrameCount = new Dictionary <int, int>();
                    for (int j = 0; j < viewObCount; ++j)
                    {
                        int obId         = BufferedNetworkUtilsClient.ReadInt(ref state);
                        int obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state);
                        para.viewFrameCount.Add(obId, obFrameCount);
                    }
                }

                subViewCount = BufferedNetworkUtilsClient.ReadInt(ref state);
                if (subViewCount > 0)
                {
                    para.subViewId         = new List <int>();
                    para.subViewFrameCount = new List <Dictionary <int, int> >();
                }
                for (int j = 0; j < subViewCount; ++j)
                {
                    para.subViewId.Add(BufferedNetworkUtilsClient.ReadInt(ref state));
                    int obCount = BufferedNetworkUtilsClient.ReadInt(ref state);
                    para.subViewFrameCount.Add(new Dictionary <int, int>());

                    for (int k = 0; k < obCount; ++k)
                    {
                        var oneSubViewData = para.subViewFrameCount[para.subViewFrameCount.Count - 1];
                        var obId           = BufferedNetworkUtilsClient.ReadInt(ref state);
                        var obFrameCount   = BufferedNetworkUtilsClient.ReadInt(ref state);
                        oneSubViewData.Add(obId, obFrameCount);
                    }
                }
                _waitForCreateList.Add(para);
            }
            count = BufferedNetworkUtilsClient.ReadInt(ref state);
            for (int i = 0; i < count; ++i)
            {
                _wairForDestoryList.Add(BufferedNetworkUtilsClient.ReadInt(ref state));
            }
            count = BufferedNetworkUtilsClient.ReadInt(ref state);
            for (int i = 0; i < count; ++i)
            {
                SyncViewIdData data = new SyncViewIdData();
                data.name = BufferedNetworkUtilsClient.ReadString(ref state);
                data.id   = BufferedNetworkUtilsClient.ReadInt(ref state);
                _waitForAssignViewIdList.Add(data);
            }
            if (BufferedNetworkUtilsClient.ReadString(ref state) != "FduClusterViewManagerEndFlag")
            {
                Debug.LogError("Wrong end of FduClusterViewManagerEndFlag!");
            }
            if (sceneName == UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)
            {
                ProcessCreateRequest();
                ProcessDestoryRequest();
                ProcessAssignViewIdRequest();
            }
            ClearListData();
            return(state);
        }
예제 #3
0
    public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state)
    {
        _transform.SetPositionAndRotation(BufferedNetworkUtilsClient.ReadVector3(ref state), BufferedNetworkUtilsClient.ReadQuaternion(ref state));

        if ((FrameCounter.frameCount) % FrameCounter.interval == 0)
        {
            gsc.mpbs[0].SetVector(GPUSkinningPlayerResources.shaderPorpID_GPUSkinning_FrameIndex_PixelSegmentation, BufferedNetworkUtilsClient.ReadVector4(ref state));
            gsc.mrs[0].SetPropertyBlock(gsc.mpbs[0]);
        }
    }
예제 #4
0
        public override NetworkState.NETWORK_STATE_TYPE Deserialize()
        {
            NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS;
            int count = BufferedNetworkUtilsClient.ReadInt(ref state);

            for (int i = 0; i < count; ++i)
            {
                string name = BufferedNetworkUtilsClient.ReadString(ref state);
                FduClusterInputType type = (FduClusterInputType)BufferedNetworkUtilsClient.ReadByte(ref state);
                switch (type)
                {
                case FduClusterInputType.Axis:
                    float fvalue = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    if (!_axisMap.ContainsKey(name))
                    {
                        AxisData _data = new AxisData();
                        _data.reset();
                        _data.setValue(fvalue);
                        _axisMap.Add(name, _data);
                    }
                    else
                    {
                        _axisMap[name].setValue(fvalue);
                    }
                    break;

                case FduClusterInputType.Button:
                    bool bvalue = BufferedNetworkUtilsClient.ReadBool(ref state);
                    if (!_buttonMap.ContainsKey(name))
                    {
                        ButtonData _data = new ButtonData();
                        _data.reset();
                        _data.setValue(bvalue);
                        _buttonMap.Add(name, _data);
                    }
                    else
                    {
                        _buttonMap[name].setValue(bvalue);
                    }
                    break;

                case FduClusterInputType.Tracker:
                    Vector3    v3Value = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    Quaternion quValue = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    if (!_trackerMap.ContainsKey(name))
                    {
                        TrackerData _data = new TrackerData();
                        _data.reset();
                        _data.setPosValue(v3Value);
                        _data.setRotValue(quValue);
                        _trackerMap.Add(name, _data);
                    }
                    else
                    {
                        _trackerMap[name].setPosValue(v3Value);
                        _trackerMap[name].setRotValue(quValue);
                    }
                    break;
                }
            }
            //if(!BufferedNetworkUtilsClient.ReadString(ref state).Equals("ClusterInputMgrEndFlag"))
            //{
            //    Debug.LogError("Wrong end!");
            //}
            //StartCoroutine(swapValueCo());
            return(state);
        }
        void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state)
        {
            for (int i = 1; i < attributeList.Length; ++i)
            {
                if (!getObservedState(i)) //如果editor中没有选择监控该属性 则直接跳过
                {
                    continue;
                }

                switch (i)
                {
                case 1:    //position
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.position = FduInterpolationInterface.getNextVector3Value_new(_transform.position, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.position);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.position = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 2:    //rotation
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.rotation = FduInterpolationInterface.getNextQuaternionValue_new(_transform.rotation, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendQuaternion(_transform.rotation);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state));
                    }
                    break;

                case 3:    //scale
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.localScale = FduInterpolationInterface.getNextVector3Value_new(_transform.localScale, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.localScale);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 4:    //parent: 对于父节点的监控 这里只是一个不完全的解决方案 获取到父节点的路径 传输过去 然后在从节点解析。如果路径不唯一(因为可以同名)就会找不到对于的父节点
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        string parentPath;
                        if (_transform.parent == null)
                        {
                            parentPath = "";
                        }
                        else
                        {
                            parentPath = FduSupportClass.getGameObjectPath(_transform.parent.gameObject);
                        }

                        if (parentPath == null)
                        {
                            parentPath = "";
                        }
                        BufferedNetworkUtilsServer.SendString(parentPath);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        string parentPath;
                        if (_transform.parent == null)
                        {
                            parentPath = "";
                        }
                        else
                        {
                            parentPath = FduSupportClass.getGameObjectPath(_transform.parent.gameObject);
                        }

                        if (parentPath == null)
                        {
                            parentPath = "";
                        }
                        string getPath = BufferedNetworkUtilsClient.ReadString(ref state);
                        if (parentPath != getPath)     //hierarchy changed
                        {
                            GameObject go = FduSupportClass.getGameObjectByPath(getPath);
                            if (go == null)
                            {
                                _transform.SetParent(null);
                            }
                            else
                            {
                                _transform.SetParent(go.transform);
                            }
                        }
                    }
                    break;

                case 5:    //LocalPosition
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.localPosition = FduInterpolationInterface.getNextVector3Value_new(_transform.localPosition, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.localPosition);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localPosition = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 6:    //LocalRotation;
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.localRotation = FduInterpolationInterface.getNextQuaternionValue_new(_transform.localRotation, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendQuaternion(_transform.localRotation);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localRotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state));
                    }
                    break;

                case 7:    //LocalScale
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.localScale = FduInterpolationInterface.getNextVector3Value_new(_transform.localScale, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.localScale);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 8:    //EulerAngle
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.eulerAngles = FduInterpolationInterface.getNextVector3Value_new(_transform.eulerAngles, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.eulerAngles);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.eulerAngles = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 9:    //LocalEulerAngle
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            _transform.localEulerAngles = FduInterpolationInterface.getNextVector3Value_new(_transform.localEulerAngles, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(_transform.localEulerAngles);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        _transform.localEulerAngles = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                default:
                    break;
                }
            }
        }
예제 #6
0
        void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state)
        {
            for (int i = 1; i < attrList.Length; ++i)
            {
                if (!getObservedState(i))
                {
                    continue;
                }
                switch (i)
                {
                case 1:     //AnchoredPosition
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.anchoredPosition = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchoredPosition, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.anchoredPosition);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.anchoredPosition = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 2:    //AnchoredPosition3D
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.anchoredPosition3D = FduInterpolationInterface.getNextVector3Value_new(rectTransform.anchoredPosition3D, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(rectTransform.anchoredPosition3D);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.anchoredPosition3D = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 3:    //Rotation
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.rotation = FduInterpolationInterface.getNextQuaternionValue_new(rectTransform.rotation, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendQuaternion(rectTransform.rotation);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state));
                    }
                    break;

                case 4:    //Scale
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.localScale = FduInterpolationInterface.getNextVector3Value_new(rectTransform.localScale, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector3(rectTransform.localScale);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state));
                    }
                    break;

                case 5:    //Parent
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        string parentPath;
                        if (rectTransform.parent == null)
                        {
                            parentPath = "";
                        }
                        else
                        {
                            parentPath = FduSupportClass.getGameObjectPath(rectTransform.parent.gameObject);
                        }

                        if (parentPath == null)
                        {
                            parentPath = "";
                        }
                        BufferedNetworkUtilsServer.SendString(parentPath);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        string parentPath;
                        if (rectTransform.parent == null)
                        {
                            parentPath = "";
                        }
                        else
                        {
                            parentPath = FduSupportClass.getGameObjectPath(rectTransform.parent.gameObject);
                        }

                        if (parentPath == null)
                        {
                            parentPath = "";
                        }
                        string getPath = BufferedNetworkUtilsClient.ReadString(ref state);
                        if (parentPath != getPath)     //hierarchy changed
                        {
                            GameObject go = FduSupportClass.getGameObjectByPath(getPath);
                            if (go == null)
                            {
                                rectTransform.SetParent(null);
                            }
                            else
                            {
                                rectTransform.SetParent(go.transform);
                            }
                        }
                    }
                    break;

                case 6:    //AnchorMax
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.anchorMax = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchorMax, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.anchorMax);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.anchorMax = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 7:    //AnchorMin
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.anchorMin = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchorMin, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.anchorMin);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.anchorMin = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 8:    //OffsetMax
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.offsetMax = FduInterpolationInterface.getNextVector2Value_new(rectTransform.offsetMax, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.offsetMax);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.offsetMax = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 9:    //OffsetMin
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.offsetMin = FduInterpolationInterface.getNextVector2Value_new(rectTransform.offsetMin, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.offsetMin);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.offsetMin = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 10:    //Pivot
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.pivot = FduInterpolationInterface.getNextVector2Value_new(rectTransform.pivot, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.pivot);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.pivot = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;

                case 11:    //SizeDelta
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            rectTransform.sizeDelta = FduInterpolationInterface.getNextVector2Value_new(rectTransform.sizeDelta, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendVector2(rectTransform.sizeDelta);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        rectTransform.sizeDelta = BufferedNetworkUtilsClient.ReadVector2(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state));
                    }
                    break;
                }
            }
        }
예제 #7
0
        //反序列化一个可传输的参数
        public static object deserializeOneParameter(ref NetworkState.NETWORK_STATE_TYPE state)
        {
            FduSendableParameter typeCode = (FduSendableParameter)BufferedNetworkUtilsClient.ReadByte(ref state);
            object result;

            switch (typeCode)
            {
            case FduSendableParameter.Int:
                result = BufferedNetworkUtilsClient.ReadInt(ref state);
                break;

            case FduSendableParameter.IntArray:
                result = BufferedNetworkUtilsClient.ReadIntArray(ref state);
                break;

            case FduSendableParameter.Byte:
                result = BufferedNetworkUtilsClient.ReadByte(ref state);
                break;

            case FduSendableParameter.ByteArray:
                result = BufferedNetworkUtilsClient.ReadByteArray(ref state);
                break;

            case FduSendableParameter.Float:
                result = BufferedNetworkUtilsClient.ReadFloat(ref state);
                break;

            case FduSendableParameter.FloatArray:
                result = BufferedNetworkUtilsClient.ReadFloatArray(ref state);
                break;

            case FduSendableParameter.Bool:
                result = BufferedNetworkUtilsClient.ReadBool(ref state);
                break;

            case FduSendableParameter.BoolArray:
                int    bollen = BufferedNetworkUtilsClient.ReadInt(ref state);
                bool[] bolarr = new bool[bollen];
                for (int i = 0; i < bollen; ++i)
                {
                    bolarr[i] = BufferedNetworkUtilsClient.ReadBool(ref state);
                }
                result = bolarr;
                break;

            case FduSendableParameter.String:
                result = BufferedNetworkUtilsClient.ReadString(ref state);
                break;

            case FduSendableParameter.StringArray:

                int      strlen = BufferedNetworkUtilsClient.ReadInt(ref state);
                string[] strarr = new string[strlen];
                for (int i = 0; i < strlen; ++i)
                {
                    strarr[i] = BufferedNetworkUtilsClient.ReadString(ref state);
                }
                result = strarr;
                break;

            case FduSendableParameter.Vector2:
                result = BufferedNetworkUtilsClient.ReadVector2(ref state);
                break;

            case FduSendableParameter.Vector2Array:
                int       v2len = BufferedNetworkUtilsClient.ReadInt(ref state);
                Vector2[] v2arr = new Vector2[v2len];
                for (int i = 0; i < v2len; ++i)
                {
                    v2arr[i] = BufferedNetworkUtilsClient.ReadVector2(ref state);
                }
                result = v2arr;
                break;

            case FduSendableParameter.Vector3:
                result = BufferedNetworkUtilsClient.ReadVector3(ref state);
                break;

            case FduSendableParameter.Vector3Array:
                int       v3len = BufferedNetworkUtilsClient.ReadInt(ref state);
                Vector3[] v3arr = new Vector3[v3len];
                for (int i = 0; i < v3len; ++i)
                {
                    v3arr[i] = BufferedNetworkUtilsClient.ReadVector3(ref state);
                }
                result = v3arr;
                break;

            case FduSendableParameter.Vector4:
                result = BufferedNetworkUtilsClient.ReadVector4(ref state);
                break;

            case FduSendableParameter.Vector4Array:
                int       v4len = BufferedNetworkUtilsClient.ReadInt(ref state);
                Vector4[] v4arr = new Vector4[v4len];
                for (int i = 0; i < v4len; ++i)
                {
                    v4arr[i] = BufferedNetworkUtilsClient.ReadVector4(ref state);
                }
                result = v4arr;
                break;

            case FduSendableParameter.Color:
                result = BufferedNetworkUtilsClient.ReadColor(ref state);
                break;

            case FduSendableParameter.ColorArray:
                int     clen   = BufferedNetworkUtilsClient.ReadInt(ref state);
                Color[] carray = new Color[clen];
                for (int i = 0; i < clen; ++i)
                {
                    carray[i] = BufferedNetworkUtilsClient.ReadColor(ref state);
                }
                result = carray;
                break;

            case FduSendableParameter.Quaternion:
                result = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                break;

            case FduSendableParameter.QuaternionArray:
                int          qlen = BufferedNetworkUtilsClient.ReadInt(ref state);
                Quaternion[] qarr = new Quaternion[qlen];
                for (int i = 0; i < qlen; i++)
                {
                    qarr[i] = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                }
                result = qarr;
                break;

            case FduSendableParameter.Matrix4X4:
                result = BufferedNetworkUtilsClient.ReadMatrix4x4(ref state);
                break;

            case FduSendableParameter.Matrix4X4Array:
                int          matlen = BufferedNetworkUtilsClient.ReadInt(ref state);
                Matrix4x4 [] matArr = new Matrix4x4[matlen];
                for (int i = 0; i < matlen; ++i)
                {
                    matArr[i] = BufferedNetworkUtilsClient.ReadMatrix4x4(ref state);
                }
                result = matArr;
                break;

            case FduSendableParameter.Rect:
                result = BufferedNetworkUtilsClient.ReadRect(ref state);
                break;

            case FduSendableParameter.RectArray:
                int    rectlen = BufferedNetworkUtilsClient.ReadInt(ref state);
                Rect[] rectArr = new Rect[rectlen];
                for (int i = 0; i < rectlen; ++i)
                {
                    rectArr[i] = BufferedNetworkUtilsClient.ReadRect(ref state);
                }
                result = rectArr;
                break;

            case FduSendableParameter.GameObject:
                bool goType = BufferedNetworkUtilsClient.ReadBool(ref state);
                if (goType)     //有clusterview的物体
                {
                    var view = FduClusterViewManager.getClusterView(BufferedNetworkUtilsClient.ReadInt(ref state));
                    if (view != null)
                    {
                        result = view.gameObject;
                    }
                    else
                    {
                        result = null;
                    }
                }
                else     //有唯一路径的gameobject
                {
                    string path = BufferedNetworkUtilsClient.ReadString(ref state);
                    result = FduSupportClass.getGameObjectByPath(path);
                }
                break;

            case FduSendableParameter.ClusterView:
                result = FduClusterViewManager.getClusterView(BufferedNetworkUtilsClient.ReadInt(ref state));
                break;

            case FduSendableParameter.Struct:
                try
                {
                    string      typeName = BufferedNetworkUtilsClient.ReadString(ref state);
                    System.Type type     = System.Type.GetType(typeName);
                    result = BufferedNetworkUtilsClient.ReadStruct(type, ref state);
                }
                catch (System.Exception e) { Debug.LogError("Error occured in reading struct data. Details: " + e.Message); throw; }
                break;

            case FduSendableParameter.SerializableClass:
                result = BufferedNetworkUtilsClient.ReadSerializableClass(ref state);
                break;

            case FduSendableParameter.Enum:
                result = BufferedNetworkUtilsClient.ReadInt(ref state);
                break;

            default:
                throw new InvalidSendableDataException("Received unsendable data type, type code:" + typeCode);
            }
            return(result);
        }