Пример #1
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();
    }
Пример #2
0
 // Write a single value in JSON
 public static void WriteJSONValue(Jboy.JsonWriter writer, object val)
 {
     if (val is int || val is KeyCode)
     {
         writer.WriteNumber((double)((int)val));
     }
     else if (val is long)
     {
         writer.WriteNumber((double)((long)val));
     }
     else if (val is double)
     {
         writer.WriteNumber((double)val);
     }
     else
     {
         Jboy.Json.WriteObject(val, writer);
     }
 }
Пример #3
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();
    }
Пример #4
0
    // Writer
    public static void JsonSerializer(Jboy.JsonWriter writer, object instance)
    {
        if (instance == null)
        {
            writer.WriteNull();
            return;
        }

        var item = (Item)instance;

        writer.WriteObjectStart();

        // ID
        writer.WritePropertyName("id");
        writer.WriteNumber(item.id);

        // Meta data
        item.WriteItemMetaData(writer);

        writer.WriteObjectEnd();
    }
Пример #5
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();
    }