Esempio n. 1
0
    // 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);
    }
Esempio n. 2
0
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        Color col = (Color)instance;

        writer.WriteObjectStart();
        writer.WritePropertyName("r");
        writer.WriteNumber(col.r);
        writer.WritePropertyName("g");
        writer.WriteNumber(col.g);
        writer.WritePropertyName("b");
        writer.WriteNumber(col.b);
        writer.WritePropertyName("a");
        writer.WriteNumber(col.a);
        writer.WriteObjectEnd();
    }
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        writer.WriteNull();
        /*var tex = (Texture2D)instance;
        writer.WriteObjectStart();

        writer.WritePropertyName("width");
        writer.WriteNumber(tex.width);

        writer.WritePropertyName("height");
        writer.WriteNumber(tex.height);

        writer.WritePropertyName("data");
        Jboy.Json.WriteObject(tex.EncodeToPNG(), writer);

        writer.WriteObjectEnd();*/
    }
Esempio n. 4
0
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        var slot = (ArtifactSlot)instance;

        writer.WriteObjectStart();

        writer.WritePropertyName("requiredLevel");
        writer.WriteNumber(slot.requiredLevel);

        writer.WritePropertyName("artifactId");
        if(slot.artifact != null)
            writer.WriteNumber(slot.artifact.id);
        else
            writer.WriteNumber(-1);

        writer.WriteObjectEnd();
    }
Esempio n. 5
0
    // 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;
    }
Esempio n. 6
0
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        if(instance == null) {
            writer.WriteNull();
            return;
        }

        var slot = (ItemSlot)instance;

        writer.WriteObjectStart();

        // ID
        writer.WritePropertyName("item");
        Jboy.Json.WriteObject(slot.item, writer);

        // Count
        writer.WritePropertyName("count");
        writer.WriteNumber(slot.count);

        writer.WriteObjectEnd();
    }
Esempio n. 7
0
    // 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;
    }
Esempio n. 8
0
    // Reader
    public static object JsonDeserializer(Jboy.JsonReader reader)
    {
        reader.ReadArrayStart();

        var tree = new ArtifactTree();
        for(int i = 0; i < tree.slots.Length; i++) {
            int numSlots = Artifact.maxLevel - i;
            var slotLevel = tree.slots[i];
            reader.ReadArrayStart();

            for(int slotIndex = 0; slotIndex < numSlots; slotIndex++) {
                var artifactSlot = new ArtifactSlot((byte)i);
                artifactSlot.artifact = Jboy.Json.ReadObject<Artifact>(reader);

                slotLevel[slotIndex] = artifactSlot;
            }

            reader.ReadArrayEnd();
        }

        reader.ReadArrayEnd();
        return tree;
    }
Esempio n. 9
0
 // uLink Bitstream write
 /*public static void BitStreamSerializer(
     uLink.BitStream stream,
     object val,
     params object[] codecOptions
 ) {
     PlayerStats stats = (PlayerStats)val;
     stream.Write<double>(stats.level);
     stream.Write<int>(stats.bestRanking);
     stream.Write<int>(stats.ping);
 }*/
 // Writer
 public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
 {
     GenericSerializer.WriteJSONClassInstance<PlayerStats>(writer, (PlayerStats)instance);
 }
Esempio n. 10
0
 // Reader
 public static object JsonDeserializer(Jboy.JsonReader reader)
 {
     return GenericSerializer.ReadJSONClassInstance<PlayerStats>(reader);
 }
Esempio n. 11
0
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        writer.WriteArrayStart();

        var tree = (ArtifactTree)instance;
        foreach(var slotLevel in tree.slots) {
            writer.WriteArrayStart();

            for(int i = 0; i < slotLevel.Length; i++) {
                Jboy.Json.WriteObject(slotLevel[i].artifact, writer);
            }

            writer.WriteArrayEnd();
        }

        writer.WriteArrayEnd();
    }
Esempio n. 12
0
 // Writer
 public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
 {
     GenericSerializer.WriteJSONClassInstance<InputSettings>(writer, (InputSettings)instance);
 }
Esempio n. 13
0
 // Reader
 public static object JsonDeserializer(Jboy.JsonReader reader)
 {
     return GenericSerializer.ReadJSONClassInstance<InputSettings>(reader);
 }
 // Reader
 public static object JsonDeserializer(Jboy.JsonReader reader)
 {
     reader.ReadNull();
     return null; //new Texture2D(64, 64);
 }