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
"use strict";
cc._RF.push(module, '9d20cAC6OFEBYjjJURkpbJl', 'hero_tips_attr_window');
// Scripts/mod/hero/view/hero_tips_attr_window.js
 
"use strict";
 
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-04-03 14:44:00
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Controller = require("hero_controller");
 
var PartnerCalculate = require("partner_calculate");
 
var HeroConst = require("hero_const");
 
var GuildskillController = require("guildskill_controller");
 
var HeroEvent = require("hero_event");
 
var Hero_tips_attrWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("hero", "hero_tips_attr_panel");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Full; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.controller = Controller.getInstance();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    var _self$key_list, _self$key_list2, _self$key_list3, _self$key_list4;
 
    var self = this;
    self.key_list1 = (_self$key_list = {}, _defineProperty(_self$key_list, 1, "atk"), _defineProperty(_self$key_list, 2, "hp"), _defineProperty(_self$key_list, 3, "def"), _defineProperty(_self$key_list, 4, "speed"), _self$key_list);
    self.key_list2 = (_self$key_list2 = {}, _defineProperty(_self$key_list2, 1, "crit_rate"), _defineProperty(_self$key_list2, 2, "crit_ratio"), _defineProperty(_self$key_list2, 3, "hit_magic"), _defineProperty(_self$key_list2, 4, "dodge_magic"), _self$key_list2);
    self.key_list3 = (_self$key_list3 = {}, _defineProperty(_self$key_list3, 1, "tenacity"), _defineProperty(_self$key_list3, 2, "hit_rate"), _defineProperty(_self$key_list3, 3, "res"), _defineProperty(_self$key_list3, 4, "dodge_rate"), _self$key_list3);
    self.key_list4 = (_self$key_list4 = {}, _defineProperty(_self$key_list4, 1, "cure"), _defineProperty(_self$key_list4, 2, "be_cure"), _defineProperty(_self$key_list4, 3, "dam"), _defineProperty(_self$key_list4, 4, "dam"), _self$key_list4);
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    var self = this;
    self.background = self.root_wnd.getChildByName("background");
    self.container = self.root_wnd.getChildByName("main_panel");
    self.panel_bg = self.container.getChildByName("panel_bg");
    self.panel_bg_size = self.panel_bg.getContentSize();
    var bottom_panel = self.container.getChildByName("bottom_panel");
    self.bottom_panel = bottom_panel;
    self.bottom_panel_y = bottom_panel.y; //getPositionY()
    // --属性信息
 
    self.attr_panel_list = {};
    self.attr_list = {}; // var arr = [self.key_list1, self.key_list2, self.key_list3, self.key_list4]
 
    for (var k = 1; k <= 4; ++k) {
      var attr_panel = self.container.getChildByName("attr_panel_" + k);
      self.attr_panel_list[k] = attr_panel;
      self.attr_list[k] = {};
      var key_attr_name = "key_list" + k;
 
      for (var i = 1; i <= 4; ++i) {
        if (k == 4 && i == 4) break; //--最后一个没有了
 
        var item = {};
        item.icon = attr_panel.getChildByName("attr_icon" + i);
        item.key = attr_panel.getChildByName("attr_key" + i);
        item.value = attr_panel.getChildByName("attr_label" + i);
        item.attr_key = self[key_attr_name][i];
        self.attr_list[k][i] = item;
      }
    } // --下面两个
    // -- 公会等级
 
 
    self.guild_level_key = bottom_panel.getChildByName("attr_key1");
    self.halidom_level_key = bottom_panel.getChildByName("attr_key2");
    self.guild_level_value = bottom_panel.getChildByName("attr_label1");
    self.halidom_level_value = bottom_panel.getChildByName("attr_label2");
    self.title_name = bottom_panel.getChildByName("title_name");
    self.goto_btn_1 = bottom_panel.getChildByName("goto_btn_1");
    self.goto_btn_2 = bottom_panel.getChildByName("goto_btn_2");
    self.bottom_btn = bottom_panel.getChildByName("bottom_btn");
    self.is_hide = false;
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.bottom_btn.on("touchend", this.onClickBottomBtn, this);
    this.background.on("touchend", this.onClickCloseBtn, this);
    this.addGlobalEvent(HeroEvent.Hero_Vo_Detailed_info, function (hero_vo) {
      if (hero_vo && hero_vo.partner_id == this.hero_vo.partner_id) {
        this.setData(hero_vo);
      }
    }.bind(this));
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(data) {
    var hero_vo = data.hero_vo;
    var is_my = data.is_my;
    if (!hero_vo) return;
    var self = this;
    self.is_my = is_my;
    self.hero_vo = hero_vo;
 
    if (self.is_my) {
      if (hero_vo.is_pokedex) {
        // --是否图鉴
        self.setData(hero_vo);
        self.goto_btn_1.active = false;
        self.goto_btn_2.active = false;
      } else if (hero_vo.is_had_detailed) {
        // --是否已经有数据
        self.setData(hero_vo);
      } else {
        this.controller.sender11063(hero_vo.partner_id);
      }
    } else {
      self.setData(hero_vo);
    }
  },
  setData: function setData(hero_vo) {
    var _this = this;
 
    var self = this;
 
    for (var k in self.attr_list) {
      //k,list in ipairs(self.attr_list) do
      var list = self.attr_list[k];
 
      var _loop = function _loop(i) {
        //i,attr in ipairs(list) do
        var attr = list[i];
        var attr_str = attr.attr_key;
        var res_id = PathTool.getAttrIconByStr(attr_str);
        var res = PathTool.getUIIconPath("common", res_id);
 
        _this.loadRes(res, function (SpriteFrame) {
          attr.icon.getComponent(cc.Sprite).spriteFrame = SpriteFrame;
        });
 
        var attr_name = Config.attr_data.data_key_to_name[attr_str];
        attr.key.getComponent(cc.Label).string = attr_name;
        var value = hero_vo[attr_str] || 0;
        var is_per = PartnerCalculate.isShowPerByStr(attr_str); //-- 是否为千分比
 
        if (is_per) {
          value = value / 10 + "%";
        }
 
        attr.value.getComponent(cc.Label).string = value;
      };
 
      for (var i in list) {
        _loop(i);
      }
    }
 
    this.setBottomInfo();
  },
  // --隐藏
  onClickBottomBtn: function onClickBottomBtn() {
    Utils.playButtonSound(1);
    var self = this;
 
    if (self.is_hide) {
      self.is_hide = false;
      self.bottom_btn.setRotation(-90); // --显示
 
      self.panel_bg.setContentSize(self.panel_bg_size);
      self.bottom_panel.y = self.bottom_panel_y;
      self.attr_panel_list[3].active = true;
      self.attr_panel_list[4].active = true;
    } else {
      self.is_hide = true;
      self.bottom_btn.setRotation(90); // --隐藏
 
      self.panel_bg.setContentSize(cc.size(self.panel_bg_size.width, self.panel_bg_size.height - 162));
      self.bottom_panel.y = self.bottom_panel_y + 162;
      self.attr_panel_list[3].active = false;
      self.attr_panel_list[4].active = false;
    }
  },
  setBottomInfo: function setBottomInfo() {
    var self = this; // let string_format = string.format
 
    var _type = HeroConst.CareerType.eMagician;
    var camp_type = HeroConst.CampType.eWater;
    var config = Config.partner_data.data_partner_base[self.hero_vo.bid];
 
    if (config) {
      _type = config.type;
      camp_type = config.camp_type;
    }
 
    var guild_level = 0; //--公会等级
 
    var halidom_level = 0; //--圣物等级
 
    var halidom_break = 0; //--圣物阶级
 
    if (self.hero_vo.ext_data) {
      for (var i = 0; i < this.hero_vo.ext_data.length; ++i) {
        var v = this.hero_vo.ext_data[i];
 
        if (v.id == 1) {
          //--公会等级
          guild_level = v.val || 0;
        } else if (v.id == 2) {
          halidom_break = v.val || 0;
        } else if (v.id == 3) {
          halidom_level = v.val || 0;
        }
      }
    }
 
    if (self.is_my && !self.hero_vo.is_pokedex) {
      // --是自己的.公会等级可能会改变
      var model = GuildskillController.getInstance().getModel();
      var level = model.getCareerSkillLevel(_type);
 
      if (level != -1) {
        // --如果有公会技能等级信息..拿本地的
        guild_level = level;
      } // let halidom_vo = HalidomController.getInstance().getModel().getHalidomDataByCampType(camp_type)
      // if halidom_vo then
      //     halidom_level = halidom_vo.lev or 0
      //     halidom_break = halidom_vo.step or 0
      // end
 
    }
 
    self.guild_level_key.getComponent(cc.Label).string = "公会技能等级" + HeroConst.CareerName[_type];
    self.halidom_level_key.getComponent(cc.Label).string = HeroConst.CampName[camp_type] + "之圣物等级";
    self.guild_level_value.getComponent(cc.Label).string = "lv." + guild_level;
 
    if (halidom_break == 0 && halidom_level == 0) {
      self.halidom_level_value.getComponent(cc.Label).string = "未解锁";
    } else {
      self.halidom_level_value.getComponent(cc.Label).string = "lv." + halidom_level + halidom_break + "阶"; //:setString(string_format("lv.%s(%s%s)", halidom_level, halidom_break, TI18N("阶")))
    }
  },
  // --关闭
  onClickCloseBtn: function onClickCloseBtn() {
    Utils.playButtonSound(2);
    this.controller.openHeroTipsAttrPanel(false);
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    this.controller.openHeroTipsAttrPanel(false);
  }
});
 
cc._RF.pop();