public override void OnSendData()
        {
#if !UNSAFE_MODE
            BufferedNetworkUtilsServer.SendInt(observedState.Data);
#endif
            switchCaseFunc(FduMultiAttributeObserverOP.SendData, ref stateTemp);
        }
        public override void OnSendData()
        {
            //是否监控enable状态
            if (getObservedState(1))
            {
                BufferedNetworkUtilsServer.SendBool(_renderer.enabled);
            }
            //是否监控shader状态
            if (getObservedState(2))
            {
                if (!invalideCheck)
                {
                    return;
                }
                for (int i = 0; i < attrList.Count; ++i)
                {
                    for (int j = 0; j < attrList[i].propertyType.Count; ++j)
                    {
                        if (bitArrList[i][j])
                        {
                            SerializeOnePara(attrList[i].propertyType[j], _renderer.materials[i], attrList[i].propertyName[j]);
                        }
                    }
                }
            }
#if UNITY_EDITOR
            BufferedNetworkUtilsServer.SendString("RenderObserverFlag");
#endif
        }
示例#3
0
        public override void Serialize()
        {
            BufferedNetworkUtilsServer.SendInt(_sendList.Count);
            foreach (SerializeData data in _sendList)
            {
                BufferedNetworkUtilsServer.SendString(data.name);
                BufferedNetworkUtilsServer.SendByte((byte)data.type);
                switch (data.type)
                {
                case FduClusterInputType.Axis:
                    BufferedNetworkUtilsServer.SendFloat(_axisMap[data.name]._setValue);
                    break;

                case FduClusterInputType.Button:
                    BufferedNetworkUtilsServer.SendBool(_buttonMap[data.name]._setValue);
                    break;

                case FduClusterInputType.Tracker:
                    BufferedNetworkUtilsServer.SendVector3(_trackerMap[data.name]._setPosValue);
                    BufferedNetworkUtilsServer.SendQuaternion(_trackerMap[data.name]._setRotValue);
                    break;
                }
            }
            //BufferedNetworkUtilsServer.SendString("ClusterInputMgrEndFlag");
            _sendList.Clear();
        }
 //将数据序列化发送出去
 public override void Serialize()
 {
     BufferedNetworkUtilsServer.SendInt(_WaitForActiveList.Count);
     foreach (ActiveSynPara para in _WaitForActiveList)
     {
         BufferedNetworkUtilsServer.SendInt(para.viewId);
         BufferedNetworkUtilsServer.SendInt(para.obFrameCount.Count);
         foreach (KeyValuePair <int, int> kvp in para.obFrameCount)
         {
             BufferedNetworkUtilsServer.SendInt(kvp.Key);
             BufferedNetworkUtilsServer.SendInt(kvp.Value);
         }
     }
     BufferedNetworkUtilsServer.SendInt(_WaitForInActiveList.Count);
     foreach (ActiveSynPara para in _WaitForInActiveList)
     {
         BufferedNetworkUtilsServer.SendInt(para.viewId);
         BufferedNetworkUtilsServer.SendInt(para.obFrameCount.Count);
         foreach (KeyValuePair <int, int> kvp in para.obFrameCount)
         {
             BufferedNetworkUtilsServer.SendInt(kvp.Key);
             BufferedNetworkUtilsServer.SendInt(kvp.Value);
         }
     }
     BufferedNetworkUtilsServer.SendString("FduActieSyncManagerEndFlag");
     _WaitForActiveList.Clear();
     _WaitForInActiveList.Clear();
 }
