private void SetRandomView()
    {
        randomequip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon);
        randomlvfloor_cr.SetAlpha(equip.StrengthenLv);
        randomlv_txt.text       = equip.StrengthenLv > 0 ? " +" + equip.StrengthenLv: "";
        randomborder_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[equip.ItemData.rare - 1]);
        equipname_txt.text      = equip.ItemData.name;

        StringBuilder append = new StringBuilder();

        for (int i = 0, length = equip.wishs.Length; i < length; ++i)
        {
            append.Append(AttrUtil.GetAttribute(equip.wishs[i].wish.attr));
            append.Append(": +");
            append.Append(AttrUtil.ShowText(equip.wishs[i].wish.attr, equip.wishs[i].wish.num, equip.wishs[i].wish.per));
            append.Append("\n");
            locks[i].isOn = equip.wishs[i].isLock;
        }
        oldattr_txt.text = append.ToString();

        StringBuilder temp = new StringBuilder();

        for (int i = 0, length = equip.tempWishs.Length; i < length; ++i)
        {
            temp.Append(AttrUtil.GetAttribute(equip.tempWishs[i].attr));
            temp.Append(": +");
            temp.Append(AttrUtil.ShowText(equip.tempWishs[i].attr, equip.tempWishs[i].num, equip.tempWishs[i].per));
            temp.Append("\n");
        }
        newattr_txt.text = temp.ToString();

        randomspend_txt.text = JsonMgr.GetSingleton().GetGlobalIntArrayByID(expend).value.ToString();
    }
Exemple #2
0
    public void Open(EquipData equip)
    {
        this.data = equip;
        int rare = equip.ItemData.rare;

        border_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[rare - 1]);
        string color = ColorMgr.Colors[rare - 1];

        name_txt.text  = string.Format("<color=#{0}>{1}</color>", color, equip.JsonData.Name);
        state_txt.text = "";
        levle_txt.text = equip.StrengthenLv > 0 ? "+" + equip.StrengthenLv: "";
        lvfloor_cr.SetAlpha(equip.StrengthenLv);
        des_txt.text     = equip.ItemData.usedes;
        equip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon);
        EventListener.Get(strengthen_btn.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Close(UIID.StrengthenTip);
            UIFace.GetSingleton().Open(UIID.Strengthen, equip);
        };
        StringBuilder sb = new StringBuilder();

        Pro[] p = equip.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append(": +");
            sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per));
            sb.Append("\n");
        }
        baseattr_txt.text = attr_txt.text = sb.ToString();
        //appendattr_obj.SetActive(equip.wishs.Length > 0);
        sb.Length = 0;
        for (int i = 0, length = equip.wishs.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(equip.wishs[i].wish.attr));
            sb.Append(": +");
            sb.Append(AttrUtil.ShowText(equip.wishs[i].wish.attr, equip.wishs[i].wish.num, equip.wishs[i].wish.per));
            sb.Append("\n");
        }
        appendattr_txt.text = equip.wishs.Length > 0 ? sb.ToString(): "<color=#FFFF00>提升装备品质\n开放更多属性</color>";
        p = equip.Innate;
        constattr_obj.SetActive(p.Length != 0);
        sb.Length = 0;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append(": +");
            sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per));
            sb.Append("\n");
        }
        constattr_txt.text = sb.ToString();
        sb = null;
    }
