Esempio n. 1
0
        public override object ReadJson(JsonReader reader,
            Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject item = JObject.Load(reader);
            object target = null;
            if (item["Type"].Value<string>() == "Equipment")
            {
                target = new Equipment();
            }
            else
            {
                target = new Item();
            }

            serializer.Populate(item.CreateReader(), target);

            return target;
        }
Esempio n. 2
0
        public Item Clone()
        {
            Item i = null;
            if (Type == ItemType.Equipment)
                i = new Equipment();
            else
                i = new Item();

            i.Id = Id;
            i.Name = Name;
            i.Price = Price;
            i.Weight = Weight;
            i.Type = Type;
            i.Description = Description;
            i.Modifiers = new List<AttributeModifier>();
            foreach (AttributeModifier o in Modifiers)
                i.Modifiers.Add(o);
            i.ScriptId = ScriptId;
            i.TextureName = TextureName;
            i.Gid = Gid;
            i.TextureTileSize = TextureTileSize;

            return i;
        }