示例#5
0
        public override void OnSendData()
        {
#if !UNSAFE_MODE
            BufferedNetworkUtilsServer.SendInt(observedState.Data);
#endif
            NetworkState.NETWORK_STATE_TYPE stateTemp = NetworkState.NETWORK_STATE_TYPE.SUCCESS;
            switchCaseFunc(FduMultiAttributeObserverOP.SendData, ref stateTemp);
        }
        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 void OnSendData()
 {
     BufferedNetworkUtilsServer.SendByte(playState2Byte(particleSys.isPlaying, particleSys.isPaused, particleSys.isStopped, particleSys.isEmitting));
     BufferedNetworkUtilsServer.SendFloat(particleSys.time);
     if (isUsingRandomSeed)
     {
         BufferedNetworkUtilsServer.SendInt((int)particleSys.randomSeed);
     }
 }
示例#8
0
    public override void OnSendData()
    {
        BufferedNetworkUtilsServer.SendVector3(RVO.Simulator.Instance.agents_[index].position_v3);
        BufferedNetworkUtilsServer.SendQuaternion(RVO.Simulator.Instance.agents_[index].rotation);

        if ((FrameCounter.frameCount) % FrameCounter.interval == 0)
        {
            BufferedNetworkUtilsServer.SendVector4(gsc._tempFramePixelSegmentation);
        }
    }
        public override void OnSendData()
        {
            NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS;

#if !UNSAFE_MODE
            byte [] temp = new byte[_bitArray.Length / 8 + 1];
            _bitArray.CopyTo(temp, 0);
            BufferedNetworkUtilsServer.SendByteArray(temp);
#endif
            switchCaseFunc(FduMultiAttributeObserverOP.SendData, ref state);
        }
示例#10
0
 internal void SerializeParameterData()
 {
     Dictionary <string, object> .Enumerator enumerator = _paraMap.GetEnumerator();
     BufferedNetworkUtilsServer.SendString(_CommandName); //Name of Command
     BufferedNetworkUtilsServer.SendInt(_paraMap.Count);  //Count of Command parameters
     while (enumerator.MoveNext())
     {
         BufferedNetworkUtilsServer.SendString(enumerator.Current.Key);   //parameter name
         FduSupportClass.serializeOneParameter(enumerator.Current.Value); //parameter value
     }
 }
 public virtual void Serialize()
 {
     if (_mouseState != null)
     {
         _mouseState.buttonStateList.ForEach(buttonState_ =>
         {
             BufferedNetworkUtilsServer.SendInt((int)buttonState_.button);
             BufferedNetworkUtilsServer.SendVector2(buttonState_.position);
             BufferedNetworkUtilsServer.SendVector2(buttonState_.delta);
             BufferedNetworkUtilsServer.SendVector2(buttonState_.scrollDelta);
             BufferedNetworkUtilsServer.SendInt((int)buttonState_.buttonState);
         });
     }
 }
