private Dictionary <enumMaterialCategory, int> takeBonusMaterial(Dictionary <enumMaterialCategory, int> baseData, HashSet <enumMaterialCategory> takeTarget, double keisu, double tani) { Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>(); Mst_item_limit mst_item_limit = Mst_DataManager.Instance.Mst_item_limit[1]; foreach (enumMaterialCategory item in takeTarget) { int materialLimit = mst_item_limit.GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, item); double a = (double)baseData[item] * keisu; int num = (int)(Math.Ceiling(a) / tani); int num2 = (int)(tani * (double)num); int num3 = num2 + Comm_UserDatas.Instance.User_material[item].Value; int num4 = materialLimit - num3; if (num4 < 0) { num2 = materialLimit - Comm_UserDatas.Instance.User_material[item].Value; if (num2 < 0) { num2 = 0; } } dictionary.Add(item, num2); Comm_UserDatas.Instance.User_material[item].Add_Material(num2); } return(dictionary); }
private Dictionary <enumMaterialCategory, int> takeBonusMaterial(Dictionary <enumMaterialCategory, int> baseData, HashSet <enumMaterialCategory> takeTarget, double keisu, double tani) { Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>(); Mst_item_limit mst_item_limit = Mst_DataManager.Instance.Mst_item_limit.get_Item(1); using (HashSet <enumMaterialCategory> .Enumerator enumerator = takeTarget.GetEnumerator()) { while (enumerator.MoveNext()) { enumMaterialCategory current = enumerator.get_Current(); int materialLimit = mst_item_limit.GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, current); double num = (double)baseData.get_Item(current) * keisu; int num2 = (int)(Math.Ceiling(num) / tani); int num3 = (int)(tani * (double)num2); int num4 = num3 + Comm_UserDatas.Instance.User_material.get_Item(current).Value; int num5 = materialLimit - num4; if (num5 < 0) { num3 = materialLimit - Comm_UserDatas.Instance.User_material.get_Item(current).Value; if (num3 < 0) { num3 = 0; } } dictionary.Add(current, num3); Comm_UserDatas.Instance.User_material.get_Item(current).Add_Material(num3); } } return(dictionary); }
public Api_Result <User_ItemUseFmt> ItemUse(int useitem_id, bool force_flag, ItemExchangeKinds exchange_type) { Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>(); Dictionary <ItemGetKinds, Dictionary <int, int> > dictionary2 = new Dictionary <ItemGetKinds, Dictionary <int, int> >(); Dictionary <int, Dictionary <int, int> > dictionary3 = new Dictionary <int, Dictionary <int, int> >(); using (IEnumerator enumerator = Enum.GetValues(typeof(ItemGetKinds)).GetEnumerator()) { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); dictionary2.Add((ItemGetKinds)((int)current), new Dictionary <int, int>()); } } for (int i = 1; i <= 3; i++) { dictionary3.Add(i, new Dictionary <int, int>()); } Api_Result <User_ItemUseFmt> api_Result = new Api_Result <User_ItemUseFmt>(); api_Result.data = new User_ItemUseFmt(); Mst_useitem mst_useitem = null; if (!Mst_DataManager.Instance.Mst_useitem.TryGetValue(useitem_id, ref mst_useitem)) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } if (mst_useitem.Usetype != 4) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } Mem_useitem mem_useitem; if (!Comm_UserDatas.Instance.User_useItem.TryGetValue(useitem_id, ref mem_useitem)) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } int num = mst_useitem.GetItemExchangeNum(exchange_type); if (num == 0) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } if (mem_useitem.Value < num) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } Dictionary <enumMaterialCategory, Mem_material> user_material = Comm_UserDatas.Instance.User_material; IEnumerable <XElement> enumerable = this.get_package_item(exchange_type, mst_useitem); if (enumerable != null) { Mst_item_limit mst_item_limit = Mst_DataManager.Instance.Mst_item_limit.get_Item(1); var enumerable2 = Enumerable.Select(Enumerable.Select(enumerable, (XElement item) => new { item = item, category = (enumMaterialCategory)((int)Enum.Parse(typeof(enumMaterialCategory), item.Element("Material_id").get_Value())) }), <> __TranspIdent6 => new { material_id = < > __TranspIdent6.category, useitem_id = int.Parse(< > __TranspIdent6.item.Element("Useitem_id").get_Value()), slotitem_id = int.Parse(< > __TranspIdent6.item.Element("Slotitem_id").get_Value()), items = int.Parse(< > __TranspIdent6.item.Element("Items").get_Value()), max_items = mst_item_limit.GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, <> __TranspIdent6.category) });
public Api_Result <User_ItemUseFmt> ItemUse(int useitem_id, bool force_flag, ItemExchangeKinds exchange_type) { Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>(); Dictionary <ItemGetKinds, Dictionary <int, int> > dictionary2 = new Dictionary <ItemGetKinds, Dictionary <int, int> >(); Dictionary <int, Dictionary <int, int> > dictionary3 = new Dictionary <int, Dictionary <int, int> >(); foreach (object value6 in Enum.GetValues(typeof(ItemGetKinds))) { dictionary2.Add((ItemGetKinds)(int)value6, new Dictionary <int, int>()); } for (int i = 1; i <= 3; i++) { dictionary3.Add(i, new Dictionary <int, int>()); } Api_Result <User_ItemUseFmt> api_Result = new Api_Result <User_ItemUseFmt>(); api_Result.data = new User_ItemUseFmt(); Mst_useitem value = null; if (!Mst_DataManager.Instance.Mst_useitem.TryGetValue(useitem_id, out value)) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } if (value.Usetype != 4) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } if (!Comm_UserDatas.Instance.User_useItem.TryGetValue(useitem_id, out Mem_useitem value2)) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } int num = value.GetItemExchangeNum(exchange_type); if (num == 0) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } if (value2.Value < num) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } Dictionary <enumMaterialCategory, Mem_material> user_material = Comm_UserDatas.Instance.User_material; IEnumerable <XElement> enumerable = get_package_item(exchange_type, value); if (enumerable != null) { Mst_item_limit mst_item_limit = Mst_DataManager.Instance.Mst_item_limit[1]; var enumerable2 = from item in enumerable let category = (enumMaterialCategory)(int)Enum.Parse(typeof(enumMaterialCategory), item.Element("Material_id").Value) select new { material_id = category, useitem_id = int.Parse(item.Element("Useitem_id").Value), slotitem_id = int.Parse(item.Element("Slotitem_id").Value), items = int.Parse(item.Element("Items").Value), max_items = mst_item_limit.GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, category) }; foreach (var item in enumerable2) { if (item.material_id != 0) { int num2 = LimitGetCount(user_material[item.material_id].Value, item.items, item.max_items); if (!force_flag && num2 != item.items) { api_Result.data.CautionFlag = true; return(api_Result); } dictionary.Add(item.material_id, item.items); dictionary3[1].Add((int)item.material_id, num2); } else if (item.useitem_id != 0) { int now_count = 0; if (Comm_UserDatas.Instance.User_useItem.TryGetValue(item.useitem_id, out Mem_useitem value3)) { now_count = value3.Value; } int value4 = LimitGetCount(now_count, item.items, item.max_items); dictionary2[ItemGetKinds.UseItem].Add(item.useitem_id, item.items); dictionary3[2].Add(item.useitem_id, value4); } else if (item.slotitem_id != 0) { dictionary2[ItemGetKinds.SlotItem].Add(item.slotitem_id, item.items); dictionary3[3].Add(item.slotitem_id, item.items); } } foreach (KeyValuePair <int, Dictionary <int, int> > item2 in dictionary3) { int key = item2.Key; foreach (KeyValuePair <int, int> item3 in item2.Value) { int key2 = item3.Key; int value5 = item3.Value; switch (key) { case 1: { enumMaterialCategory key3 = (enumMaterialCategory)key2; user_material[key3].Add_Material(value5); break; } case 2: Comm_UserDatas.Instance.Add_Useitem(key2, value5); break; case 3: Comm_UserDatas.Instance.Add_Slot(new List <int> { key2 }); break; } } } } else if (value.Id == 10 || value.Id == 11 || value.Id == 12) { Mem_basic user_basic = Comm_UserDatas.Instance.User_basic; int get_count = int.Parse(value.Description2) * value2.Value; int max_count = 200000; int num3 = LimitGetCount(user_basic.Fcoin, get_count, max_count); dictionary2[ItemGetKinds.UseItem].Add(44, num3); user_basic.AddCoin(num3); num = value2.Value; } else if (value.Id == 53) { Mem_basic user_basic2 = Comm_UserDatas.Instance.User_basic; if (user_basic2.Max_chara >= user_basic2.GetPortMaxExtendNum()) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } dictionary2[ItemGetKinds.UseItem].Add(53, 1); user_basic2.PortExtend(1); } value2.Sub_UseItem(num); api_Result.data.GetItem = GetItemFmt(dictionary2); api_Result.data.Material = dictionary; return(api_Result); }