public int GetBuyNum() { Comm_UserDatas instance = Comm_UserDatas.Instance; List <int> list = new List <int>(); foreach (PayItemEffectInfo item2 in Items) { int item = 0; int num = 0; if (item2.Type == 1 && item2.MstId == 53) { int num2 = instance.User_basic.GetPortMaxExtendNum() - instance.User_basic.Max_chara; int num3 = 0; if (instance.User_useItem.TryGetValue(53, out Mem_useitem value)) { num3 = value.Value; } if (num2 > 0) { item = num2 / 10 - num3; } } else if (item2.Type == 1) { Mem_useitem value2 = null; if (Comm_UserDatas.Instance.User_useItem.TryGetValue(item2.MstId, out value2)) { num = value2.Value; } int num4 = 3000 - num; if (num4 > 0) { item = num4 / item2.Count; } } else if (item2.Type == 2) { item = int.MaxValue; } else if (item2.Type == 3) { enumMaterialCategory mstId = (enumMaterialCategory)item2.MstId; Dictionary <int, Mst_item_limit> mst_item_limit = Mst_DataManager.Instance.Mst_item_limit; int materialLimit = Mst_DataManager.Instance.Mst_item_limit[1].GetMaterialLimit(mst_item_limit, mstId); num = Comm_UserDatas.Instance.User_material[mstId].Value; int num5 = materialLimit - num; if (num5 > 0) { item = num5 / item2.Count; } } list.Add(item); } int num6 = list.Min(); return((num6 != int.MaxValue) ? num6 : (-1)); }
public int GetBuyNum() { Comm_UserDatas instance = Comm_UserDatas.Instance; List <int> list = new List <int>(); using (List <PayItemEffectInfo> .Enumerator enumerator = this.Items.GetEnumerator()) { while (enumerator.MoveNext()) { PayItemEffectInfo current = enumerator.get_Current(); int num = 0; int num2 = 0; if (current.Type == 1 && current.MstId == 53) { int num3 = instance.User_basic.GetPortMaxExtendNum() - instance.User_basic.Max_chara; int num4 = 0; Mem_useitem mem_useitem; if (instance.User_useItem.TryGetValue(53, ref mem_useitem)) { num4 = mem_useitem.Value; } if (num3 > 0) { num = num3 / 10 - num4; } } else if (current.Type == 1) { Mem_useitem mem_useitem2 = null; if (Comm_UserDatas.Instance.User_useItem.TryGetValue(current.MstId, ref mem_useitem2)) { num2 = mem_useitem2.Value; } int num5 = 3000 - num2; if (num5 > 0) { num = num5 / current.Count; } } else if (current.Type == 2) { num = 2147483647; } else if (current.Type == 3) { enumMaterialCategory mstId = (enumMaterialCategory)current.MstId; Dictionary <int, Mst_item_limit> mst_item_limit = Mst_DataManager.Instance.Mst_item_limit; int materialLimit = Mst_DataManager.Instance.Mst_item_limit.get_Item(1).GetMaterialLimit(mst_item_limit, mstId); num2 = Comm_UserDatas.Instance.User_material.get_Item(mstId).Value; int num6 = materialLimit - num2; if (num6 > 0) { num = num6 / current.Count; } } list.Add(num); } } int num7 = Enumerable.Min(list); return((num7 != 2147483647) ? num7 : -1); }