示例#12
0
        public override void Serialize()
        {
            if (ViewId == FduSyncBaseIDManager.getInvalidSyncId())
            {
                return;
            }
            FduObserverBase observer = null;

            for (index = 0; index < observerList.Count; ++index)
            {
                try
                {
                    observer = observerList[index];
#if !UNSAFE_MODE
                    if (observer != null)
                    {
                        bool send = false;
                        if (observer.getDataTransmitStrategy() != null)
                        {
                            send = observer.getDataTransmitStrategy().sendOrNot();
                        }

                        BufferedNetworkUtilsServer.SendBool(send);
                        if (send)
                        {
                            FduClusterViewManager.updateSentDataObserverCount();
                            observer.OnSendData();
                        }
                    }
#else
                    if (observer.getDataTransmitStrategy().sendOrNot())
                    {
#if DEBUG
                        FduClusterViewManager.updateSentDataObserverCount();
#endif
                        observer.OnSendData();
                    }
#endif
                }
                catch (System.NullReferenceException) { }
                catch (System.Exception e)
                {
                    string erroMessage = string.Format("An error occured when observer {0} call OnSendData  method. Game Object Name:{1},View Id:{2}, Error Message:{3}, Stack Trace:{4}", observer.GetType().Name, observer.name, ViewId, e.Message, e.StackTrace);
                    Debug.LogError(erroMessage);
                    throw;
                }
            }
        }
    public override void OnSendData()
    {
        BufferedNetworkUtilsServer.SendSerializableClass(CustomClassDataInstance);

        BufferedNetworkUtilsServer.SendInt(IntInstance);

        BufferedNetworkUtilsServer.SendVector3(Vector3Instance);

        BufferedNetworkUtilsServer.SendString(StringInstance);

        BufferedNetworkUtilsServer.SendStruct(CustomDataInstance);

        BufferedNetworkUtilsServer.SendList <InsideCustomData>(ListData);

        BufferedNetworkUtilsServer.SendDic <string, Vector3>(DicData);
    }
        void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state)
        {
            if (_ObservedComponent == null || _props == null)
            {
                return;
            }

            for (int i = 0; i < _bitArray.Length; ++i)
            {
                if (!_bitArray[i])
                {
                    continue;
                }
                if (op == FduMultiAttributeObserverOP.SendData)
                {
                    if (_props[i].PropertyType.IsEnum)
                    {
                        BufferedNetworkUtilsServer.SendInt(System.Convert.ToInt32(_props[i].GetValue(_ObservedComponent, null)));
                    }
                    else if (_props[i].PropertyType.Equals(typeof(string)))
                    {
                        BufferedNetworkUtilsServer.SendString((string)_props[i].GetValue(_ObservedComponent, null));
                    }
                    else
                    {
                        BufferedNetworkUtilsServer.SendStruct(_props[i].GetValue(_ObservedComponent, null));
                    }
                }
                else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                {
                    if (_props[i].PropertyType.IsEnum)
                    {
                        _props[i].SetValue(_ObservedComponent, BufferedNetworkUtilsClient.ReadInt(ref state), null);
                    }
                    else if (_props[i].PropertyType.Equals(typeof(string)))
                    {
                        _props[i].SetValue(_ObservedComponent, BufferedNetworkUtilsClient.ReadString(ref state), null);
                    }
                    else
                    {
                        _props[i].SetValue(_ObservedComponent, BufferedNetworkUtilsClient.ReadStruct(_props[i].PropertyType, ref state), null);
                    }
                }
            }
        }
示例#15
0
        //将rpc事件中的各项参数都序列化发出去
        void serializeParameters()
        {
            BufferedNetworkUtilsServer.SendInt((int)_rpcData[(byte)0]);
            BufferedNetworkUtilsServer.SendString((string)_rpcData[(byte)1]);
            int paraCount = ((int)_rpcData[(byte)2]);

            BufferedNetworkUtilsServer.SendInt(paraCount);
            object[] parameters = (object[])_rpcData[(byte)3];
            try
            {
                for (int i = 0; i < paraCount; ++i)
                {
                    FduSupportClass.serializeOneParameter(parameters[i]);
                }
            }
            catch (InvalidSendableDataException e)
            {
                Debug.LogError(e.Message);
            }
        }
示例#16
0
 public override void OnSendData()
 {
     BufferedNetworkUtilsServer.SendInt(_operationList.Count);
     foreach (FduParticleSystemOP op in _operationList)
     {
         BufferedNetworkUtilsServer.SendByte((byte)op.operation);
         if (op.paras != null)
         {
             BufferedNetworkUtilsServer.SendInt(op.paras.Length);
             for (int i = 0; i < op.paras.Length; ++i)
             {
                 FduSupportClass.serializeOneParameter(op.paras[i]);
             }
         }
         else
         {
             BufferedNetworkUtilsServer.SendInt(0);
         }
     }
     _operationList.Clear();
 }
