public static Equipment convertToEquipment(EquipmentItem Item) { Equipment equipment = new Equipment(); equipment.staticIndexes.Add("idItem", Item.idItem); equipment.staticIndexes.Add("idItemInit", Item.idItemInit); equipment.staticIndexes.Add("type", Item.typeItem); equipment.staticIndexes.Add("class", Item.classItem); equipment.staticIndexes.Add("rarely", Item.rarelyItem); equipment.staticIndexes.Add("idGroup", Item.idGroupSetItems); equipment.staticIndexes.Add("nameItem", Item.nameItem); equipment.staticIndexes.Add("levelRequired", Item.levelRequired); equipment.staticIndexes.Add("levelUpgraded", Item.levelUpgraded); equipment.staticIndexes.Add("valueItem", Item.valueItem); equipment.staticIndexes.Add("numberItem", Item.numberItem); switch (Item.typeItem) { case TypeEquipmentCharacter.Gem: break; case TypeEquipmentCharacter.AlchemyMaterial: break; case TypeEquipmentCharacter.Amulet: equipment.staticIndexes.Add("name", "necklace"); break; case TypeEquipmentCharacter.Avatar: equipment.staticIndexes.Add("name", "avatar"); break; case TypeEquipmentCharacter.Belt: equipment.staticIndexes.Add("name", "belt"); break; case TypeEquipmentCharacter.Boots: equipment.staticIndexes.Add("name", "boots"); break; case TypeEquipmentCharacter.Buff: equipment.staticIndexes.Add("name", "book"); break; case TypeEquipmentCharacter.Gloves: equipment.staticIndexes.Add("name", "gloves"); break; case TypeEquipmentCharacter.Head: equipment.staticIndexes.Add("name", "helmet"); break; case TypeEquipmentCharacter.HPRecovery: break; case TypeEquipmentCharacter.Leg: //pants equipment.staticIndexes.Add("name", "pants"); break; case TypeEquipmentCharacter.LuckMaterial: break; case TypeEquipmentCharacter.Ring: equipment.staticIndexes.Add("name", "ring"); break; case TypeEquipmentCharacter.Scroll: break; case TypeEquipmentCharacter.Shield: equipment.staticIndexes.Add("name", "shield"); break; case TypeEquipmentCharacter.Torso: //cape equipment.staticIndexes.Add("name", "cape"); break; case TypeEquipmentCharacter.VIPCard: break; case TypeEquipmentCharacter.Weapon: equipment.staticIndexes.Add("name", "weapon"); break; case TypeEquipmentCharacter.OffhandWeapon: equipment.staticIndexes.Add("name", "weapon2"); break; } foreach (string key in Item.indexes.Keys) { if (key != "listidproperty") { ServerIndexes index = Utilities.ParseEnum <ServerIndexes>(key); String name = index.ToString(); string[] parts = name.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); String prefix = parts[0]; if (prefix == "min") {// chi so min cua dynamic String property = ""; for (int i = 1; i < parts.Length; i++) { property += i == 1 ? parts[i] : "_" + parts[i]; } Range <float> ranger = equipment.dynamicIndexes.ContainsKey(property) ? (Range <float>)equipment.dynamicIndexes[property] : new Range <float>(); equipment.dynamicIndexes.Add(property, ranger); ranger.Minimum = Utilities.convertStringToFloat(String.Format("{0:0.00}", Item.indexes[key])); } else if (prefix == "max") {// chi so max cuat dynamic String property = ""; for (int i = 1; i < parts.Length; i++) { property += i == 1 ? parts[i] : "_" + parts[i]; } Range <float> ranger = equipment.dynamicIndexes.ContainsKey(property) ? (Range <float>)equipment.dynamicIndexes[property] : new Range <float>(); equipment.dynamicIndexes.Add(property, ranger); ranger.Maximum = Utilities.convertStringToFloat(String.Format("{0:0.00}", Item.indexes[key])); } else {// chi so static String property = name; equipment.staticIndexes.Add(property, Utilities.convertStringToFloat(String.Format("{0:0.00}", Item.indexes[key]))); } } } return(equipment); }
public static EquipmentItem convertToEquipmentItem(Equipment equipment) { EquipmentItem item = new EquipmentItem(); //item.attributeItems = new List<PropertiesBonus>(); foreach (string key in equipment.dynamicIndexes.Keys) { object value = equipment.dynamicIndexes[key]; Range <float> range = (Range <float>)value; float min = range.Minimum; String index = "min_" + key; string id = (int)Utilities.ParseEnum <ServerIndexes>(index) + ""; item.indexes.Add(index, min + ""); float max = range.Maximum; index = "max_" + key; id = (int)Utilities.ParseEnum <ServerIndexes>(index) + ""; item.indexes.Add(index, max + ""); } foreach (String key in equipment.staticIndexes.Keys) { switch (key) { case "idItem": item.idItem = (int)equipment.staticIndexes["idItem"]; break; case "idItemInit": item.idItemInit = (int)equipment.staticIndexes["idItemInit"]; break; case "type": item.typeItem = (TypeEquipmentCharacter)equipment.staticIndexes["type"]; // TypeEquipmentCharacter.None); break; case "class": item.classItem = (ClassCharacterItem)equipment.staticIndexes["class"]; break; case "rarely": item.rarelyItem = (int)equipment.staticIndexes["rarely"]; break; case "idGroup": item.idGroupSetItems = (int)equipment.staticIndexes["idGroup"]; break; case "nameItem": item.nameItem = (string)equipment.staticIndexes["nameItem"]; break; case "levelRequired": item.levelRequired = (int)equipment.staticIndexes["levelRequired"]; break; case "levelUpgraded": item.levelUpgraded = (int)equipment.staticIndexes["levelUpgraded"]; break; case "valueItem": item.valueItem = (float)equipment.staticIndexes["valueItem"]; break; case "numberItem": item.numberItem = (int)equipment.staticIndexes["numberItem"]; break; case "name": //item.indexes.Add(key, equipment.staticIndexes["name"]); break; default: ServerIndexes index = Utilities.ParseEnum <ServerIndexes>(key); if (index == null) { continue; } string id = "" + (int)index; string v = (float)equipment.staticIndexes[key] + ""; item.indexes.Add(id, v); break; } } switch ((string)equipment.staticIndexes["name"]) { case "necklace": item.typeItem = TypeEquipmentCharacter.Amulet; break; case "avatar": item.typeItem = TypeEquipmentCharacter.Avatar; break; case "belt": item.typeItem = TypeEquipmentCharacter.Belt; break; case "boots": item.typeItem = TypeEquipmentCharacter.Boots; break; case "gloves": item.typeItem = TypeEquipmentCharacter.Gloves; break; case "helmet": item.typeItem = TypeEquipmentCharacter.Head; break; case "pants": //pants item.typeItem = TypeEquipmentCharacter.Leg; break; case "ring": item.typeItem = TypeEquipmentCharacter.Ring; break; case "shield": item.typeItem = TypeEquipmentCharacter.Shield; break; case "cape": //cape item.typeItem = TypeEquipmentCharacter.Torso; break; case "weapon": item.typeItem = TypeEquipmentCharacter.Weapon; break; } return(item); }