Пример #1
0
 private void UpdateDamageInstanceData()
 {
     main_monster.MeleeDamage = null;
     if (damageInstanceDataGrid.Rows.Count > 0)
     {
         main_monster.MeleeDamage = new DamageInstance {
         };
     }
     foreach (DataGridViewRow row in damageInstanceDataGrid.Rows)
     {
         string type = row.Cells["Type"].Value.ToString();
         int    amount;
         int.TryParse(row.Cells["Amount"].Value.ToString(), out amount);
         int armor_penetration;
         int.TryParse(row.Cells["ArmorPenetration"].Value.ToString(), out armor_penetration);
         float armor_multiplier;
         float.TryParse(row.Cells["ArmorMultiplier"].Value.ToString(), out armor_multiplier);
         float damage_multiplier;
         float.TryParse(row.Cells["DamageMultiplier"].Value.ToString(), out damage_multiplier);
         DamageUnit du =
             new DamageUnit
         {
             Type             = type,
             Amount           = amount,
             ArmorPenetration = armor_penetration,
             ArmorMultiplier  = armor_multiplier,
             DamageMultiplier = damage_multiplier
         };
         main_monster.MeleeDamage.Add(du);
     }
 }
Пример #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken         token    = JToken.Load(reader);
            DamageInstance instance = new DamageInstance {
            };

            if (token.Type == JTokenType.Array)
            {
                foreach (JObject jo in token.ToObject <List <JObject> >(serializer))
                {
                    DamageUnit du = (DamageUnit)jo.ToObject(typeof(DamageUnit), serializer);
                    instance.Add(du);
                }
            }
            else
            {
                return(token.ToObject <T>(serializer));
            }
            return(instance);
        }
Пример #3
0
 public void Add(DamageUnit du_add)
 {
     Values.Add(du_add);
 }