示例#17
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:    //Interactable
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(button.interactable);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        button.interactable = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 2:    //Transition
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)button.transition);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        button.transition = (Selectable.Transition)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 30:    //remove func
                    break;

                case 31:    //Interpolation Option
                    break;
                }
            }
        }
 public override void Serialize()
 {
     BufferedNetworkUtilsServer.SendInt(_clusterCommandWatingList.Count);//total number of cluster Commands
     try
     {
         foreach (ClusterCommand e in _clusterCommandWatingList)
         {
             e.SerializeParameterData();
             e.SerializeGenericData();
         }
         ClusterCommandStatisticClass.instance.RefreshData();
         FduClusterCommandDispatcher.NotifyDispatch();
     }
     catch (InvalidSendableDataException e)
     {
         Debug.LogError(e.Message);
     }
     finally
     {
         clearClusterCommands();
     }
 }
        void SerializeOnePara(byte propertyType, Material mat, string propertyName)
        {
            switch (propertyType)
            {
            case 0:    //Color
                BufferedNetworkUtilsServer.SendColor(mat.GetColor(propertyName));
                break;

            case 1:    //Vector
                BufferedNetworkUtilsServer.SendVector4(mat.GetVector(propertyName));
                break;

            case 2:    //Float
                BufferedNetworkUtilsServer.SendFloat(mat.GetFloat(propertyName));
                break;

            case 3:    //Range
                BufferedNetworkUtilsServer.SendFloat(mat.GetFloat(propertyName));
                break;

            case 4:    //TexEnv
                break;
            }
        }
        //发送待创建列表和待销毁列表中的数据
        public override void Serialize()
        {
            levelPrefix = levelPrefix == "" ? UnityEngine.SceneManagement.SceneManager.GetActiveScene().name : levelPrefix;
            BufferedNetworkUtilsServer.SendString(levelPrefix);
            BufferedNetworkUtilsServer.SendInt(_waitForCreateList.Count);
            //Debug.Log("Create Count:" + _waitForCreateList.Count);
            foreach (ClusterGameObjectCreatePara para in _waitForCreateList)
            {
                BufferedNetworkUtilsServer.SendInt(para.viewId);
                BufferedNetworkUtilsServer.SendInt(para.assetId);
                BufferedNetworkUtilsServer.SendVector3(para.position);
                BufferedNetworkUtilsServer.SendQuaternion(para.rotation);
                if (para.parentPath == null)
                {
                    BufferedNetworkUtilsServer.SendString("");
                }
                else
                {
                    BufferedNetworkUtilsServer.SendString(para.parentPath);
                }
                para.viewFrameCount = para.viewInstance.getAllFrameCountForEveryNFrameDTS();
                BufferedNetworkUtilsServer.SendInt(para.viewFrameCount.Count);
                foreach (KeyValuePair <int, int> kvp in para.viewFrameCount)
                {
                    BufferedNetworkUtilsServer.SendInt(kvp.Key);   //observer在view中的id
                    BufferedNetworkUtilsServer.SendInt(kvp.Value); //observer中EveryNFrameDTS所需要同步的参数frameCount
                }


                var subViews = para.viewInstance.getSubViews();
                BufferedNetworkUtilsServer.SendInt(subViews.Count);
                foreach (FduClusterView view in subViews)
                {
                    if (view == null)
                    {
                        Debug.LogError("Find Invalid sub view in one Cluster view.View id :" + view.ViewId + ". Please press Refresh Button of this view in Inspector window");
                        break;
                    }
                    BufferedNetworkUtilsServer.SendInt(view.ViewId);
                    var list = view.getAllFrameCountForEveryNFrameDTS();
                    BufferedNetworkUtilsServer.SendInt(list.Count);
                    foreach (KeyValuePair <int, int> kvp in list)
                    {
                        BufferedNetworkUtilsServer.SendInt(kvp.Key);   //observer在subview中的id
                        BufferedNetworkUtilsServer.SendInt(kvp.Value); //observer中EveryNFrameDTS所需要同步的参数frameCount
                    }
                }
            }
            BufferedNetworkUtilsServer.SendInt(_wairForDestoryList.Count);
            foreach (int viewId in _wairForDestoryList)
            {
                BufferedNetworkUtilsServer.SendInt(viewId);
            }
            BufferedNetworkUtilsServer.SendInt(_waitForAssignViewIdList.Count);
            foreach (SyncViewIdData data in _waitForAssignViewIdList)
            {
                BufferedNetworkUtilsServer.SendString(data.name);
                BufferedNetworkUtilsServer.SendInt(data.id);
            }
            BufferedNetworkUtilsServer.SendString("FduClusterViewManagerEndFlag");
            ClearListData();
        }
