public static IJsonWriter Node(this IJsonWriter writer, IJsonNode node) { switch (node.Type) { case JsonNodeType.Array: if (!string.IsNullOrEmpty(node.Name)) writer.Prop(node.Name); writer.Array(); break; case JsonNodeType.ArrayEnd: writer.ArrayEnd(); break; case JsonNodeType.Object: if (!string.IsNullOrEmpty(node.Name)) writer.Prop(node.Name); writer.Object(); break; case JsonNodeType.ObjectEnd: writer.ObjectEnd(); break; case JsonNodeType.SimpleProperty: writer.Prop(node.Name, node.Value); break; default: writer.Value(node.Value); break; } return writer; }
public static IJsonNode Parse(string json) { //try //{ ScanObj obj = new ScanObj(); obj.json = json; obj.seed = 0; IJsonNode node = Scan(obj); return node; //} //catch (Exception err) //{ // throw new Exception("parse err:" + json, err); //} }
public static IJsonNode Parse(string json) { try { ScanObj obj = new ScanObj(); obj.json = json; obj.seed = 0; IJsonNode node = Scan(obj); return(node); } catch (Exception err) { throw new Exception("parse err:" + json, err); } }
/// <summary> /// Encode each item in message. /// </summary> private int encodeProp(IJsonNode value, string type, int offset, byte[] buffer, JsonNode_Object proto) { switch (type) { case "uInt32": this.writeUInt32(buffer, ref offset, value); break; case "int32": case "sInt32": this.writeInt32(buffer, ref offset, value); break; case "float": this.writeFloat(buffer, ref offset, value); break; case "double": this.writeDouble(buffer, ref offset, value); break; case "string": this.writeString(buffer, ref offset, value); break; default: IJsonNode __messages; IJsonNode __message_type; if (proto.TryGetValue("__messages", out __messages)) { if (((JsonNode_Object)__messages).TryGetValue(type, out __message_type) || protos.TryGetValue("message " + type, out __message_type)) { byte[] tembuff = new byte[Encoder.byteLength(value.ToString()) * 3]; int length = 0; length = this.encodeMsg(tembuff, length, (JsonNode_Object)__message_type, (JsonNode_Object)value); offset = writeBytes(buffer, offset, Encoder.encodeUInt32((uint)length)); for (int i = 0; i < length; i++) { buffer[offset] = tembuff[i]; offset++; } } } break; } return(offset); }
public void JsonDo(IJsonNode json) { Clear(); KillAll(); if (json == null || json.Count <= 0) { return; } // end if int count = json.Count; m_tweens = new JTweenBase[count]; IJsonNode node; JTweenBase tween; string path; UnityEngine.Transform trans; Dictionary <string, UnityEngine.Transform> pathToTrans = new Dictionary <string, UnityEngine.Transform>(); for (int i = 0; i < count; ++i) { node = json[i]; tween = JTweenFactory.CreateTween(node); m_tweens[i] = tween; if (node.Contains("_PATH")) { path = node.GetString("_PATH"); if (!pathToTrans.TryGetValue(path, out trans)) { trans = transform.Find(path); if (null != trans) { pathToTrans.Add(path, trans); } else { Debug.LogErrorFormat("JTweenSequence con't find, Name:{0}, Path:{1}", gameObject.name, path); } // end if } // end if tween.Bind(trans); } else { tween.Bind(transform); } // end if tween.JsonDo(node); } // end for }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginPosition", JTweenUtils.Vector3Json(m_beginPosition)); IJsonNode pathJson = JsonHelper.CreateNode(); for (int i = 0; i < m_toPath.Length; ++i) { pathJson.Add(JTweenUtils.Vector3Json(m_toPath[i])); } // end for json.SetNode("path", pathJson); json.SetInt("type", (int)m_pathType); json.SetInt("mode", (int)m_pathMode); json.SetInt("resolution", m_resolution); json.SetNode("gizmoColor", JTweenUtils.ColorJson(m_gizmoColor)); json.SetBool("showGizmo", m_showGizmo); }
public static JTweenBase CreateTween(IJsonNode json) { if (!json.Contains("tweenType")) { UnityEngine.Debug.LogError("JTweenFactory CreateTween json tweenType is error"); return(null); } // end if if (!json.Contains("tweenElement")) { UnityEngine.Debug.LogError("JTweenFactory CreateTween json tweenElement is error"); return(null); } // end if int tweenType = json.GetInt("tweenType"); int tweenElement = json.GetInt("tweenElement"); return(CreateTween(tweenElement, tweenType)); }
public static AnimationCurve JsonAnimationCurve(IJsonNode json) { IJsonNode jsonKeys = json.GetNode("keys"); int count = jsonKeys.Count; Keyframe[] keys = new Keyframe[count]; for (int i = 0; i < count; ++i) { IJsonNode oneKey = jsonKeys[i]; keys[i] = new Keyframe(oneKey.GetFloat("T"), oneKey.GetFloat("V"), oneKey.GetFloat("I"), oneKey.GetFloat("O")); keys[i].tangentMode = oneKey.GetInt("M"); } AnimationCurve ret = new AnimationCurve(keys); ret.preWrapMode = (WrapMode)json.GetInt("pre"); ret.postWrapMode = (WrapMode)json.GetInt("post"); return(ret); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginRotate")) { BeginRotate = JTweenUtils.JsonToVector3(json.GetNode("beginRotate")); } // end if if (json.Contains("rotate")) { m_toRotate = JTweenUtils.JsonToVector3(json.GetNode("rotate")); } // end if if (json.Contains("mode")) { m_RotateMode = (RotateMode)(int)json.GetInt("mode"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginPosition")) { BeginPosition = JTweenUtils.JsonToVector3(json.GetNode("beginPosition")); } // end if if (json.Contains("path")) { IJsonNode pathJson = json.GetNode("path"); m_toPath = new Vector3[pathJson.Count]; for (int i = 0, imax = pathJson.Count; i < imax; ++i) { m_toPath[i] = JTweenUtils.JsonToVector3(pathJson[i]); } // end for } // end if if (json.Contains("type")) { m_pathType = (PathType)json.GetInt("type"); } // end if if (json.Contains("mode")) { m_pathMode = (PathMode)json.GetInt("mode"); } // end if if (json.Contains("resolution")) { m_resolution = json.GetInt("resolution"); } // end if if (json.Contains("gizmoColor")) { m_gizmoColor = JTweenUtils.JsonToColor(json.GetNode("gizmoColor")); } // end if if (json.Contains("showGizmo")) { m_showGizmo = json.GetBool("showGizmo"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("vector")) { m_toVector = JTweenUtils.JsonToVector4(json.GetNode("vector")); } // end if if (json.Contains("property")) { m_property = json.GetString("property"); } // end if if (json.Contains("propertyID")) { m_propertyID = json.GetInt("propertyID"); } // end if Restore(); }
public void Deserialize(IJsonNode json) { if (json == null) { return; } JsonObject jsonObject = json as JsonObject; var bindType = allTypeList.Find(p => { return(p.nameSpace == jsonObject["nameSpace"].AsString() && p.className == jsonObject["className"].AsString()); }); if (bindType != null) { bindType.preload = jsonObject["preload"].AsBool(); bindType.drop = jsonObject["drop"].AsBool(); bindType.wrapName = jsonObject["wrapName"].AsString(); bindType.libName = jsonObject["libName"].AsString(); bindType.baseClass = jsonObject["baseClass"].AsString(); if (!bindType.drop) { bindType.isBuilded = true; } if (bindType.isDelegate) { if (!wrappedDelegateList.Contains(bindType)) { wrappedDelegateList.Add(bindType); } } else if (bindType.drop) { if (!dropedTypeList.Contains(bindType)) { dropedTypeList.Add(bindType); } } else { if (!wrappedCustomTypeList.Contains(bindType)) { wrappedCustomTypeList.Add(bindType); } } } }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginAnchorPos", JTweenUtils.Vector2Json(m_beginAnchorPos)); switch (m_shakeType) { case ShakeTypeEnum.Value: json.SetFloat("strength", m_strength); break; case ShakeTypeEnum.Axis: json.SetNode("strengthAxis", JTweenUtils.Vector2Json(m_strengthAxis)); break; default: Debug.LogError(GetType().FullName + " ToJson ShakeType is null"); break; } // end swtich json.SetInt("vibrato", m_vibrato); json.SetFloat("randomness", m_randomness); json.SetBool("fadeOut", m_fadeOut); }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginPivot", JTweenUtils.Vector2Json(m_beginPivot)); switch (m_pivotType) { case PivotTypeEnum.Pivot: json.SetNode("pivot", JTweenUtils.Vector2Json(m_toPivot)); break; case PivotTypeEnum.PivotX: json.SetFloat("pivotX", m_toPivotX); break; case PivotTypeEnum.PivotY: json.SetFloat("pivotY", m_toPivotY); break; default: Debug.LogError(GetType().FullName + " ToJson PosType is null"); break; } // end swtich }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginAnchorPos", JTweenUtils.Vector2Json(m_beginAnchorPos)); switch (m_posType) { case PosTypeEnum.Pos: json.SetNode("pos", JTweenUtils.Vector2Json(m_toAnchorPos)); break; case PosTypeEnum.PosX: json.SetFloat("posX", m_toAnchorPosX); break; case PosTypeEnum.PosY: json.SetFloat("posY", m_toAnchorPosY); break; default: Debug.LogError(GetType().FullName + " ToJson PosType is null"); break; } // end swtich }
public static IJsonNode AnimationCurveJson(AnimationCurve arg) { IJsonNode ret = JsonHelper.CreateNode(); IJsonNode jsonKeys = JsonHelper.CreateNode(); Keyframe[] keys = arg.keys; for (int i = 0, imax = keys.Length; i < imax; ++i) { Keyframe k = keys[i]; IJsonNode oneKey = JsonHelper.CreateNode(); ret.SetDouble("T", System.Math.Round(k.time, 4)); ret.SetDouble("V", System.Math.Round(k.value, 4)); ret.SetDouble("I", System.Math.Round(k.inTangent, 4)); ret.SetDouble("O", System.Math.Round(k.outTangent, 4)); ret.SetInt("M", k.tangentMode); jsonKeys.Add(oneKey); } ret.SetNode("keys", jsonKeys); ret.SetInt("pre", (int)arg.preWrapMode); ret.SetInt("post", (int)arg.postWrapMode); return(ret); }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginPosition", JTweenUtils.Vector3Json(m_beginPosition)); switch (m_MoveType) { case MoveTypeEnum.Move: json.SetNode("move", JTweenUtils.Vector3Json(m_toPosition)); break; case MoveTypeEnum.MoveX: json.SetFloat("moveX", m_toMoveX); break; case MoveTypeEnum.MoveY: json.SetFloat("moveY", m_toMoveY); break; default: Debug.LogError(GetType().FullName + " ToJson MoveType is null"); break; } // end swtich }
/// <summary> /// 转成Json /// </summary> public IJsonNode DoJson() { IJsonNode json = JsonHelper.CreateNode(); if (m_tweenType != 0) { json.SetInt("tweenType", m_tweenType); } // end if json.SetInt("tweenElement", (int)m_tweenElement); if (!string.IsNullOrEmpty(m_name)) { json.SetString("name", m_name); } // end if json.SetDouble("duration", Math.Round(m_duration, 4)); if (m_delay > 0.00009f) { json.SetDouble("delay", Math.Round(m_delay, 4)); } // end if json.SetBool("snapping", m_isSnapping); if (m_animCurve != null && m_animCurve.keys != null && m_animCurve.keys.Length > 0) { json.SetNode("animCurve", JTweenUtils.AnimationCurveJson(m_animCurve)); } else { json.SetInt("animEase", (int)m_animEase); } // end if if (m_loopCount > 0) { json.SetInt("loopCount", m_loopCount); json.SetInt("loopType", (int)m_loopType); } // end if ToJson(ref json); return(json); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginAnchorPos")) { BeginAnchorPos = JTweenUtils.JsonToVector2(json.GetNode("beginAnchorPos")); } // end if if (json.Contains("anchorPos")) { ToAnchorPos = JTweenUtils.JsonToVector2(json.GetNode("anchorPos")); } // end if if (json.Contains("jumpPower")) { JumpPower = json.GetFloat("jumpPower"); } // end if if (json.Contains("numJumps")) { NumJumps = json.GetInt("numJumps"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("width")) { m_width = json.GetFloat("width"); } // end if if (json.Contains("height")) { m_height = json.GetFloat("height"); } // end if if (json.Contains("beginWidth")) { BeginWidth = json.GetFloat("beginWidth"); } // end if if (json.Contains("beginHeight")) { BeginHeight = json.GetFloat("beginHeight"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginRotation")) { BeginRotation = JTweenUtils.JsonToVector3(json.GetNode("beginRotation")); } // end if if (json.Contains("punch")) { m_toPunch = JTweenUtils.JsonToVector3(json.GetNode("punch")); } // end if if (json.Contains("vibrate")) { m_vibrate = json.GetInt("vibrate"); } // end if if (json.Contains("elasticity")) { m_elasticity = json.GetFloat("elasticity"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginRotate")) { BeginRotate = JTweenUtils.JsonToVector3(json.GetNode("beginRotate")); } // end if if (json.Contains("towards")) { m_towards = JTweenUtils.JsonToVector3(json.GetNode("towards")); } // end if if (json.Contains("axis")) { m_axisConstraint = (AxisConstraint)(int)json.GetInt("axis"); } // end if if (json.Contains("up")) { m_up = JTweenUtils.JsonToVector3(json.GetNode("up")); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginAnchorPos")) { BeginAnchorPos = JTweenUtils.JsonToVector2(json.GetNode("beginAnchorPos")); } // end if if (json.Contains("punch")) { m_punch = JTweenUtils.JsonToVector2(json.GetNode("punch")); } // end if if (json.Contains("vibrato")) { m_vibrato = json.GetInt("vibrato"); } // end if if (json.Contains("elasticity")) { m_elasticity = json.GetFloat("elasticity"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginStartColor")) { BeginStartColor = JTweenUtils.JsonToColor(json.GetNode("beginStartColor")); } // end if if (json.Contains("beginEndColor")) { BeginEndColor = JTweenUtils.JsonToColor(json.GetNode("beginEndColor")); } // end if if (json.Contains("toStartColor")) { m_toStartColor = JTweenUtils.JsonToColor(json.GetNode("toStartColor")); } // end if if (json.Contains("toEndColor")) { m_toEndColor = JTweenUtils.JsonToColor(json.GetNode("toEndColor")); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginOffset")) { BeginOffset = JTweenUtils.JsonToVector2(json.GetNode("beginOffset")); } // end if if (json.Contains("offset")) { m_toOffset = JTweenUtils.JsonToVector2(json.GetNode("offset")); } // end if if (json.Contains("property")) { m_property = json.GetString("property"); } // end if if (json.Contains("propertyID")) { m_propertyID = json.GetInt("propertyID"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginFloat")) { BeginFloat = json.GetFloat("beginFloat"); } // end if if (json.Contains("float")) { m_toFloat = json.GetFloat("float"); } // end if if (json.Contains("property")) { m_property = json.GetString("property"); } // end if if (json.Contains("propertyID")) { m_propertyID = json.GetInt("propertyID"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginPosition")) { BeginPosition = JTweenUtils.JsonToVector3(json.GetNode("beginPosition")); } // end if if (json.Contains("endValue")) { m_toPosition = JTweenUtils.JsonToVector3(json.GetNode("endValue")); } // end if if (json.Contains("jumpPower")) { m_jumpPower = json.GetFloat("jumpPower"); } // end if if (json.Contains("numJumps")) { m_numJumps = json.GetInt("numJumps"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginColor")) { BeginColor = JTweenUtils.JsonToColor(json.GetNode("beginColor")); } // end if if (json.Contains("alpha")) { m_toAlpha = json.GetFloat("alpha"); } // end if if (json.Contains("property")) { m_property = json.GetString("property"); } // end if if (json.Contains("propertyID")) { m_propertyID = json.GetInt("propertyID"); } // end if Restore(); }
protected override void JsonTo(IJsonNode json) { if (json.Contains("beginStartWidth")) { BeginStartWidth = json.GetFloat("beginStartWidth"); } // end if if (json.Contains("beginEndWidth")) { BeginEndWidth = json.GetFloat("beginEndWidth"); } // end if if (json.Contains("startWidth")) { m_startWidth = json.GetFloat("startWidth"); } // end if if (json.Contains("endWidth")) { m_endWidth = json.GetFloat("endWidth"); } // end if Restore(); }
protected override void ToJson(ref IJsonNode json) { json.SetNode("beginColor", JTweenUtils.ColorJson(m_beginColor)); json.SetNode("color", JTweenUtils.ColorJson(m_toColor)); }
public void SetDictValue(string key, IJsonNode node) { throw new NotImplementedException(); }