yyl
22 小时以前 4b5b31a23a74c1559460643836d70778d7d49931
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
/// <summary>
/// 武将吞噬界面
/// </summary>
public class HeroGiftEatWin : UIBase
{
    [SerializeField] HeroShowBaseCell heroShow;
    [SerializeField] GiftBaseCell[] giftCells;
    [SerializeField] Button addHeroBtn;
    [SerializeField] Button addHeroGo;
    [SerializeField] HeroShowBaseCell addHeroShow;
    [SerializeField] GiftBaseCell[] addGiftCells;
    [SerializeField] GameObject addTip;
    [SerializeField] GameObject addAttrGo;
    [SerializeField] Text[] addAttrTexts;
    [SerializeField] Text addGiftTip;
 
    [SerializeField] Button eatBtn;
 
 
 
 
    protected override void InitComponent()
    {
        addHeroBtn.AddListener(OpenSelectWin);
 
        addHeroGo.AddListener(OpenSelectWin);
 
        eatBtn.AddListener(EatHero);
    }
 
    protected override void OnPreOpen()
    {
        HeroUIManager.Instance.SelectEatHeroEvent += Display;
        Display();
    }
 
    protected override void OnPreClose()
    {
        HeroUIManager.Instance.selectEatHeroGuid = "";
        HeroUIManager.Instance.SelectEatHeroEvent -= Display;
    }
 
 
    public void Display()
    {
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
 
        heroShow.Init(hero.heroId, hero.SkinID, hero.breakLevel, hero.heroStar, hero.awakeLevel, hero.heroLevel);
        HeroUIManager.Instance.RefreshGiftCell(giftCells, hero);
        if (string.IsNullOrEmpty(HeroUIManager.Instance.selectEatHeroGuid))
        {
            addHeroBtn.SetActive(true);
            addHeroGo.SetActive(false);
            addTip.SetActive(true);
            addAttrGo.SetActive(false);
        }
        else
        {
            addHeroBtn.SetActive(false);
            addHeroGo.SetActive(true);
            addTip.SetActive(false);
            addAttrGo.SetActive(true);
            var addHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectEatHeroGuid);
            addHeroShow.Init(addHero.heroId, addHero.SkinID, addHero.breakLevel, addHero.heroStar, addHero.awakeLevel, addHero.heroLevel);
            HeroUIManager.Instance.RefreshGiftCell(addGiftCells, addHero);
            for (int i = 0; i < addAttrTexts.Length; i++)
            {
                int id = PlayerPropertyConfig.basePerAttrs[i];
                addAttrTexts[i].text = PlayerPropertyConfig.GetFullDescription(id, hero.qualityConfig.StarAddPer,
                "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}", true));
            }
            addGiftTip.SetActive(!hero.IsFullGift());
        }
    }
 
    void EatHero()
    {
        if (HeroUIManager.Instance.selectEatHeroGuid == "")
        {
            SysNotifyMgr.Instance.ShowTip("HeroGift3");
            return;
        }
 
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
        //洗炼和觉醒的天赋未处理不可吞噬
        if (hero.talentRandomIDList.Count > 0)
        {
            SysNotifyMgr.Instance.ShowTip("HeroGift4");
            return;
        }
 
        if (hero.talentAwakeRandomIDList.Count > 0)
        {
            SysNotifyMgr.Instance.ShowTip("HeroGift5");
            return;
        }
 
        var eatHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectEatHeroGuid);
        if (hero == null || eatHero == null)
            return;
 
 
        if (hero.heroStar >= HeroUIManager.Instance.GetMaxStarCount(hero.heroId, hero.Quality))
        {
            CloseWindow();
            SysNotifyMgr.Instance.ShowTip("HeroGift7");
            return;
        }
 
        if (hero.IsFullStar())
        {
            CloseWindow();
            SysNotifyMgr.Instance.ShowTip("HeroGift1");
            return;
        }
 
 
        var pack = new CB231_tagCSHeroStarUP();
        pack.ItemIndex = (ushort)hero.itemHero.gridIndex;
        pack.UseItemIndex = (ushort)eatHero.itemHero.gridIndex;
        GameNetSystem.Instance.SendInfo(pack);
        HeroUIManager.Instance.eatHeroIDForResult = hero.heroId;
        HeroUIManager.Instance.selectHeroGuidForGiftFuncForSuccessWin = HeroUIManager.Instance.selectHeroGuidForGiftFunc;
        HeroUIManager.Instance.heroBeforeGiftIDList = new List<int>(hero.talentIDList);
        HeroUIManager.Instance.heroBeforeGiftLevelList = new List<int>(hero.talentLvList);
        HeroUIManager.Instance.lastFightPower = new KeyValuePair<string, long>(hero.itemHero.guid, hero.CalculatePower(false));
 
        //设置个等待回复的标识 显示成功界面
        HeroUIManager.Instance.waitResponse = new WaitHeroFuncResponse()
        {
            guid = HeroUIManager.Instance.selectHeroGuidForGiftFuncForSuccessWin,
            type = HeroFuncType.Gift,
            time = Time.time
        };
    }
 
    void OpenSelectWin()
    {
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
        if (hero == null)
        {
            CloseWindow();
            return;
        }
 
        if (hero.heroStar >= HeroUIManager.Instance.GetMaxStarCount(hero.heroId, hero.Quality))
        {
            CloseWindow();
            SysNotifyMgr.Instance.ShowTip("HeroGift7");
            return;
        }
 
        if (hero.IsFullStar())
        {
            CloseWindow();
            SysNotifyMgr.Instance.ShowTip("HeroGift1");
            return;
        }
        UIManager.Instance.OpenWindow<HeroGiftRoleListWin>();
    }
}