示例#21
0
        public override void Serialize()
        {
            BufferedNetworkUtilsServer.SendInt(_bitArr.Data);
            for (int i = 1; i < 30; ++i)
            {
                if (!_bitArr[FduGlobalConfig.BIT_MASK[i]])
                {
                    continue;
                }
                switch (i)
                {
                case 1:    //deltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["deltaTime"]._setValue);
                    break;

                case 2:    //unscaledDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["unscaledDeltaTime"]._setValue);
                    break;

                case 3:    //time
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["time"]._setValue);
                    break;

                case 4:    //unscaledTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["unscaledTime"]._setValue);
                    break;

                case 5:    //fixedTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["fixedTime"]._setValue);
                    break;

                case 6:    //fixedUnscaledTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["fixedUnscaledTime"]._setValue);
                    break;

                case 7:    //fixedDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["fixedDeltaTime"]._setValue);
                    break;

                case 8:    //fixedUnscaledDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["fixedUnscaledDeltaTime"]._setValue);
                    break;

                case 9:    //smoothDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["smoothDeltaTime"]._setValue);
                    break;

                case 10:    //timeSinceLevelLoad
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["timeSinceLevelLoad"]._setValue);
                    break;

                case 11:    //timeScale
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["timeScale"]._setValue);
                    break;

                case 12:    //captureFramerate
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["captureFramerate"]._setValue);
                    break;

                case 13:    //renderedFrameCount
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["renderedFrameCount"]._setValue);
                    break;

                case 14:    //maximumDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["maximumDeltaTime"]._setValue);
                    break;

                case 15:    //maximumParticleDeltaTime
                    BufferedNetworkUtilsServer.SendFloat(_timeDataMap["maximumParticleDeltaTime"]._setValue);
                    break;
                }
            }
            //BufferedNetworkUtilsServer.SendString("FduClusterTimeEndFlag");
        }
