// Reader public static object JsonDeserializer(Jboy.JsonReader reader) { reader.ReadObjectStart(); reader.ReadPropertyName("r"); var r = (float)reader.ReadNumber(); reader.ReadPropertyName("g"); var g = (float)reader.ReadNumber(); reader.ReadPropertyName("b"); var b = (float)reader.ReadNumber(); reader.ReadPropertyName("a"); var a = (float)reader.ReadNumber(); reader.ReadObjectEnd(); return new Color(r, g, b, a); }
// Reader public static object JsonDeserializer(Jboy.JsonReader reader) { var slot = new ArtifactSlot(); reader.ReadObjectStart(); reader.ReadPropertyName("requiredLevel"); slot.requiredLevel = (byte)reader.ReadNumber(); reader.ReadPropertyName("artifactId"); int itemId = (int)reader.ReadNumber(); if(itemId != -1) { slot.artifact = new Artifact(itemId); } reader.ReadObjectEnd(); return slot; }
// Reader public static object JsonDeserializer(Jboy.JsonReader reader) { if(reader.TryReadNull()) return null; var itemSlot = new ItemSlot(); reader.ReadObjectStart(); // ID reader.ReadPropertyName("item"); itemSlot.item = Jboy.Json.ReadObject<Item>(reader); // Count reader.ReadPropertyName("count"); itemSlot.count = (ulong)reader.ReadNumber(); reader.ReadObjectEnd(); return itemSlot; }