private bool IsEnoughGemToCompose(int itemId) { int num = 0; List <long> materailGemIds = this.GetMaterailGemIds(itemId, ref num); return(materailGemIds.get_Count() >= GemGlobal.GetComposeAmount(itemId)); }
public static bool IsCanCompose(int typeId) { if (GemGlobal.IsGemMaxLv(typeId)) { return(false); } int afterId = GemGlobal.GetAfterId(typeId); int composeAmount = GemGlobal.GetComposeAmount(afterId); int gemTotalCountInBag = GemGlobal.GetGemTotalCountInBag(typeId); return(gemTotalCountInBag >= composeAmount); }
public static int GetOneKeyComposeCost(List <MaterialGem> gems, int typeId) { gems.Reverse(); List <MaterialGem> list = new List <MaterialGem>(); using (List <MaterialGem> .Enumerator enumerator = gems.GetEnumerator()) { while (enumerator.MoveNext()) { MaterialGem current = enumerator.get_Current(); for (int i = 0; i < current.count; i++) { MaterialGem materialGem = new MaterialGem { typeId = current.typeId, gemId = current.gemId, count = current.count }; list.Add(materialGem); } } } int num = 0; int num2 = 0; while (num < list.get_Count() && list.get_Count() > 1) { int typeId2 = list.get_Item(num).typeId; int afterId = GemGlobal.GetAfterId(typeId2); int composeAmount = GemGlobal.GetComposeAmount(afterId); int num3 = 0; while (num < list.get_Count() && typeId2 == list.get_Item(num++).typeId) { num3++; } list.RemoveRange(0, num3); int num4 = num3 / composeAmount; for (int j = 0; j < num4; j++) { MaterialGem materialGem2 = new MaterialGem { typeId = afterId, gemId = -1L, count = 1 }; list.Insert(0, materialGem2); num2 += GemGlobal.GetAmount(afterId); } string text = string.Empty; using (List <MaterialGem> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { MaterialGem current2 = enumerator2.get_Current(); text = text + current2.typeId + " "; } } if (list.get_Count() == 1) { break; } num = 0; } return(num2); }
private List <long> GetMaterailGemIds(int itemId, ref int ownGemAmount) { List <long> list = new List <long>(); this.branchGems = new List <CostGem>(); int composeAmount = GemGlobal.GetComposeAmount(itemId); if (composeAmount <= 0) { return(list); } if (itemId == GemUI.instance.typeIdNext) { long id = GemUI.instance.GetCurrSlot().id; list.Add(id); this.branchGems.Add(new CostGem { gemId = id, gemNum = 1u }); ownGemAmount++; } int needId = GemGlobal.GetNeedId(itemId); List <Goods> list2 = BackpackManager.Instance.OnGetGood(needId); int num = 0; using (List <Goods> .Enumerator enumerator = list2.GetEnumerator()) { while (enumerator.MoveNext()) { Goods current = enumerator.get_Current(); num += current.GetCount(); } } ownGemAmount += num; int num2 = Mathf.Min(num, composeAmount - list.get_Count()); if (num2 == 0) { return(list); } using (List <Goods> .Enumerator enumerator2 = list2.GetEnumerator()) { while (enumerator2.MoveNext()) { Goods current2 = enumerator2.get_Current(); if (num2 == 0) { break; } long longId = current2.GetLongId(); int count = current2.GetCount(); int num3 = Mathf.Min(num2, count); num2 -= num3; for (int i = 0; i < num3; i++) { list.Add(longId); } this.branchGems.Add(new CostGem { gemId = longId, gemNum = (uint)num3 }); } } return(list); }
private void SetItemIcons(int itemId) { this.rootTypeId = itemId; this.branchTypeId = GemGlobal.GetNeedId(itemId); bool enabled = GemUI.instance.typeIdNext != this.rootTypeId; this.btnGrids[0].get_transform().GetComponent <Animator>().set_enabled(enabled); this.btnGrids[0].get_transform().set_localScale(Vector3.get_one()); GemSingleUI gemSingleUI = UIManagerControl.Instance.GetUIIfExist("GemSingleUI") as GemSingleUI; if (gemSingleUI != null) { gemSingleUI.SetOneGem(itemId); } if (GemGlobal.IsActiveOneKeyCompose(GemUI.instance.equipCurr, GemUI.instance.slotCurr, this.rootTypeId)) { this.btnCompose.get_transform().set_localPosition(this.btnCompose.get_transform().get_localPosition().AssignX(-92.2f)); this.btnOneKeyCompose.set_enabled(true); this.btnOneKeyCompose.get_gameObject().SetActive(true); this.btnOneKeyCompose.onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickBtnOneKeyCompose); List <MaterialGem> oneKeyComposeGems = GemGlobal.GetOneKeyComposeGems(GemUI.instance.equipCurr, GemUI.instance.slotCurr, this.rootTypeId); if (oneKeyComposeGems != null) { Text component = base.FindTransform("btnOneKeyCompose").FindChild("texCostVal").GetComponent <Text>(); int oneKeyComposeCost = GemGlobal.GetOneKeyComposeCost(oneKeyComposeGems, this.rootTypeId); component.set_text("x" + oneKeyComposeCost); this.SetCostActive("btnOneKeyCompose", true, oneKeyComposeCost); } else { this.SetCostActive("btnOneKeyCompose", false, 0); } } else { this.btnCompose.get_transform().set_localPosition(this.btnCompose.get_transform().get_localPosition().AssignXZero()); this.btnOneKeyCompose.set_enabled(false); this.btnOneKeyCompose.get_gameObject().SetActive(false); } this.SetScroll(GemUI.instance.typeIdNext, itemId); this.SetOneItemIcon(0, this.rootTypeId); this.SetOneItemIcon(1, this.branchTypeId); Text component2 = base.FindTransform("btnCompose").FindChild("texCostVal").GetComponent <Text>(); int amount = GemGlobal.GetAmount(itemId); component2.set_text("x" + amount); this.SetCostActive("btnCompose", true, amount); int num = 0; List <long> materailGemIds = this.GetMaterailGemIds(itemId, ref num); Transform transform = this.btnGrids[1].get_transform().Find("texPercent"); int composeAmount = GemGlobal.GetComposeAmount(itemId); string text = (materailGemIds.get_Count() < composeAmount) ? "<color=#ff0000>" : "<color=#00ff00>"; transform.GetComponent <Text>().set_text(string.Concat(new object[] { text, num, "</color>/", composeAmount })); }