示例#22
0
 void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state)
 {
     for (int i = 0; i < m_parameterList.Count; ++i)
     {
         FduAnimatorParameter para = m_parameterList[i];
         if (para.type == AnimatorControllerParameterType.Bool) //参数为布尔类型
         {
             if (op == FduMultiAttributeObserverOP.SendData)
             {
                 BufferedNetworkUtilsServer.SendBool(animator.GetBool(para.name));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
             {
                 animator.SetBool(para.name, BufferedNetworkUtilsClient.ReadBool(ref state));
             }
         }
         else if (para.type == AnimatorControllerParameterType.Trigger)//参数为trigger类型
         {
             if (op == FduMultiAttributeObserverOP.SendData)
             {
                 BufferedNetworkUtilsServer.SendBool(triggerCacheList.Contains(para.name));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Direct)
             {
                 animator.SetBool(para.name, BufferedNetworkUtilsClient.ReadBool(ref state));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
             {
                 bool triggerValue = BufferedNetworkUtilsClient.ReadBool(ref state);
                 if (triggerValue)
                 {
                     animator.SetTrigger(para.name);
                 }
                 else
                 {
                     animator.ResetTrigger(para.name);
                 }
             }
         }
         else if (para.type == AnimatorControllerParameterType.Int)//参数为int类型
         {
             if (op == FduMultiAttributeObserverOP.SendData)
             {
                 BufferedNetworkUtilsServer.SendInt(animator.GetInteger(para.name));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Direct)
             {
                 animator.SetInteger(para.name, BufferedNetworkUtilsClient.ReadInt(ref state));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
             {
                 setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadInt(ref state));
             }
             else if (op == FduMultiAttributeObserverOP.Update)
             {
                 if (getCachedProperytyCount(i) > 0)
                 {
                     animator.SetInteger(para.name, FduInterpolationInterface.getNextIntValue_new(animator.GetInteger(para.name), i, this));
                 }
             }
         }
         else if (para.type == AnimatorControllerParameterType.Float)//参数为float类型
         {
             if (op == FduMultiAttributeObserverOP.SendData)
             {
                 BufferedNetworkUtilsServer.SendFloat(animator.GetFloat(para.name));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Direct)
             {
                 animator.SetFloat(para.name, BufferedNetworkUtilsClient.ReadFloat(ref state));
             }
             else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
             {
                 setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
             }
             else if (op == FduMultiAttributeObserverOP.Update)
             {
                 if (getCachedProperytyCount(i) > 0)
                 {
                     animator.SetFloat(para.name, FduInterpolationInterface.getNextFloatValue_new(animator.GetFloat(para.name), i, this));
                 }
             }
         }
     }
 }
示例#23
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:    //MaxValue
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            slider.maxValue = FduInterpolationInterface.getNextFloatValue_new(slider.maxValue, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(slider.maxValue);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        slider.maxValue = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 2:    //CurrentValue
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            slider.value = FduInterpolationInterface.getNextFloatValue_new(slider.value, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(slider.value);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        slider.value = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 3:    //MinValue
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            slider.minValue = FduInterpolationInterface.getNextFloatValue_new(slider.minValue, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(slider.minValue);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        slider.minValue = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 4:    //Direction
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)slider.direction);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        slider.direction = (Slider.Direction)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 5:    //NormalizedValue
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            slider.normalizedValue = FduInterpolationInterface.getNextFloatValue_new(slider.normalizedValue, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(slider.normalizedValue);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        slider.normalizedValue = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 6:    //WholeNumbers
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(slider.wholeNumbers);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        slider.wholeNumbers = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;
                }
            }
        }
示例#24
0
 public override void Serialize()
 {
     BufferedNetworkUtilsServer.SendStruct(Random.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;
                }
            }
        }
        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:     //TextContent
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendString(text.text);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.text = BufferedNetworkUtilsClient.ReadString(ref state);
                    }
                    break;

                case 2:    //Color
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            text.color = FduInterpolationInterface.getNextColorValue_new(text.color, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendColor(text.color);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        text.color = BufferedNetworkUtilsClient.ReadColor(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadColor(ref state));
                    }
                    break;

                case 3:     //FontStyle
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)text.fontStyle);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.fontStyle = (FontStyle)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 4:    //FontSize
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            text.fontSize = FduInterpolationInterface.getNextIntValue_new(text.fontSize, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendInt(text.fontSize);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        text.fontSize = BufferedNetworkUtilsClient.ReadInt(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadInt(ref state));
                    }
                    break;

                case 5:    //LineSpacing
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            text.lineSpacing = FduInterpolationInterface.getNextFloatValue_new(text.lineSpacing, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(text.lineSpacing);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        text.lineSpacing = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 6:    //SupportRichText
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(text.supportRichText);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.supportRichText = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 7:    //Aligment
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)text.alignment);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.alignment = (TextAnchor)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 8:    //AlignByGeometry
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(text.alignByGeometry);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.alignByGeometry = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 9:    //HorizontalOverflow
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)text.horizontalOverflow);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.horizontalOverflow = (HorizontalWrapMode)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 10:    //VerticalOverflow
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)text.verticalOverflow);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.verticalOverflow = (VerticalWrapMode)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 11:    //BestFit
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(text.resizeTextForBestFit);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.resizeTextForBestFit = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 12:    //RaycastTarget
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(text.raycastTarget);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        text.raycastTarget = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 31:    //Interpolation Option
                    break;
                }
            }
        }
