Example #1
0
    public HeroData(int heroid)
    {
        _heroID = heroid;
        int[] skills = JsonData.skills;
        SkillLevel = new Dictionary <int, int>();
        for (int i = 0; i < skills.Length; ++i)
        {
            SkillLevel.Add(skills[i], 1);
        }

        Totems = new string[0];
        int[] equip = JsonData.equip;
        Equips = new string[equip.Length];

        for (int i = 0, length = equip.Length; i < length; ++i)
        {
            EquipData data = new EquipData(equip[i])
            {
                md5    = equip[i] + heroid.ToString(),
                HeroId = heroid
            };
            EquipMgr.GetSingleton().AddEquip(data);
            Equips[i] = data.md5;
        }

        Piece  = 500;
        UnLock = true;
    }
Example #2
0
 public Role(int player_id) : base(player_id)
 {
     this.equip_mgr = new EquipMgr(this);
     this.skill_mgr = new SkillMgr(this);
     this.buff_mgr  = new BuffMgr(this);
     this.state_mgr = new StateMgr(this);
 }
Example #3
0
    public void OnLoadEquipData(ServerMsgObj msg)
    {
        string          server = msg.Msg;
        EquipMsgCollect em     = JsonUtility.FromJson <EquipMsgCollect>(server);

        EquipData[] data = new EquipData[em.equips.Length];
        for (int i = 0; i < data.Length; i++)
        {
            data[i] = new EquipData(em.equips[i]);
            EquipMgr.GetSingleton().AddEquip(data[i]);
        }
    }
Example #4
0
 public override void Awake()
 {
     base.Awake();
     EventListener.Get(takeoff_btn.gameObject).OnClick = e =>
     {
         if (data == null)
         {
             return;
         }
         EquipMgr.GetSingleton().TakeOffEquip(data);
         data = null;
         UIFace.GetSingleton().Close(UIID.StrengthenTip);
         ZEventSystem.Dispatch(EventConst.REFRESHLEFT);
     };
 }
    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();
    }
Example #6
0
 private string HasCanDress(EquipPart part, int heroType)
 {
     EquipData[] equips = EquipMgr.GetSingleton().GetEquipByPart(part);
     if (equips == null)
     {
         return("");
     }
     for (int i = 0; i < equips.Length; ++i)
     {
         int  type  = equips[i].JsonData.Type;
         bool dress = part == EquipPart.Weapon ? type == heroType : type <= heroType;
         if (equips[i].HeroId == 0 && dress)
         {
             return(equips[i].md5);
         }
     }
     return("");
 }
 public void SetView(HeroData heroData)
 {
     dontTakePart.Clear();
     EquipData[] equips = heroData.GetEquip();
     for (int i = 0; i < partDic.Count; ++i)
     {
         EquipData data = equips[i];
         EquipPart part = (EquipPart)(i + 1);
         if (data == null)
         {
             dontTakePart.Add(part);
             partDic[part].image.gameObject.SetActive(false);
             partDic[part].level.text = "";
             continue;
         }
         partDic[part].image.gameObject.SetActive(true);
         EventListener.Get(partArray[i].image.gameObject).OnClick = e =>
         {
             if (data == null)
             {
                 return;
             }
             UIFace.GetSingleton().Open(UIID.StrengthenTip, data);
         };
         if (partDic.ContainsKey(part))
         {
             int id = JsonMgr.GetSingleton().GetItemConfigByID(data.EquipId).icon;
             partDic[part].image.sprite = ResourceMgr.Instance.LoadSprite(id);
             partDic[part].level.text   = data.StrengthenLv > 0 ? "+" + data.StrengthenLv : "";
             if (partDic[part].floor != null)
             {
                 partDic[part].floor.SetAlpha(data.StrengthenLv);
             }
         }
     }
     for (int i = 0; i < dontTakePart.Count; i++)
     {
         string md5 = EquipMgr.GetSingleton().TestCanDress(dontTakePart[i], heroData);
         partDic[dontTakePart[i]].cr.SetAlpha(md5 != "" ? 1 : 0);
     }
 }
Example #8
0
 void Awake()
 {
     Instance      = this;
     equipDict     = new Dictionary <int, EquipItem>();
     EquipListPath = AppConst.EquipListPath;
 }
Example #9
0
 public EquipData[] GetEquip()
 {
     return(EquipMgr.GetSingleton().GetHeroEquip(this));
 }
    public void ShowLeft()
    {
        Name_txt.text = heroData.JsonData.name;

        show_txt.text = heroData.Officer > 0 ? JsonMgr.GetSingleton().GetOfficerByID(heroData.Officer).Post : "";

        //需要获取武将官阶的官职列表并对dd赋值

        int[] unlock = JsonMgr.GetSingleton().GetHeroRareByID(heroData.Rare).UnLock;

        for (int i = 0; i < officerText.Length; ++i)
        {
            if (i >= unlock.Length)
            {
                officerText[i].text = "";
                continue;
            }
            Officer o   = JsonMgr.GetSingleton().GetOfficerByID(unlock[i]);
            string  txt = officerText[i].text = o.Post;

            EventListener.Get(officerText[i].gameObject).OnClick = e =>
            {
                show_txt.text = txt;
                ShowPopList(null);
                HeroMgr.GetSingleton().TakeOfficer(heroData, o.ID);
                if (showType == EHEROSHOWTYPE.Detail)
                {
                    ShowDetail();
                }
            };
        }
        Vector2 size = scrollRect.content.sizeDelta;

        size.y = unlock.Length * 53;
        scrollRect.content.sizeDelta        = size;
        EventListener.Get(hero_obj).OnClick = e =>
        {
            if (player != null && !player.IsPlaying)
            {
                player.RandomPlay(true);
            }
        };
        EventListener.Get(hero_obj).BegineDragEvent = e =>
        {
            previousX = Input.mousePosition.x;
        };
        EventListener.Get(hero_obj).DragEvent = e =>
        {
            offset    = previousX - Input.mousePosition.x;
            previousX = Input.mousePosition.x;
            Herotf.Rotate(Vector3.up, offset * scale, Space.Self);
        };
        HeroEquipView hev = Equip_obj.GetComponent <HeroEquipView>();

        hev.SetView(heroData);
        EventListener.Get(Dress_btn.gameObject).OnClick = e =>
        {
            EquipData[] equips = heroData.GetEquip();
            for (int i = 0; i < equips.Length; ++i)
            {
                EquipData data = equips[i];
                if (data == null)
                {
                    string    md5   = EquipMgr.GetSingleton().TestCanDress((EquipPart)i + 1, heroData);
                    EquipData equip = EquipMgr.GetSingleton().GetEquipDataByUID(md5);
                    if (equip != null)
                    {
                        EquipMgr.GetSingleton().TakeEquip(equip, heroData);
                        hev.SetView(heroData);
                    }
                }
            }
        };
        EventListener.Get(Intensify_btn.gameObject).OnClick = e =>
        {
            EquipData[] equips = heroData.GetEquip();
            bool        canUp  = false;
            for (int i = 0; i < equips.Length; ++i)
            {
                EquipData data = equips[i];
                if (data == null || data.StrengthenLv == HeroMgr.MaxHeroLevel)
                {
                    continue;
                }
                canUp = true;
                EquipMgr.GetSingleton().UpEquip(data);
                hev.SetView(heroData);
            }
            if (!canUp)
            {
                CanvasView.Instance.AddNotice("暂时没有可强化装备");
            }
        };
    }
Example #11
0
 public static EquipMgr GetSingleton()
 {
     return(_equip ?? (_equip = new EquipMgr()));
 }