示例#1
0
    private List <MaterialGem> GetLowerGems(int currSlot, int typeId)
    {
        List <MaterialGem> list = new List <MaterialGem>();

        for (int needId = GemGlobal.GetNeedId(typeId); needId != 0; needId = GemGlobal.GetNeedId(needId))
        {
            List <Goods> list2 = BackpackManager.Instance.OnGetGood(needId);
            using (List <Goods> .Enumerator enumerator = list2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Goods current = enumerator.get_Current();
                    list.Add(new MaterialGem
                    {
                        typeId = needId,
                        gemId  = current.GetLongId(),
                        count  = current.GetCount()
                    });
                }
            }
        }
        list.Reverse();
        GemEmbedInfo equipSlot = this.GetEquipSlot(currSlot);

        if (equipSlot.typeId != 0)
        {
            list.Add(new MaterialGem
            {
                typeId = equipSlot.typeId,
                gemId  = equipSlot.id,
                count  = 1
            });
        }
        return(list);
    }
示例#2
0
    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);
    }
示例#3
0
    private List <int> GetGenealogy(int rootTypeId, int branchTypeId)
    {
        List <int> list = new List <int>();

        list.Add(rootTypeId);
        int needId = GemGlobal.GetNeedId(rootTypeId);

        while (needId != 0 && needId >= branchTypeId)
        {
            list.Add(needId);
            needId = GemGlobal.GetNeedId(needId);
        }
        return(list);
    }
示例#4
0
    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);
    }
示例#5
0
    private void OnClickBtnGrid(GameObject go)
    {
        string text = go.get_name().Substring(7);
        int    afterId;

        if (int.Parse(text) == 0)
        {
            if (GemUI.instance.typeIdNext == this.rootTypeId)
            {
                return;
            }
            afterId = GemGlobal.GetAfterId(this.rootTypeId);
        }
        else
        {
            afterId = this.branchTypeId;
            if (GemGlobal.GetNeedId(afterId) == 0)
            {
                UIManagerControl.Instance.OpenSourceReferenceUI(afterId, new Action(this.CloseUI));
                return;
            }
        }
        this.SetItemIcons(afterId);
    }
示例#6
0
    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);
    }
示例#7
0
    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
        }));
    }