示例#27
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:    //Color
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            image.color = FduInterpolationInterface.getNextColorValue_new(image.color, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendColor(image.color);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        image.color = BufferedNetworkUtilsClient.ReadColor(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadColor(ref state));
                    }
                    break;

                case 2:    //RaycastTarget
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(image.raycastTarget);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        image.raycastTarget = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 3:    //FillMethod
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)image.fillMethod);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        image.fillMethod = (Image.FillMethod)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 4:    //FillAmount
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            image.fillAmount = FduInterpolationInterface.getNextFloatValue_new(image.fillAmount, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendFloat(image.fillAmount);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        image.fillAmount = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadFloat(ref state));
                    }
                    break;

                case 5:    //FillCenter
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(image.fillCenter);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        image.fillCenter = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 6:    //FillClockwise
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendBool(image.fillClockwise);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        image.fillClockwise = BufferedNetworkUtilsClient.ReadBool(ref state);
                    }
                    break;

                case 7:    //FillOrigin
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            image.fillOrigin = FduInterpolationInterface.getNextIntValue_new(image.fillOrigin, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendInt(image.fillOrigin);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        image.fillOrigin = BufferedNetworkUtilsClient.ReadInt(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadInt(ref state));
                    }
                    break;

                case 8:    //ImageType
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)image.type);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        image.type = (Image.Type)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 9:    //Image
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        bool changeFlag = false;
                        if (image.sprite != null && image.sprite.GetInstanceID() != spriteId)
                        {     //通过对比InstanceId判断该精灵是否被替换
                            changeFlag = true;
                            spriteId   = image.sprite.GetInstanceID();
                        }

                        BufferedNetworkUtilsServer.SendBool(changeFlag);
                        if (changeFlag)    //若已经变化了 则将图片分解为JPG格式传送至节点
                        {
                            byte[] arr;
                            try
                            {
                                arr = image.sprite.texture.EncodeToJPG();
                                BufferedNetworkUtilsServer.SendByteArray(arr);
                                BufferedNetworkUtilsServer.SendRect(image.sprite.textureRect);
                                BufferedNetworkUtilsServer.SendVector2(image.sprite.pivot);
                            }
                            catch (System.Exception e)
                            {
                                Debug.LogError(e.Message);
                            }
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)     //从节点先判断有没有图片传来 然后再解析
                    {
                        bool changeFlag = BufferedNetworkUtilsClient.ReadBool(ref state);
                        if (changeFlag)
                        {
                            byte[]    bytes   = BufferedNetworkUtilsClient.ReadByteArray(ref state);
                            Rect      rect    = BufferedNetworkUtilsClient.ReadRect(ref state);
                            Vector2   pivot   = BufferedNetworkUtilsClient.ReadVector2(ref state);
                            Texture2D texture = new Texture2D((int)GetComponent <RectTransform>().rect.width, (int)GetComponent <RectTransform>().rect.height);
                            texture.LoadImage(bytes);
                            image.sprite = Sprite.Create(texture, rect, pivot);
                        }
                    }
                    break;
                }
            }
        }
示例#28
0
 public override void Serialize()
 {
     BufferedNetworkUtilsServer.SendString(levelName);
 }
