public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { //是否监控enable状态 if (getObservedState(1)) { _renderer.enabled = BufferedNetworkUtilsClient.ReadBool(ref state); } //是否监控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]) { DeserializeOnePara(attrList[i].propertyType[j], _renderer.materials[i], attrList[i].propertyName[j], ref state); } } } } #if UNITY_EDITOR if (BufferedNetworkUtilsClient.ReadString(ref state) != "RenderObserverFlag") { Debug.LogError("Wrong end"); } #endif }
public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { _operationList.Clear(); int opCount = BufferedNetworkUtilsClient.ReadInt(ref state); for (int i = 0; i < opCount; ++i) { FduParticleSystemOP.Operation operationType = (FduParticleSystemOP.Operation)BufferedNetworkUtilsClient.ReadByte(ref state); int paraCount = BufferedNetworkUtilsClient.ReadInt(ref state); FduParticleSystemOP op = new FduParticleSystemOP(); op.operation = operationType; if (paraCount > 0) { op.paras = new object[paraCount]; } for (int j = 0; j < paraCount; ++j) { op.paras[j] = FduSupportClass.deserializeOneParameter(ref state); } _operationList.Add(op); } //反序列化结束 执行每一项粒子系统的操作 foreach (FduParticleSystemOP op in _operationList) { op.executeOpOnSlave(particleSys); } _operationList.Clear(); }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; levelName = BufferedNetworkUtilsClient.ReadString(ref state); FduClusterLevelLoader.Instance._slaveStartLoadScene(levelName); return(state); }
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); }
public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { #if !UNSAFE_MODE byte[] temp = BufferedNetworkUtilsClient.ReadByteArray(ref state); _bitArray = new BitArray(temp); #endif switchCaseFunc(FduMultiAttributeObserverOP.Receive_Direct, ref state); }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; deserializeParameters(ref state); FduRpcManager.Instance.executeRpc(_rpcData); _rpcData.Clear(); return(state); }
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() { if (this == null) //由于跨场景时 在新的view 没有在start中完成注册之前 旧的view会接收数据 { return(NetworkState.NETWORK_STATE_TYPE.SUCCESS); } if (ViewId == FduSyncBaseIDManager.getInvalidSyncId()) { return(NetworkState.NETWORK_STATE_TYPE.SUCCESS); } UnityEngine.Profiling.Profiler.BeginSample("OnReceiveData"); NetworkState.NETWORK_STATE_TYPE networkState = NetworkState.NETWORK_STATE_TYPE.SUCCESS; FduObserverBase observer = null; for (index = 0; index < observerList.Count; ++index) { try { observer = observerList[index]; #if !UNSAFE_MODE if (observer != null) { bool receiveOrNot = BufferedNetworkUtilsClient.ReadBool(ref networkState); if (receiveOrNot) { observer.OnReceiveData(ref networkState); FduClusterViewManager.updateSentDataObserverCount(); } } #else if (observer.getDataTransmitStrategy().receiveOrNot()) { observer.OnReceiveData(ref networkState); #if DEBUG FduClusterViewManager.updateSentDataObserverCount(); #endif } #endif } catch (System.NullReferenceException) { } catch (System.Exception e) { string erroMessage = string.Format("An error occured when observer {0} call OnReceiveDataMethod. 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; } if (networkState == NetworkState.NETWORK_STATE_TYPE.FORMAT_ERROR) { Debug.LogError("Data length not match in this observer! Observer name" + observer.GetType().FullName + " View id " + ViewId + " Game Object name " + observer.gameObject.name); } } UnityEngine.Profiling.Profiler.EndSample(); return(networkState); }
public override void AlwaysUpdate() { base.AlwaysUpdate(); if (!getInterpolationState() || FduSupportClass.isMaster) { return; //标志位为真且为从节点才进行插值 } NetworkState.NETWORK_STATE_TYPE stateTemp = NetworkState.NETWORK_STATE_TYPE.SUCCESS; switchCaseFunc(FduMultiAttributeObserverOP.Update, ref stateTemp); }
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]); } }
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); }
internal void DeserializeParameterData(ref NetworkState.NETWORK_STATE_TYPE state) { _CommandName = BufferedNetworkUtilsClient.ReadString(ref state); //Name of Command int parameterCount = BufferedNetworkUtilsClient.ReadInt(ref state); //Count of Command parameters for (int j = 0; j < parameterCount; ++j) { string paraName = BufferedNetworkUtilsClient.ReadString(ref state); //Name of parameter object para = FduSupportClass.deserializeOneParameter(ref state); //Value of parameter addParameter(paraName, para); } }
public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { CustomClassDataInstance = (CustomClassData)BufferedNetworkUtilsClient.ReadSerializableClass(ref state); IntInstance = BufferedNetworkUtilsClient.ReadInt(ref state); Vector3Instance = BufferedNetworkUtilsClient.ReadVector3(ref state); StringInstance = BufferedNetworkUtilsClient.ReadString(ref state); CustomDataInstance = (CustomStructData)BufferedNetworkUtilsClient.ReadStruct(typeof(CustomStructData), ref state); ListData = BufferedNetworkUtilsClient.ReadList <InsideCustomData>(ref state); DicData = BufferedNetworkUtilsClient.ReadDic <string, Vector3>(ref state); }
public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { processPlayState(BufferedNetworkUtilsClient.ReadByte(ref state)); particleSys.time = BufferedNetworkUtilsClient.ReadFloat(ref state); if (isUsingRandomSeed) { uint seed = (uint)BufferedNetworkUtilsClient.ReadInt(ref state); if (particleSys.randomSeed != seed) { if (!particleSys.isPlaying) { particleSys.randomSeed = seed; } } } }
public override void OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { bool interFlag = false; if (dataTransmitStrategy.getCustomData(FduDTSCustomDataType.EveryNFrame_CurFrameCount) != null && _interpolationState) { interFlag = true; } if (!interFlag) { switchCaseFunc(FduMultiAttributeObserverOP.Receive_Direct, ref state); } else { switchCaseFunc(FduMultiAttributeObserverOP.Receive_Interpolation, ref state); } }
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); } } } }
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 OnReceiveData(ref NetworkState.NETWORK_STATE_TYPE state) { //如果需要插值 则缓存数据 否则直接赋值 bool interFlag = false; if (dataTransmitStrategy.getCustomData(FduDTSCustomDataType.EveryNFrame_CurFrameCount) != null && getInterpolationState()) { interFlag = true; } #if !UNSAFE_MODE observedState = new System.Collections.Specialized.BitVector32(BufferedNetworkUtilsClient.ReadInt(ref state)); #endif if (!interFlag) { switchCaseFunc(FduMultiAttributeObserverOP.Receive_Direct, ref state); } else { switchCaseFunc(FduMultiAttributeObserverOP.Receive_Interpolation, ref state); } }
//接收到rpc事件中的数据 反序列化为可用的事件实例 void deserializeParameters(ref NetworkState.NETWORK_STATE_TYPE state) { _rpcData.Clear(); _rpcData.Add((byte)0, BufferedNetworkUtilsClient.ReadInt(ref state)); _rpcData.Add((byte)1, BufferedNetworkUtilsClient.ReadString(ref state)); int paraCount = BufferedNetworkUtilsClient.ReadInt(ref state); _rpcData.Add((byte)2, paraCount); object[] parameters = new object[paraCount]; try { for (int i = 0; i < paraCount; ++i) { object ob = FduSupportClass.deserializeOneParameter(ref state); parameters[i] = ob; } } catch (InvalidSendableDataException e) { Debug.LogError(e.Message); return; } _rpcData.Add((byte)3, (object[])parameters); }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; clearClusterCommands(); int CommandCount = BufferedNetworkUtilsClient.ReadInt(ref state); //total number of cluster Commands try { for (int i = 0; i < CommandCount; ++i) { ClusterCommand newCommand = new ClusterCommand("1"); newCommand.DeserializeParameterData(ref state); newCommand.DeserializeGenericData(ref state); _clusterCommandWatingList.Add(newCommand); } ClusterCommandStatisticClass.instance.RefreshData(); FduClusterCommandDispatcher.NotifyDispatch(); } catch (InvalidSendableDataException e) { Debug.LogError(e.Message); } return(state); }
public override void OnSendData() { NetworkState.NETWORK_STATE_TYPE stateTemp = NetworkState.NETWORK_STATE_TYPE.SUCCESS; switchCaseFunc(FduMultiAttributeObserverOP.SendData, ref stateTemp); triggerCacheList.Clear(); }
//解析需要创建和销毁的数据 并通知对应类完成创建和销毁工作 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); }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; receiveState = (Random.State)BufferedNetworkUtilsClient.ReadStruct(typeof(Random.State), ref state); return(state); }
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 < 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; } } }
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)); } } } } }
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; } } }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; _bitArr = new BitVector32(BufferedNetworkUtilsClient.ReadInt(ref state)); for (int i = 1; i < 30; ++i) { if (!_bitArr[FduGlobalConfig.BIT_MASK[i]]) { continue; } switch (i) { case 1: //deltaTime _timeDataMap["deltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 2: //unscaledDeltaTime _timeDataMap["unscaledDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 3: //time _timeDataMap["time"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 4: //unscaledTime _timeDataMap["unscaledTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 5: //fixedTime _timeDataMap["fixedTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 6: //fixedUnscaledTime _timeDataMap["fixedUnscaledTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 7: //fixedDeltaTime _timeDataMap["fixedDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); if (_timeDataMap["fixedDeltaTime"]._setValue != Time.fixedDeltaTime) { Time.fixedDeltaTime = _timeDataMap["fixedDeltaTime"]._setValue; } break; case 8: //fixedUnscaledDeltaTime _timeDataMap["fixedUnscaledDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 9: //smoothDeltaTime _timeDataMap["smoothDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 10: //timeSinceLevelLoad _timeDataMap["timeSinceLevelLoad"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 11: //timeScale _timeDataMap["timeScale"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); if (_timeDataMap["timeScale"]._setValue != Time.timeScale) { Time.timeScale = _timeDataMap["timeScale"]._setValue; } break; case 12: //captureFramerate _timeDataMap["captureFramerate"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); if ((int)_timeDataMap["captureFramerate"]._setValue != Time.captureFramerate) { Time.captureFramerate = (int)_timeDataMap["captureFramerate"]._setValue; } break; case 13: //renderedFrameCount _timeDataMap["renderedFrameCount"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); break; case 14: //maximumDeltaTime _timeDataMap["maximumDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); if (_timeDataMap["maximumDeltaTime"]._setValue != Time.maximumDeltaTime) { Time.maximumDeltaTime = _timeDataMap["maximumDeltaTime"]._setValue; } break; case 15: //maximumParticleDeltaTime _timeDataMap["maximumParticleDeltaTime"].setValue(BufferedNetworkUtilsClient.ReadFloat(ref state)); if (_timeDataMap["maximumParticleDeltaTime"]._setValue != Time.maximumParticleDeltaTime) { Time.maximumParticleDeltaTime = _timeDataMap["maximumParticleDeltaTime"]._setValue; } break; } } //string end = BufferedNetworkUtilsClient.ReadString(ref state); //if (end != "FduClusterTimeEndFlag") //{ // Debug.LogError("Wrong end of Cluseter Time!"); //} //StartCoroutine(SwapCo()); return(state); }
public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; //active部分数据 int count = BufferedNetworkUtilsClient.ReadInt(ref state); int viewId, obCount; FduClusterView view; int obId, obFrameCount; for (int i = 0; i < count; ++i) { viewId = BufferedNetworkUtilsClient.ReadInt(ref state); obCount = BufferedNetworkUtilsClient.ReadInt(ref state); view = FduClusterViewManager.getClusterView(viewId); if (view != null) { try { for (int j = 0; j < obCount; ++j) { obId = BufferedNetworkUtilsClient.ReadInt(ref state); obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); view.setFrameCountForEveryNFrameDTS(obId, obFrameCount); } view.gameObject.SetActive(true); } catch (System.Exception e) { Debug.LogError(e.Message); } } else { //view是空的也要读完 for (int j = 0; j < obCount; ++j) { obId = BufferedNetworkUtilsClient.ReadInt(ref state); obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); } Debug.LogWarning("[FduActiveSyncManager-active]Can not find a view with ViewId " + viewId); } } //Inactive部分数据 count = BufferedNetworkUtilsClient.ReadInt(ref state); for (int i = 0; i < count; ++i) { viewId = BufferedNetworkUtilsClient.ReadInt(ref state); obCount = BufferedNetworkUtilsClient.ReadInt(ref state); view = FduClusterViewManager.getClusterView(viewId); if (view != null) { try { for (int j = 0; j < obCount; ++j) { obId = BufferedNetworkUtilsClient.ReadInt(ref state); obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); view.setFrameCountForEveryNFrameDTS(obId, obFrameCount); } view.gameObject.SetActive(false); } catch (System.Exception e) { Debug.LogError(e.Message); } } else { //view是空的也要读完 for (int j = 0; j < obCount; ++j) { obId = BufferedNetworkUtilsClient.ReadInt(ref state); obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); } Debug.LogWarning("[FduActiveSyncManager-Inactive]Can not find a view with ViewId " + viewId); } } if (BufferedNetworkUtilsClient.ReadString(ref state) != "FduActieSyncManagerEndFlag") { Debug.LogError("Wrong end of FduActiveSyncManager!"); } return(state); }
internal void DeserializeGenericData(ref NetworkState.NETWORK_STATE_TYPE state) { int genCount = BufferedNetworkUtilsClient.ReadInt(ref state); for (int i = 0; i < genCount; ++i) { string genName = BufferedNetworkUtilsClient.ReadString(ref state); string keyTypeName = BufferedNetworkUtilsClient.ReadString(ref state); string valueTypeName = BufferedNetworkUtilsClient.ReadString(ref state); string containerTypeName = BufferedNetworkUtilsClient.ReadString(ref state); System.Type valueType = System.Type.GetType(valueTypeName); System.Type keyType = System.Type.GetType(keyTypeName); genericData _data = new genericData(); _data.valueTypeName = valueTypeName; _data.containerTypeName = containerTypeName; int valueCount = BufferedNetworkUtilsClient.ReadInt(ref state); bool isStringK = false; bool isStringV = false; if (valueType != null && valueType.Equals(typeof(string))) { isStringV = true; } if (keyType != null && keyType.Equals(typeof(string))) { isStringK = true; } if (_data.containerTypeName == "dic") { for (int j = 0; j < valueCount; j = j + 2) { if (isStringK) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadString(ref state)); } else if (keyType.IsEnum) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadInt(ref state)); } else { _data.valueData.Add(BufferedNetworkUtilsClient.ReadStruct(keyType, ref state)); } if (isStringV) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadString(ref state)); } else if (valueType.IsEnum) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadInt(ref state)); } else { _data.valueData.Add(BufferedNetworkUtilsClient.ReadStruct(valueType, ref state)); } } } else if (_data.containerTypeName == "queue" || _data.containerTypeName == "list" || _data.containerTypeName == "stack") { for (int j = 0; j < valueCount; ++j) { if (isStringV) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadString(ref state)); } else if (valueType.IsEnum) { _data.valueData.Add(BufferedNetworkUtilsClient.ReadInt(ref state)); } else { _data.valueData.Add(BufferedNetworkUtilsClient.ReadStruct(valueType, ref state)); } } } _genericMap.Add(genName, _data); } }