Exemple #3
0
    private void SetAttrView()
    {
        int upexp = composeItem.LevelUpExp() - composeItem.Exp;

        plusLevel = composeItem.Level;
        float temp = playExp;

        while (temp >= upexp)
        {
            plusLevel++;
            temp -= upexp;
            upexp = composeItem.LevelUpExp(plusLevel);
        }

        Pro[]         proa   = composeItem.Attribute;
        StringBuilder sb     = new StringBuilder();
        StringBuilder sbnext = new StringBuilder();

        sb.Append(composeItem.Level + "级");
        sbnext.Append(plusLevel + "级");

        for (int i = 0; i < proa.Length; ++i)
        {
            sb.Append("\n");
            sbnext.Append("\n");
            sb.Append(AttrUtil.GetAttribute(proa[i].attr));
            sbnext.Append(AttrUtil.GetAttribute(proa[i].attr));
            sb.Append("  +");
            sbnext.Append("  +");
            if (proa[i].num != 0)
            {
                sb.Append(AttrUtil.ShowText(proa[i].attr, proa[i].num));
                sbnext.Append(AttrUtil.ShowText(proa[i].attr, proa[i].num));
            }
            else if (proa[i].per != 0)
            {
                sb.Append(AttrUtil.ShowText(proa[i].attr, 0, proa[i].per));
                sbnext.Append(AttrUtil.ShowText(proa[i].attr, 0, proa[i].per));
            }
            sb.Append("\n");
            sbnext.Append("\n");
        }

        attr_txt.text     = sb.ToString();
        nextattr_txt.text = sbnext.ToString();
        SetAttrActive(playExp != 0);
    }
    private void SetStrengthenView()
    {
        StringBuilder sb     = new StringBuilder();
        StringBuilder nextSB = new StringBuilder();

        Pro[] p = equip.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            nextSB.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append(": +");
            nextSB.Append(": +");
            sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per));
            nextSB.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num * 2 + p[i].num, equip.JsonData.Attribute[i].per * 2 + p[i].per));
            sb.Append("\n");
            nextSB.Append("\n");
        }
        attr_txt.supportRichText = true;
        string title = equip.ItemData.name + (equip.StrengthenLv == 0 ? "" : " +" + equip.StrengthenLv) + "\n";

        title             = title.AddColorLabel(ColorMgr.Colors[equip.ItemData.rare - 1]);
        attr_txt.text     = title + sb;
        title             = equip.ItemData.name + " +" + (equip.StrengthenLv + 1) + "\n";
        title             = title.AddColorLabel(ColorMgr.Colors[equip.ItemData.rare - 1]);
        thenattr_txt.text = title + nextSB;
        sb     = null;
        nextSB = null;

        equip_img.sprite      = thenequip_img.sprite = ResourceMgr.Instance.LoadSprite(equip.ItemData.icon);
        thenborder_img.sprite = border_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[equip.ItemData.rare - 1]);
        lvfloor_cr.SetAlpha(equip.StrengthenLv);
        lv_txt.text = equip.StrengthenLv == 0 ? "" : "+" + equip.StrengthenLv;
        thenlvfloor_cr.SetAlpha(1);
        thenlv_txt.text = "+" + (equip.StrengthenLv + 1);
        EventListener.Get(strengthen_btn.gameObject).OnClick = e =>
        {
            if (EquipMgr.GetSingleton().UpEquip(equip))
            {
                StrengthenOK_img.GetComponent <UISprite>().Play();
            }
            SetStrengthenView();
        };
        EventListener.Get(strengthenonekey_btn.gameObject).OnClick = e =>
        {
        };
        spend_txt.text = JsonMgr.GetSingleton().GetStrengthenSpendByID(equip.StrengthenLv).spend.ToString();
    }
    public void AttrTxet(ScrollRect rect, Attr attr, float num)
    {
        EventListener.Get(gameObject).BegineDragEvent = e =>
        {
            rect.OnBeginDrag(e);
        };
        EventListener.Get(gameObject).DragEvent = e =>
        {
            rect.OnDrag(e);
        };
        EventListener.Get(gameObject).EndDragEvent = e =>
        {
            rect.OnEndDrag(e);
        };

        texts[0].text = string.Format("<color=#FFFF00>{0}</color>", AttrUtil.GetAttribute(attr));
        texts[1].text = string.Format("<color=#4AE000>{0}</color>", AttrUtil.ShowText(attr, num));
    }
    public void Open(TotemData data, SHOWBUTTON btnCtrl)
    {
        take_btn.gameObject.SetActive(btnCtrl == SHOWBUTTON.Etake);
        takeoff_btn.gameObject.SetActive(btnCtrl == SHOWBUTTON.EtakeOff);

        EventListener.Get(take_btn.gameObject).OnClick = e =>
        {
            ZEventSystem.Dispatch(EventConst.TAKETOTEM, data);
            UIFace.GetSingleton().Close(UIID.DivinationTip);
        };
        EventListener.Get(compose_btn.gameObject).OnClick = e =>
        {
            UIFace.GetSingleton().Open(UIID.CompostDivination, data);
            ZEventSystem.Dispatch(EventConst.ONOPENCOMPOSE);
            UIFace.GetSingleton().Close(UIID.DivinationTip);
        };
        EventListener.Get(takeoff_btn.gameObject).OnClick = e =>
        {
            TotemMgr.GetSingleton().TakeOffTotem(data);
            ZEventSystem.Dispatch(EventConst.REFRESHRIGHT, false);
            UIFace.GetSingleton().Close(UIID.DivinationTip);
        };
        item_img.sprite = ResourceMgr.Instance.LoadSprite(data.ItemData.icon);
        int    rare  = data.ItemData.rare;
        string color = ColorMgr.Colors[rare - 1];

        name_txt.text         = string.Format("<color=#{0}>{1}</color>", color, data.TotemConfig.Name);
        level_txt.text        = string.Format("<color=#{0}>Lv.{1}</color>", color, data.Level);
        slider_img.fillAmount = data.Exp / (float)data.LevelUpExp();
        prog_txt.text         = data.Exp + "/" + data.LevelUpExp();
        Pro[]         p  = data.Attribute;
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < p.Length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append("  +");
            sb.Append(AttrUtil.ShowText(p[i].attr, p[i].num, p[i].per));
            sb.Append("\n");
        }
        attr_txt.text = sb.ToString();
    }
