public TarsStruct DirectRead(TarsStruct s, int tag, bool isRequire) { // TarsStruct must have a no-argument constructor. TarsStruct ref_s = null; if (SkipToTag(tag)) { try { ref_s = (TarsStruct)BasicClassTypeUtil.CreateObject(s.GetType()); } catch (Exception ex) { throw new TarsDecodeException(ex.Message); } HeadData head = new HeadData(); ReadHead(head); if (head.type != (byte)TarsStructType.STRUCT_BEGIN) { throw new TarsDecodeException("type mismatch."); } ref_s.ReadFrom(this); SkipToStructEnd(); } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(ref_s); }
/// <summary> /// 跳到指定的tag的数据之前 /// </summary> /// <param name="tag"></param> /// <returns></returns> public bool SkipToTag(int tag) { try { var hd = new HeadData(); while (true) { int len = PeakHead(hd); if (hd.Type == StructEnd) { return(false); } if (tag <= hd.Tag) { return(tag == hd.Tag); } Skip(len); SkipField(hd.Type); } } catch (IndexOutOfRangeException e) { } catch (TarsDecodeException e) { //QTrace.Trace(e.Message); } return(false); }
public void Send(HeadData sendData) { foreach (var fieldInfo in fieldInfos) { Debug.Log(fieldInfo.Name + fieldInfo.GetValue(sendData)); } }
public double Read(double n, int tag, bool isRequire) { if (SkipToTag(tag)) { var hd = new HeadData(); ReadHead(hd); switch (hd.Type) { case (byte)TarsStructType.ZeroTag: n = 0; break; case (byte)TarsStructType.Float: { n = buffer.ReadFloat(); } break; case (byte)TarsStructType.Double: { n = buffer.ReadDouble(); } break; default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(n); }
public byte Read(byte c, int tag, bool isRequire) { if (skipToTag(tag)) { HeadData hd = new HeadData(); readHead(hd); switch (hd.type) { case (byte)TarsStructType.ZERO_TAG: c = 0x0; break; case (byte)TarsStructType.BYTE: { c = br.ReadByte(); break; } default: { throw new TarsDecodeException("type mismatch."); } } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(c); }
/// <summary> /// 跳过一个字段 /// </summary> private void SkipField() { var hd = new HeadData(); ReadHead(hd); SkipField(hd.Type); }
public ushort Read(ushort n, int tag, bool isRequire) { if (SkipToTag(tag)) { var hd = new HeadData(); ReadHead(hd); switch (hd.Type) { case (byte)TarsStructType.ZeroTag: n = 0; break; case (byte)TarsStructType.Byte: { n = buffer.ReadByte(); break; } case (byte)TarsStructType.Short: { n = buffer.ReadUnsignedShort(); break; } default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(n); }
public TarsStruct DirectRead(TarsStruct o, int tag, bool isRequire) { //o必须有一个无参的构造函数 TarsStruct reff = null; if (SkipToTag(tag)) { try { reff = (TarsStruct)BasicClassTypeUtil.CreateObject(o.GetType()); } catch (Exception e) { throw new TarsDecodeException(e.Message); } var hd = new HeadData(); ReadHead(hd); if (hd.Type != (byte)TarsStructType.StructBegin) { throw new TarsDecodeException("type mismatch."); } reff.ReadFrom(this); SkipToStructEnd(); } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(reff); }
public string readString(int tag, bool isRequire) { string s = null; if (skipToTag(tag)) { HeadData hd = new HeadData(); readHead(hd); switch (hd.type) { case (byte)TarsStructType.STRING1: { s = readString1(); } break; case (byte)TarsStructType.STRING4: { s = readString4(); } break; default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(s); }
public float Read(float n, int tag, bool isRequire) { if (SkipToTag(tag)) { HeadData head = new HeadData(); ReadHead(head); switch (head.type) { case (byte)TarsStructType.ZERO_TAG: { n = 0; } break; case (byte)TarsStructType.FLOAT: { n = ByteConverter.ReverseEndian(reader.ReadSingle()); } break; default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(n); }
public string Read(string str, int tag, bool isRequire) { if (SkipToTag(tag)) { HeadData head = new HeadData(); ReadHead(head); switch (head.type) { case (byte)TarsStructType.STRING1: { str = ReadString1(); } break; case (byte)TarsStructType.STRING4: { str = ReadString4(); } break; default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(str); }
// // Skip a field. // private void SkipField() { HeadData head = new HeadData(); ReadHead(head); SkipField(head.type); }
public long[] Read(long[] l, int tag, bool isRequire) { long[] lr = null; if (skipToTag(tag)) { HeadData hd = new HeadData(); readHead(hd); switch (hd.type) { case (byte)TarsStructType.LIST: { int size = Read(0, 0, true); if (size < 0) { throw new TarsDecodeException("size invalid: " + size); } lr = new long[size]; for (int i = 0; i < size; ++i) { lr[i] = Read(lr[0], 0, true); } break; } default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(lr); }
public TarsStruct Read(TarsStruct s, int tag, bool isRequire) { // TarsStruct must have a no-argument constructor. TarsStruct ref_s = null; if (SkipToTag(tag)) { try { // Must be recreated, otherwise it will result in assignment on the same object, // which is caused by a reference to C#. ref_s = (TarsStruct)BasicClassTypeUtil.CreateObject(s.GetType()); } catch (Exception ex) { throw new TarsDecodeException(ex.Message); } HeadData head = new HeadData(); ReadHead(head); if (head.type != (byte)TarsStructType.STRUCT_BEGIN) { throw new TarsDecodeException("type mismatch."); } ref_s.ReadFrom(this); SkipToStructEnd(); } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(ref_s); }
void OnDrawGizmos() { //loop recordings foreach (ColoredRecording coloredRec in recordings) { Recording recording = coloredRec.recording; if (recording == null) { continue; } //draw colored recording HeadData lastHeadData = null; foreach (DataFrame frame in recording.DataFrames) { HeadData headData = frame.ParseFromJson <HeadData>(); //draw head Gizmos.color = coloredRec.color; headData.DebugDraw(radius, rayLength); //draw connection between heads if (lastHeadData != null) { SetGizmoAlpha(connectionAlpha); Gizmos.DrawLine(lastHeadData.worldPos, headData.worldPos); } lastHeadData = headData; } } }
/// <summary> /// 读取头信息,但不移动缓冲区的当前偏移 /// </summary> /// <param name="hd"></param> /// <returns></returns> private int PeakHead(HeadData hd) { int len = ReadHead(hd); Skip(-1 * len); return(len); }
// 跳过一个字段 private void skipField() { HeadData hd = new HeadData(); readHead(hd); skipField(hd.type); }
public ushort Read(ushort n, int tag, bool isRequire) { if (skipToTag(tag)) { HeadData hd = new HeadData(); readHead(hd); switch (hd.type) { case (byte)TarsStructType.ZERO_TAG: n = 0; break; case (byte)TarsStructType.BYTE: { n = br.ReadByte(); break; } case (byte)TarsStructType.SHORT: { n = ByteConverter.ReverseEndian(br.ReadUInt16()); break; } default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(n); }
public void Send(HeadData sendData) { foreach (var eyeDataAsObserver in eyeDataAsObserverList) { eyeDataAsObserver.OnNext(sendData); } }
public TarsStruct Read(TarsStruct o, int tag, bool isRequire) { //o必须有一个无参的构造函数 TarsStruct reff = null; if (skipToTag(tag)) { try { // 必须重新创建一个,否则,会导致在同一个对象上赋值,这是由于C#的引用引起的 reff = (TarsStruct)BasicClassTypeUtil.CreateObject(o.GetType()); } catch (Exception e) { throw new TarsDecodeException(e.Message); } HeadData hd = new HeadData(); readHead(hd); if (hd.type != (byte)TarsStructType.STRUCT_BEGIN) { throw new TarsDecodeException("type mismatch."); } reff.ReadFrom(this); skipToStructEnd(); } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(reff); }
public double Read(double n, int tag, bool isRequire) { if (skipToTag(tag)) { HeadData hd = new HeadData(); readHead(hd); switch (hd.type) { case (byte)TarsStructType.ZERO_TAG: n = 0; break; case (byte)TarsStructType.FLOAT: { n = ByteConverter.ReverseEndian(br.ReadSingle()); } break; case (byte)TarsStructType.DOUBLE: { n = ByteConverter.ReverseEndian(br.ReadDouble()); } break; default: throw new TarsDecodeException("type mismatch."); } } else if (isRequire) { throw new TarsDecodeException("require field not exist."); } return(n); }
// 读取头信息,但不移动缓冲区的当前偏移 private int peakHead(HeadData hd) { long curPos = ms.Position; int len = readHead(hd); ms.Position = curPos; return(len); }
protected override void ParseData(Dictionary <string, object> dic) { dic.TryGetValueWitheKey(out _Time, KeyTime); dic.TryGetValueWitheKey(out _Score, KeyScore); dic.TryGetValueWitheKey(out _WinerCount, KeyWinerCount); _headData = new HeadData(dic); }
private void UpdateHead() { headData = GameInstance.GetAvailableHead(SelectHead); if (characterModel != null && headData != null) { characterModel.SetHeadModel(headData.modelObject); } }
// // Read header information but not move the current offset of the buffer. // private int PeekHead(HeadData head) { long curPos = stream.Position; int len = ReadHead(head); stream.Position = curPos; return(len); }
void ParseHeadDatas(Dictionary <string, object> headDatas) { _headDatas.Clear(); foreach (var valuePair in headDatas) { var headData = new HeadData(valuePair.Key, valuePair.Value); _headDatas.Add(headData); } }
// // Jump to the end of the current structure. // public void SkipToStructEnd() { HeadData head = new HeadData(); do { ReadHead(head); SkipField(head.type); } while (head.type != (byte)TarsStructType.STRUCT_END); }
/// <summary> /// 跳到当前结构的结束位置 /// </summary> public void SkipToStructEnd() { var hd = new HeadData(); do { ReadHead(hd); SkipField(hd.Type); } while (hd.Type != StructEnd); }
protected virtual void OnHeadChanged(string value) { selectHead = value; headData = GameInstance.GetHead(value); if (characterModel != null && headData != null) { characterModel.SetHeadModel(headData.modelObject); } UpdateCharacterModelHiddingState(); }
// 跳到当前结构的结束位置 public void skipToStructEnd() { HeadData hd = new HeadData(); do { readHead(hd); skipField(hd.type); } while (hd.type != (byte)TarsStructType.STRUCT_END); }
protected void PlayActionSequence ( ArrayList p_actionSequence ) { // check here if cueueble or action is uninteractibe. if( !this.IsInteractible() ) { if( m_bEventIsCueable ) { // Sanity check.. // 1. Should not Add ActionSequence that is currently playing // 2. Should not Add ActionSequence that is already in cue foreach( string action in p_actionSequence ) { bool containsAction = false; foreach( string cuedAction in m_cuedActions ) { if( action.Equals(cuedAction) ) containsAction = true; } if( !containsAction ) { m_cuedActions.Add(action); } #if DEBUG_CUEABLES if( containsAction ) Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #else if( containsAction ) Log("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Log("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #endif } return; } #if DEBUG_CUEABLES Debug.LogError("Dragon::PlayActionSequence Cannot Play this Action because Action is not Interactibe."); //Debug.Break(); #else //Log("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe."); Debug.LogWarning("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe. \n"); #endif return; } // clear actions DragonAnimationQueue.getInstance().ClearAll(); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadSoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.BodySoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadAndBodySoundContainer ); foreach( string action in p_actionSequence ) { // Body Animations ArrayList bodyActionSequence = SequenceReader.GetInstance().ReadBodySequence(action); Log("----------- Playing Reaction:"+action+" -----------"); //LogWarning(">>>>>>> Checking action: \""+action+"\"\n"); if( bodyActionSequence != null ) { // +KJ:06132013 Shared Parameter. this supports the same random value that a cue is sharing foreach( object actionData in bodyActionSequence ) { ArrayList actionDataList = actionData as ArrayList; BodyData bodyData = new BodyData(); bodyData.Action = action; bodyData.Start = Utility.ParseToInt(actionDataList[0]); bodyData.ActionKey = actionDataList[1].ToString(); bodyData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { bodyData.Param = actionDataList[3] as Hashtable; } bodyData.ExtractHashtableValues( bodyData.Param ); bodyData.EventTrigger = this.FormulateEventTriggers( bodyData.Param ); DragonAnimationQueue.getInstance().AddBodyCue( bodyData.GenerateHashtable() ); } } // Head Animations ArrayList headActionSequence = SequenceReader.GetInstance().ReadHeadSequence(action); if( headActionSequence != null ) { foreach( object actionData in headActionSequence ) { ArrayList actionDataList = actionData as ArrayList; HeadData headData = new HeadData(); headData.Action = action; headData.Start = Utility.ParseToInt(actionDataList[0]); headData.ActionKey = actionDataList[1].ToString(); headData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { headData.Param = actionDataList[3] as Hashtable; } headData.ExtractHashtableValues( headData.Param ); headData.EventTrigger = this.FormulateEventTriggers( headData.Param ); DragonAnimationQueue.getInstance().AddHeadCue( headData.GenerateHashtable() ) ; } } // Update Queue ArrayList updateActionQueue = SequenceReader.GetInstance().ReadUpdate(action); if( updateActionQueue != null ) { foreach( object actionData in updateActionQueue ) { ArrayList actionDataList = actionData as ArrayList; UpdateData updateData = new UpdateData(); updateData.Action = action; updateData.Start = Utility.ParseToInt(actionDataList[0]); updateData.ActionKey = actionDataList[1].ToString(); updateData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { updateData.Param = actionDataList[3] as Hashtable; } updateData.EventTrigger = this.FormulateEventTriggers( updateData.Param ); DragonAnimationQueue.getInstance().AddUpdateCue( updateData.GenerateHashtable() ); } } // Transition Queue ArrayList transitionQueue = SequenceReader.GetInstance().ReadTransform(action); if( transitionQueue != null ) { foreach( object actionData in transitionQueue ) { ArrayList actionDataList = actionData as ArrayList; TransformData transformData = new TransformData(); transformData.Action = action; transformData.Start = Utility.ParseToInt(actionDataList[0]); transformData.ActionKey = actionDataList[1].ToString(); transformData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { transformData.Param = actionDataList[3] as Hashtable; } transformData.EventTrigger = this.FormulateEventTriggers( transformData.Param ); DragonAnimationQueue.getInstance().AddTransformCue( transformData.GenerateHashtable() ); } } ArrayList cameraQueue = SequenceReader.GetInstance().ReadCamera(action); if( cameraQueue != null ) { foreach( object actionData in cameraQueue ) { ArrayList actionDataList = actionData as ArrayList; CameraData cameraData = new CameraData(); cameraData.Action = action; cameraData.Start = Utility.ParseToInt(actionDataList[0]); cameraData.ActionKey = actionDataList[1].ToString(); cameraData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { cameraData.Param = actionDataList[3] as Hashtable; } cameraData.EventTrigger = this.FormulateEventTriggers( cameraData.Param ); DragonAnimationQueue.getInstance().AddCameraCue( cameraData.GenerateHashtable() ); } } ArrayList eventQueue = SequenceReader.GetInstance().ReadEventTriggers(action); if( eventQueue != null ) { foreach( object actionData in eventQueue ) { ArrayList actionDataList = actionData as ArrayList; EventData eventData = new EventData(); eventData.Action = action; eventData.Start = Utility.ParseToInt(actionDataList[0]); eventData.ActionKey = actionDataList[1].ToString(); eventData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { eventData.Param = actionDataList[3] as Hashtable; } eventData.EventTrigger = this.FormulateEventTriggers( eventData.Param ); DragonAnimationQueue.getInstance().AddEventCue( eventData.GenerateHashtable() ); } } // + LA 072613 ArrayList soundQueue = SequenceReader.GetInstance().ReadSounds(action); if( soundQueue != null ) { foreach( object actionData in soundQueue ) { ArrayList actionDataList = actionData as ArrayList; SoundData soundData = new SoundData(); soundData.Action = action; soundData.Start = Utility.ParseToInt(actionDataList[0]); soundData.ActionKey = actionDataList[1].ToString(); soundData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { soundData.Param = actionDataList[3] as Hashtable; } soundData.EventTrigger = this.FormulateEventTriggers( soundData.Param ); DragonAnimationQueue.getInstance().AddSoundCue( soundData.GenerateHashtable() ); } } // - LA } DragonAnimationQueue.getInstance().PlayQueuedAnimations(); }