示例#29
0
        internal void SerializeGenericData()
        {
            var enu = _genericMap.GetEnumerator();

            BufferedNetworkUtilsServer.SendInt(_genericMap.Count);
            while (enu.MoveNext())
            {
                BufferedNetworkUtilsServer.SendString(enu.Current.Key);
                genericData _data = enu.Current.Value;
                BufferedNetworkUtilsServer.SendString(_data.keyTypeName);
                BufferedNetworkUtilsServer.SendString(_data.valueTypeName);
                BufferedNetworkUtilsServer.SendString(_data.containerTypeName);
                int count = _data.valueData.Count;
                BufferedNetworkUtilsServer.SendInt(count);

                bool        isStringK = false; bool isStringV = false;
                System.Type typeK = System.Type.GetType(_data.keyTypeName);
                System.Type typeV = System.Type.GetType(_data.valueTypeName);

                if (typeV != null && typeV.Equals(typeof(string)))
                {
                    isStringV = true;
                }
                if (typeK != null && typeK.Equals(typeof(string)))
                {
                    isStringK = true;
                }

                if (_data.containerTypeName == "dic")
                {
                    for (int i = 0; i < _data.valueData.Count; i = i + 2)
                    {
                        if (isStringK)
                        {
                            BufferedNetworkUtilsServer.SendString((string)_data.valueData[i]);
                        }
                        else if (typeK.IsEnum)
                        {
                            BufferedNetworkUtilsServer.SendInt(System.Convert.ToInt32(_data.valueData[i]));
                        }
                        else
                        {
                            BufferedNetworkUtilsServer.SendStruct(_data.valueData[i]);
                        }

                        if (isStringV)
                        {
                            BufferedNetworkUtilsServer.SendString((string)_data.valueData[i + 1]);
                        }
                        else if (typeV.IsEnum)
                        {
                            BufferedNetworkUtilsServer.SendInt(System.Convert.ToInt32(_data.valueData[i + 1]));
                        }
                        else
                        {
                            BufferedNetworkUtilsServer.SendStruct(_data.valueData[i + 1]);
                        }
                    }
                }
                else if (_data.containerTypeName == "queue" || _data.containerTypeName == "list" || _data.containerTypeName == "stack")
                {
                    for (int i = 0; i < _data.valueData.Count; ++i)
                    {
                        if (isStringV)
                        {
                            BufferedNetworkUtilsServer.SendString((string)_data.valueData[i]);
                        }
                        else if (typeV.IsEnum)
                        {
                            BufferedNetworkUtilsServer.SendInt(System.Convert.ToInt32(_data.valueData[i]));
                        }
                        else
                        {
                            BufferedNetworkUtilsServer.SendStruct(_data.valueData[i]);
                        }
                    }
                }
            }
        }
示例#30
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:     //InputContent
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendString(inputField.text);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.text = BufferedNetworkUtilsClient.ReadString(ref state);
                    }
                    break;

                case 2:    //CaretPosition
                    if (op == FduMultiAttributeObserverOP.Update)
                    {
                        if (getCachedProperytyCount(i) > 0)
                        {
                            inputField.caretPosition = FduInterpolationInterface.getNextIntValue_new(inputField.caretPosition, i, this);
                        }
                    }
                    else if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendInt(inputField.caretPosition);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct)
                    {
                        inputField.caretPosition = BufferedNetworkUtilsClient.ReadInt(ref state);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        setCachedProperty(i, BufferedNetworkUtilsClient.ReadInt(ref state));
                    }
                    break;

                case 3:    //CharacterValidation
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)inputField.characterValidation);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.characterValidation = (InputField.CharacterValidation)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 4:    //ContentType
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)inputField.contentType);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.contentType = (InputField.ContentType)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 5:    //InputType
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)inputField.inputType);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.inputType = (InputField.InputType)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 6:    //KeyboardType
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)inputField.keyboardType);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.keyboardType = (TouchScreenKeyboardType)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 7:    //LineType
                    if (op == FduMultiAttributeObserverOP.SendData)
                    {
                        BufferedNetworkUtilsServer.SendByte((byte)inputField.lineType);
                    }
                    else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation)
                    {
                        inputField.lineType = (InputField.LineType)BufferedNetworkUtilsClient.ReadByte(ref state);
                    }
                    break;

                case 29:    //Remove On Value Change CallBack On Slave
                    break;

                case 30:    //Remove On End Edit CallBack On Slave
                    break;

                case 31:    //Interpolation Option
                    break;
                }
            }
        }