Exemple #7
0
    private void openItemTip(int itemId, Vector2 pos, int align, Vector2 offset)
    {
        JsonData.ItemConfig itemJson = JsonMgr.GetSingleton().GetItemConfigByID(itemId);
        if (itemJson == null)
        {
            EDebug.LogErrorFormat("openItemTip, invalid item id {0}", itemId);
            return;
        }
        itemTipsView.SetInfo(itemId, 0);
        string itemColor = ColorMgr.Colors[itemJson.rare - 1];

        this.ItemName_txt.text = itemJson.name.AddColorLabel(itemColor);
        this.ItemNum_txt.text  = string.Format(JsonMgr.GetSingleton().GetGlobalStringArrayByID(2005).desc,
                                               ItemMgr.Instance.GetItemNum(itemId).ToString());
        this.ItemPrice_txt.text = itemJson.price.ToString();
        if (itemJson.type == FuncType.EQUIP)
        {
            _sb.Length = 0;
            JsonData.Equip equipJson = JsonMgr.GetSingleton().GetEquipByID(itemId);
            if (equipJson != null)
            {
                for (int idx = 0; idx < equipJson.Attribute.Length; ++idx)
                {
                    Pro p = equipJson.Attribute[idx];
                    _sb.AppendLine(string.Format("  {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per)));
                }
                for (int idx = 0; idx < equipJson.Innate.Length; ++idx)
                {
                    Pro p = equipJson.Innate[idx];
                    _sb.AppendLine(string.Format("  {0} +{1}", AttrUtil.GetAttribute(p.attr), AttrUtil.ShowText(p.attr, p.num, p.per)));
                }
                _sb.Remove(_sb.Length - 1, 1);
                this.ItemIntroduce_txt.alignment = TextAnchor.MiddleLeft;
                this.ItemIntroduce_txt.text      = _sb.ToString();
            }
            else
            {
                EDebug.LogErrorFormat("openItemTip invalid equip id {0}", itemId);
            }
        }
        else
        {
            this.ItemIntroduce_txt.alignment = TextAnchor.UpperLeft;
            this.ItemIntroduce_txt.text      = itemJson.propertydes;
        }
        this.itemtips_rect.anchoredPosition = calAlignment(pos, this.itemtips_rect.sizeDelta, align, offset);
        this.itemtips_rect.gameObject.SetActive(true);
    }
    private void SetAdvancedView()
    {
        int[] targets = equip.JsonData.Advanced;
        int   target  = PlayerPrefs.GetInt("advancedtarget");

        //处理紫升橙
        if (targets.Length > 1)
        {
            bool has = false;
            for (int i = 0; i < targets.Length; ++i)
            {
                if (targets[i] == target)
                {
                    has = true;
                }
            }
            if (target != 0 && has)
            {
                advancedequip_img.raycastTarget = true;
                target_img.raycastTarget        = false;
                EventListener.Get(advancedequip_img.gameObject).OnClick = e =>
                {
                    attr_obj.SetActive(false);
                    null_obj.SetActive(true);
                    for (int i = 0, length = parent_trf.childCount; i < length; ++i)
                    {
                        DestroyImmediate(parent_trf.GetChild(0).gameObject);
                    }
                    target = 0;
                    PlayerPrefs.SetInt("advancedtarget", 0);
                    UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets);
                };
            }
            else
            {
                advancedequip_img.gameObject.SetActive(false);
                advancedborder_img.gameObject.SetActive(false);
                target_img.gameObject.SetActive(true);
                attr_obj.SetActive(false);
                null_obj.SetActive(true);
                target_img.raycastTarget        = true;
                advancedequip_img.raycastTarget = false;

                EventListener.Get(target_img.gameObject).OnClick = e =>
                {
                    PlayerPrefs.SetInt("advancedtarget", 0);
                    UIFace.GetSingleton().Open(UIID.EuqipTipCtrl, targets);
                };
                return;
            }
        }
        else if (targets.Length == 0)
        {
            advancedequip_img.gameObject.SetActive(false);
            advancedborder_img.gameObject.SetActive(false);
            target_img.gameObject.SetActive(true);
            attr_obj.SetActive(false);
            null_obj.SetActive(true);
            target_img.raycastTarget        = true;
            advancedequip_img.raycastTarget = false;
            EventListener.Get(target_img.gameObject).OnClick = e =>
            {
                CanvasView.Instance.AddNotice("当前装备已进阶至最大等级");
            };
            return;
        }
        else
        {
            advancedequip_img.raycastTarget = false;
            target = targets[0];
        }

        advancedequip_img.gameObject.SetActive(true);
        advancedborder_img.gameObject.SetActive(true);
        target_img.gameObject.SetActive(false);
        attr_obj.SetActive(true);
        null_obj.SetActive(false);
        AdvancedSpend aspend = JsonMgr.GetSingleton().GetAdvancedSpendByID(target);

        SetSpendView(aspend);
        EventListener.Get(advanced_btn.gameObject).OnClick = e =>
        {
            if (equip.JsonData.Advanced.Length == 0)
            {
                CanvasView.Instance.AddNotice("当前装备已进阶至最大等级");
                return;
            }
            else if (equip.StrengthenLv < equip.JsonData.AdvancedCondition)
            {
                CanvasView.Instance.AddNotice(string.Format("进阶失败!需要强化等级达到{0},才能继续进阶。", equip.JsonData.AdvancedCondition));
                return;
            }
            else if (target == 0)
            {
                return;
            }
            for (int i = 0, length = parent_trf.childCount; i < length; ++i)
            {
                DestroyImmediate(parent_trf.GetChild(0).gameObject);
            }

            equip.EquipId = target;
            SetAdvancedView();
            HeroData hero = HeroMgr.GetSingleton().GetHeroData(equip.HeroId);
            if (hero == null)
            {
                return;
            }
            hero.ClearEquipAttr();
            ZEventSystem.Dispatch(EventConst.REFRESHRIGHT);
        };
        StringBuilder sb = new StringBuilder();

        Pro[] p = equip.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            sb.Append(AttrUtil.GetAttribute(p[i].attr));
            sb.Append(": +");
            sb.Append(AttrUtil.ShowText(p[i].attr, equip.JsonData.Attribute[i].num + p[i].num, equip.JsonData.Attribute[i].per + p[i].per));
            sb.Append("\n");
        }
        name_txt.supportRichText = true;
        string color = ColorMgr.Colors[equip.ItemData.rare - 1];

        name_txt.text     = string.Format("<color=#{0}>{1}{2}</color>", color, equip.JsonData.Name, equip.StrengthenLv > 0 ? "  +" + equip.StrengthenLv : "");
        baseattr_txt.text = string.Format("<color=#{0}>{1}</color>", color, sb);

        Equip         q      = JsonMgr.GetSingleton().GetEquipByID(target);
        StringBuilder append = new StringBuilder();

        p = q.Attribute;
        for (int i = 0, length = p.Length; i < length; ++i)
        {
            append.Append(AttrUtil.GetAttribute(p[i].attr));
            append.Append(": +");
            append.Append(AttrUtil.ShowText(p[i].attr, p[i].num + p[i].num * equip.StrengthenLv, p[i].per + p[i].per * equip.StrengthenLv));
            append.Append("\n");
        }
        ItemConfig ic = JsonMgr.GetSingleton().GetItemConfigByID(target);

        color = ColorMgr.Colors[ic.rare - 1];
        advanced_txt.supportRichText = true;
        advanced_txt.text            = string.Format("<color=#{0}>{1}{2}</color>", color, q.Name, equip.StrengthenLv > 0 ? "  +" + equip.StrengthenLv : "");
        advancedattr_txt.text        = string.Format("<color=#{0}>{1}</color>", color, append);
        sb     = null;
        append = null;
    }
    private void ShowOfficer()
    {
        showGo = Officer_trf;
        showGo.SetParent(Right_trf);

        LOfficer_obj.SetActive(true);
        Left_obj.SetActive(false);
        HeroRare ou = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare);
        HeroRare up = JsonMgr.GetSingleton().GetHeroRareByID(Mathf.Min(heroData.Rare + 1));

        if (ou == null)
        {
            return;
        }
        if (up == null)
        {
            return;
        }
        currentleft_img.sprite = currentright_img.sprite = ResourceMgr.Instance.LoadSprite(ou.Officer);
        upleft_img.sprite      = upright_img.sprite = ResourceMgr.Instance.LoadSprite(up.Officer);
        current_txt.text       = ou.Name.AddColorLabel(ou.Color);
        up_txt.text            = up.Name.AddColorLabel(up.Color);
        HeroHeadView hhvL = LeftHead_trf.GetComponent <HeroHeadView>();
        HeroHeadView hhvR = RightHea_trf.GetComponent <HeroHeadView>();

        hhvL.Init();
        hhvR.Init();
        hhvL.SetHeroInfo(heroData.JsonData.headid, heroData.Rare, heroData.Star, heroData.Level, true);
        hhvR.SetHeroInfo(heroData.JsonData.headid, heroData.Rare + 1, heroData.Star, heroData.Level, true);
        needhonor_txt.color = Role.Instance.Honor < up.NeedNum ? Color.red : Color.white;
        needhonor_txt.text  = up.NeedNum.ToString("N0");
        EventListener.Get(up_btn.gameObject).OnClick = e =>
        {
            if (heroData.Rare >= JsonMgr.GetSingleton().GetGlobalIntArrayByID(1023).value)
            {
                CanvasView.Instance.AddNotice("高处不胜寒呐~~");
                return;
            }
            if (Role.Instance.Honor < up.NeedNum)
            {
                CanvasView.Instance.AddNotice("荣誉不足!!");
                return;
            }
            HeroMgr.GetSingleton().UnfixOfficer(heroData);
            heroData.Rare++;
            ShowOfficer();
            ShowSide(false);
        };
        Dictionary <Attr, float> ret = heroData.RareAttr(false);
        StringBuilder            sb  = new StringBuilder();

        foreach (var item in ret)
        {
            if (item.Value != 0)
            {
                sb.Append(AttrUtil.GetAttribute(item.Key));
                sb.Append(" ");
                sb.Append(AttrUtil.ShowText(item.Key, item.Value));
                sb.Append("\n");
            }
        }
        leftpro_txt.text = sb.ToString();
        Dictionary <Attr, float> next = heroData.RareAttr(true);

        sb.Length = 0;
        foreach (var item in next)
        {
            if (item.Value != 0)
            {
                sb.Append(AttrUtil.GetAttribute(item.Key));
                sb.Append(" ");
                sb.Append(AttrUtil.ShowText(item.Key, item.Value));
                sb.Append(" ");
                float befor = 0;
                if (ret.ContainsKey(item.Key))
                {
                    befor = ret[item.Key];
                }
                sb.Append(string.Format(@"<color=#00FF00> (+{0})</color>", AttrUtil.ShowText(item.Key, item.Value - befor)));
                sb.Append("\n");
            }
        }
        rightpro_txt.text = sb.ToString();

        int[]          officers   = HeroMgr.GetSingleton().GetUnLockOfficer(heroData.Rare);
        int            childCount = OfficerList_obj.transform.childCount;
        List <Officer> os         = SortPost(officers);

        for (int i = 0; i < os.Count; ++i)
        {
            Officer o = os[i];
            if (o == null)
            {
                continue;
            }
            GameObject itemgo;
            if (i < childCount)
            {
                itemgo = OfficerList_obj.transform.GetChild(i).gameObject;
            }
            else
            {
                itemgo = Instantiate(officerGo, OfficerList_obj.transform, false);
            }
            OfficerItem oi = itemgo.GetComponent <OfficerItem>();

            oi.SetView(heroData, o);
            EventListener.Get(oi.take_btn.gameObject).OnClick = e =>
            {
                int takeID = HeroMgr.GetSingleton().IsTake(o.ID);
                if (takeID == heroData.HeroId)
                {
                    return;
                }
                if (takeID != 0)
                {
                    string  name = HeroMgr.GetSingleton().GetHeroData(takeID).JsonData.name;
                    TipCtrl ctrl = (TipCtrl)UIFace.GetSingleton().Open(UIID.Tip, 1, name);
                    ctrl.SetHandler(delegate() { UIFace.GetSingleton().Close(UIID.Tip); },
                                    delegate()
                    {
                        UIFace.GetSingleton().Close(UIID.Tip);
                        HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                        ShowOfficer();
                    });
                }
                else
                {
                    HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                    ShowOfficer();
                }
            };
            EventListener.Get(itemgo).OnClick = e =>
            {
                oi.OnClickItem();
                float minu   = (oi.highlightY - oi.normalY);
                float height = oi.down ? minu : -minu;
                officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, officerrt.sizeDelta.y + height);
            };
            if (oi.down)
            {
                oi.OnClickItem();
            }
            EventListener.Get(itemgo).BegineDragEvent = e =>
            {
                OfficerSV_sr.OnBeginDrag(e);
            };
            EventListener.Get(itemgo).DragEvent = e =>
            {
                OfficerSV_sr.OnDrag(e);
            };
            EventListener.Get(itemgo).EndDragEvent = e =>
            {
                OfficerSV_sr.OnEndDrag(e);
            };
        }
        float maxHeight = (officers.Length + 0.5f) * (10.6f + 101);

        officerrt.sizeDelta = new Vector2(officerrt.sizeDelta.x, maxHeight);
    }