difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
"use strict";
cc._RF.push(module, 'd915bHeVG9G+rHrmfBww5nf', 'hero_main_talent_panel');
// Scripts/mod/hero/view/hero_main_talent_panel.js
 
"use strict";
 
var HeroEvent = require("hero_event");
 
var HeroCalculate = require("hero_calculate");
 
var BackpackEvent = require("backpack_event");
 
var BackPackConst = require("backpack_const");
 
var HeroConst = require("hero_const");
 
var HeroVo = require("hero_vo");
 
var HeroMainTalenPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("hero", "hero_main_tab_talent_panel");
    this.ctrl = arguments[0];
    this.model = this.ctrl.getModel();
  },
  initConfig: function initConfig() {
    this.talent_pos_cfg = Config.partner_skill_data.data_partner_skill_pos;
  },
  initPanel: function initPanel() {
    this.up_btn_nd = this.seekChild("up_btn");
    this.up_btn_txt = this.seekChild("up_btn_txt", cc.Label);
    this.shop_btn_nd = this.seekChild("shop_btn");
    this.tip_bnt_nd = this.seekChild("tip_bnt");
    var skill_bnts = this.skill_bnts = {};
 
    for (var skill_i = 1; skill_i <= 2; skill_i++) {
      var btn_info = this.skill_bnts[skill_i] = {};
      var btn_nd = btn_info["btn_nd"] = this.seekChild("skill_btn_" + skill_i);
      btn_nd.skill_tag = skill_i;
      btn_info["lev_bg_nd"] = this.seekChild(btn_nd, "lev_bg");
      btn_info["lev_lb"] = this.seekChild(btn_nd, "lev", cc.Label);
      btn_info["red_con_nd"] = this.seekChild(btn_nd, "red_con");
      btn_info["skill_icon_nd"] = this.seekChild(btn_nd, "skill_icon");
      btn_info["skill_icon_sp"] = this.seekChild(btn_nd, "skill_icon", cc.Sprite);
      btn_info["add_icon_nd"] = this.seekChild(btn_nd, "add_icon");
      btn_info["tip_nd"] = this.seekChild(btn_nd, "tip_nd");
      btn_info["tip_title_lb"] = this.seekChild(btn_nd, "tip_title", cc.Label);
      btn_info["lock_icon_nd"] = this.seekChild(btn_nd, "lock_icon");
      btn_info["add_icon_nd"] = this.seekChild(btn_nd, "add_icon"); // btn_info["add_icon_nd"].on(cc.Node.EventType.TOUCH_END, this.onClickAddBtn, this);
 
      btn_info["btn_nd"].on(cc.Node.EventType.TOUCH_END, this.onClickSkillBnt, this);
    }
 
    this.tip_bnt_nd.on(cc.Node.EventType.TOUCH_END, this.onClickTipBtn, this);
    this.up_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickUpBtn, this);
    this.shop_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickShopBtn, this);
  },
  registerEvent: function registerEvent() {
    // --物品道具增加 判断红点
    this.addGlobalEvent(BackpackEvent.ADD_GOODS, function (bag_code, temp_add) {
      if (bag_code != BackPackConst.Bag_Code.EQUIPS) {
        for (var i in temp_add) {
          var item = temp_add[i];
 
          if (Utils.getItemConfig(item.base_id)) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
 
          if (item.base_id == this.model.talent_skill_cost_id) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
        }
      }
    }.bind(this)); // --物品道具删除 判断红点
 
    this.addGlobalEvent(BackpackEvent.DELETE_GOODS, function (bag_code, temp_del) {
      if (bag_code != BackPackConst.Bag_Code.EQUIPS) {
        for (var i in temp_del) {
          var item = temp_del[i];
 
          if (Utils.getItemConfig(item.base_id)) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
 
          if (item.base_id == this.model.talent_skill_cost_id) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
        }
      }
    }.bind(this)); //物品道具改变 判断红点
 
    this.addGlobalEvent(BackpackEvent.MODIFY_GOODS_NUM, function (bag_code, temp_list) {
      if (bag_code != BackPackConst.Bag_Code.EQUIPS) {
        for (var i in temp_list) {
          var item = temp_list[i];
 
          if (Utils.getItemConfig(item.base_id)) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
 
          if (item.base_id == this.model.talent_skill_cost_id) {
            this.checkSkillLevelUpRedpoint();
            break;
          }
        }
      }
    }.bind(this)); //遗忘技能返回
 
    this.addGlobalEvent(HeroEvent.Hero_Forget_Talent_Event, function (data) {
      if (!data) return;
      if (!this.hero_vo) return;
 
      if (data.partner_id == this.hero_vo.partner_id) {
        this.hero_vo = data;
        this.updateWidget();
      }
    }.bind(this)); //技能升级
 
    this.addGlobalEvent(HeroEvent.Hero_Level_Up_Talent_Event, function (data) {
      if (!data) return;
      if (!this.hero_vo) return;
 
      if (data.partner_id == this.hero_vo.partner_id) {
        this.hero_vo = data; // message(Utils.TI18N("技能升级成功"))
 
        this.updateWidget();
      }
    }.bind(this)); //获取到天赋信息
 
    this.addGlobalEvent(HeroEvent.Hero_Get_Talent_Event, function (list) {
      if (!list) return;
      if (!this.hero_vo) return;
 
      for (var i = 0; i < list.length; ++i) {
        var v = list[i];
 
        if (v.partner_id == this.hero_vo.partner_id) {
          this.hero_vo = Utils.deepCopy1(this.model.getHeroById(v.partner_id));
          this.updateWidget(); // this.checkSkillLevelUpRedpoint()
        }
      }
    }.bind(this)); //领悟天赋技能
 
    this.addGlobalEvent(HeroEvent.Hero_Learn_Talent_Event, function (data) {
      if (!data) return;
      if (!this.hero_vo) return;
 
      if (data.partner_id == this.hero_vo.partner_id) {
        this.hero_vo = data;
        this.updateWidget(); // this.checkSkillLevelUpRedpoint()
      }
    }.bind(this));
  },
  onShow: function onShow(params) {
    this.hero_vo = params;
 
    if (this.hero_vo.is_open_talent) {
      // --移除6星开启天赋
      this.hero_vo.is_open_talent = null; // --移除那边的
 
      this.hero_vo.fire(HeroVo.UPDATE_Partner_ATTR, this.hero_vo); // --更新一下主角按钮的红点
 
      HeroCalculate.getInstance().checkHeroRedPointByRedPointType(HeroConst.RedPointType.eRPTalent);
    }
 
    this.updateWidget();
  },
  onHide: function onHide() {},
  onDelete: function onDelete() {},
  // 界面hero_vo更新
  updateHeroInfo: function updateHeroInfo(hero_vo) {
    this.hero_vo = hero_vo;
    if (this.root_wnd) this.updateWidget();
  },
  onClickSkillBnt: function onClickSkillBnt(event) {
    Utils.playButtonSound(1);
 
    if (this.hero_vo.ishaveTalentData()) {
      var skill_index = event.target.skill_tag;
      var is_open = this.checkOpenByIndex(skill_index, true);
 
      if (is_open) {
        if (this.hero_vo.talent_skill_list[skill_index]) {
          this.ctrl.openHeroTalentSkillLevelUpPanel(true, this.hero_vo, this.hero_vo.talent_skill_list[skill_index], skill_index);
        } else {
          this.ctrl.openHeroTalentSkillLearnPanel(true, this.hero_vo, skill_index);
        }
      }
    }
  },
  updateWidget: function updateWidget() {
    if (this.hero_vo.talent_skill_list == null) return;
    var talent_info = this.hero_vo.talent_skill_list;
 
    for (var cfg_i in this.talent_pos_cfg) {
      var cur_cfg = this.talent_pos_cfg[cfg_i];
      var is_open = this.checkOpenByIndex(cur_cfg.pos);
 
      if (is_open) {
        var skill_info = talent_info[cur_cfg.pos];
 
        if (skill_info) {
          this.skill_bnts[cur_cfg.pos]["add_icon_nd"].active = false;
          this.skill_bnts[cur_cfg.pos]["skill_icon_nd"].active = true;
          var skill_data = gdata('skill_data', 'data_get_skill', skill_info);
 
          if (skill_data) {
            var icon_path = PathTool.getIconPath("skillicon", skill_data.icon);
            this.loadRes(icon_path, function (index, icon_sf) {
              this.skill_bnts[index]["skill_icon_sp"].spriteFrame = icon_sf;
            }.bind(this, cur_cfg.pos));
            this.skill_bnts[cur_cfg.pos]["tip_nd"].active = true;
            this.skill_bnts[cur_cfg.pos]["tip_title_lb"].string = skill_data.name;
            this.skill_bnts[cur_cfg.pos]["lev_bg_nd"].active = true;
            this.skill_bnts[cur_cfg.pos]["lev_lb"].string = skill_data.level;
          }
        } else {
          this.skill_bnts[cur_cfg.pos]["lev_bg_nd"].active = false;
          this.skill_bnts[cur_cfg.pos]["tip_nd"].active = false;
          this.skill_bnts[cur_cfg.pos]["add_icon_nd"].active = true;
          this.skill_bnts[cur_cfg.pos]["skill_icon_nd"].active = false;
        }
 
        this.skill_bnts[cur_cfg.pos]["lock_icon_nd"].active = false;
      } else {
        this.skill_bnts[cur_cfg.pos]["lock_icon_nd"].active = true;
        this.skill_bnts[cur_cfg.pos]["add_icon_nd"].active = false;
        this.skill_bnts[cur_cfg.pos]["tip_title_lb"].string = Utils.TI18N(cur_cfg.pos_limit[1] + "星开启");
        this.skill_bnts[cur_cfg.pos]["tip_nd"].active = true;
        this.skill_bnts[cur_cfg.pos]["lev_bg_nd"].active = false;
        this.skill_bnts[cur_cfg.pos]["skill_icon_nd"].active = false;
      }
    }
 
    this.checkSkillLevelUpRedpoint();
  },
  checkOpenByIndex: function checkOpenByIndex(index, shwo_tip) {
    if (!index) return;
    var cur_cfg = this.talent_pos_cfg[index];
    if (!cur_cfg) return;
 
    if (cur_cfg.pos_limit[0] == "star") {
      if (this.hero_vo.star >= cur_cfg.pos_limit[1]) {
        return true;
      } else {
        if (shwo_tip) message(Utils.TI18N(cur_cfg.pos_limit[1] + "星开启"));
      }
    }
 
    return false;
  },
  onClickTipBtn: function onClickTipBtn(event) {
    Utils.playButtonSound(3);
    var tip_des = Config.partner_skill_data.data_partner_skill_const.skill_rule;
    var pos = event.touch.getLocation();
 
    require("tips_controller").getInstance().showCommonTips(tip_des.desc, pos);
  },
  onClickUpBtn: function onClickUpBtn() {
    this.ctrl.openArtifactSkillWindow(true, 2);
  },
  onClickShopBtn: function onClickShopBtn() {
    var MallController = require("mall_controller");
 
    var MallConst = require("mall_const");
 
    MallController.getInstance().openMallPanel(true, MallConst.MallType.SkillShop);
  },
  //检查升级的红点 
  checkSkillLevelUpRedpoint: function checkSkillLevelUpRedpoint() {
    if (!this.hero_vo.talent_skill_list) return;
 
    for (var i in this.talent_pos_cfg) {
      var v = this.talent_pos_cfg[i];
 
      if (this.hero_vo.talent_skill_list[v.pos]) {
        var is_redpoint = HeroCalculate.getInstance().checkSingleTalentSkillLevel(this.hero_vo.talent_skill_list[v.pos]);
        this.skill_bnts[i].red_con_nd.active = is_redpoint;
      } else {
        this.skill_bnts[i].red_con_nd.active = false;
      }
    }
  }
});
 
cc._RF.pop();