public static List <MaterialGem> GetOneKeyComposeGems(EquipLibType.ELT equipNum, int slotNum, int nextTypeId) { List <MaterialGem> list = new List <MaterialGem>(); int value = GemGlobal.GetValue(nextTypeId); int num = 0; GemEmbedInfo gemEmbedInfo = GemGlobal.GetGemInfo(equipNum, slotNum); for (int needId = GemGlobal.GetNeedId(nextTypeId); needId != 0; needId = GemGlobal.GetNeedId(needId)) { if (gemEmbedInfo != null && gemEmbedInfo.typeId == needId) { list.Add(new MaterialGem { typeId = gemEmbedInfo.typeId, gemId = gemEmbedInfo.id, count = 1 }); num += GemGlobal.GetValue(needId); if (num == value) { return(list); } gemEmbedInfo = null; } List <Goods> list2 = BackpackManager.Instance.OnGetGood(needId); for (int i = 0; i < list2.get_Count(); i++) { Goods goods = list2.get_Item(i); int num2 = 0; for (int j = 0; j < goods.GetCount(); j++) { num2++; num += GemGlobal.GetValue(needId); if (num == value) { list.Add(new MaterialGem { typeId = needId, gemId = goods.GetLongId(), count = num2 }); return(list); } } list.Add(new MaterialGem { typeId = needId, gemId = goods.GetLongId(), count = goods.GetCount() }); } } return(null); }
private List <CostGem> GetComposeMaterialGems(int currSlot, int typeId) { List <MaterialGem> lowerGems = this.GetLowerGems(currSlot, typeId); if (lowerGems.get_Count() == 0) { return(null); } int value = GemGlobal.GetValue(typeId); int[] array = new int[lowerGems.get_Count()]; bool flag = false; while (array[lowerGems.get_Count() - 1] <= lowerGems.get_Item(lowerGems.get_Count() - 1).count) { for (int i = 0; i < lowerGems.get_Count() - 1; i++) { if (array[i] > lowerGems.get_Item(i).count) { array[i] = 0; array[i + 1]++; } } int num = 0; for (int j = 0; j < lowerGems.get_Count(); j++) { num += array[j] * GemGlobal.GetValue(lowerGems.get_Item(j).typeId); } if (num == value) { flag = true; break; } array[0]++; } if (!flag) { return(null); } List <CostGem> list = new List <CostGem>(); for (int k = 0; k < array.Length; k++) { if (array[k] > 0) { list.Add(new CostGem { gemId = lowerGems.get_Item(k).gemId, gemNum = (uint)array[k] }); } } return(list); }
public static bool IsCanCompose(int equipNum, int slotNum, int currTypeId) { if (GemGlobal.IsGemMaxLv(currTypeId)) { return(false); } if (currTypeId == 0) { return(false); } int afterId = GemGlobal.GetAfterId(currTypeId); if (!GemGlobal.IsGemEnoughLv(afterId)) { return(false); } if (!GemGlobal.IsEnoughMoneyToCompose(afterId)) { return(false); } int value = GemGlobal.GetValue(afterId); int needId = GemGlobal.GetNeedId(afterId); int num = 0; while (needId != 0) { List <Goods> list = BackpackManager.Instance.OnGetGood(needId); using (List <Goods> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { Goods current = enumerator.get_Current(); int count = current.GetCount(); int itemId = current.GetItemId(); if (GemGlobal.IsGemEnoughLv(itemId)) { int value2 = GemGlobal.GetValue(itemId); num += value2 * count; if (num >= value) { return(true); } } } } needId = GemGlobal.GetNeedId(needId); } return(false); }