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
"use strict";
cc._RF.push(module, 'ed032FmFzlI45Gw11hNRwG9', 'hero_reset_offer_window');
// Scripts/mod/hero/view/hero_reset_offer_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-04 17:07:10
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var HeroEvent = require("hero_event");
 
var HeroConst = require("hero_const");
 
var CommonAlert = require("commonalert");
 
var Hero_reset_offerWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("hero", "hero_reset_offer_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.ctrl = arguments[0];
    this.model = this.ctrl.getModel();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.is_show_tips = false; //是否显示提示
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.des_txt_lb = this.seekChild("des_txt", cc.RichText);
    this.list_view_nd = this.seekChild("list_view");
    this.cancel_btn_nd = this.seekChild("cancel_btn");
    this.confirm_btn_nd = this.seekChild("confirm_btn");
    this.close_btn_nd = this.seekChild("close_btn");
    this.win_title_lb = this.seekChild("win_title", cc.Label);
    this.cancel_btn_nd.on(cc.Node.EventType.TOUCH_END, function () {
      Utils.playButtonSound(1);
      this.onClickCancelBtn();
    }, this);
    this.confirm_btn_nd.on(cc.Node.EventType.TOUCH_END, function () {
      Utils.playButtonSound(1);
      this.onClickConfirBtn();
    }, this);
    this.close_btn_nd.on(cc.Node.EventType.TOUCH_END, function () {
      Utils.playButtonSound(2);
      this.onClickCloseBtn();
    }, this);
    this.des_txt_lb.string = Utils.TI18N(Lang.OFFET_DES);
    this.initListView();
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.addGlobalEvent(HeroEvent.Hero_Reset_Look_Event, function (data) {
      if (data) {
        this.setItemsData(data);
      }
    }.bind(this));
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  // 1 英雄分解 2 碎片分解  3神装分解 4 10星置换 参考 HeroConst.ResetType
  openRootWnd: function openRootWnd(params) {
    this.reset_type = params.reset_type;
    this.is_show_tips = params.is_show_tips;
 
    if (params.reset_type == HeroConst.ResetType.eHeroReset) {
      //英雄献祭
      this.des_txt_lb.string = Utils.TI18N("献祭英雄可获得材料,若英雄有进行升级、进阶、升星培养,也会100%返还所消耗的进阶石、金币和英雄经验。本次献祭所得如下:");
      this.win_title_lb.string = Utils.TI18N("英雄献祭");
 
      if (params.item_list) {
        this.ctrl.sender11075(params.item_list);
      }
    } else if (params.reset_type == HeroConst.ResetType.eChipReset) {
      //碎片献祭
      this.des_txt_lb.string = Utils.TI18N(params.dec);
      this.setItemsData(params.item_list);
      this.win_title_lb.string = Utils.TI18N("碎片献祭");
    }
 
    if (params.callback) {
      this.close_cb = params.callback;
    }
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    if (this.item_scrollview) {
      this.item_scrollview.deleteMe();
      this.item_scrollview = null;
    }
 
    this.ctrl.openHeroResetOfferPanel(false);
  },
  updateWidgets: function updateWidgets() {},
  initListView: function initListView() {
    var CommonScrollView = require("common_scrollview");
 
    var scroll_view_size = cc.size(this.list_view_nd.width, this.list_view_nd.height);
    var setting = {
      item_class: "backpack_item",
      // 单元类
      start_x: 0,
      // 第一个单元的X起点
      space_x: 4,
      // x方向的间隔
      start_y: 0,
      // 第一个单元的Y起点
      space_y: 0,
      // y方向的间隔
      item_width: 150,
      // 单元的尺寸width
      item_height: 136,
      // 单元的尺寸height
      col: 4,
      // 列数,作用于垂直滚动类型
      once_num: 5,
      need_dynamic: true
    };
    this.item_scrollview = new CommonScrollView();
    this.item_scrollview.createScroll(this.list_view_nd, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, scroll_view_size, setting, cc.v2(0.5, 0.5));
  },
  onClickCancelBtn: function onClickCancelBtn() {
    this.onClickCloseBtn();
  },
  onClickConfirBtn: function onClickConfirBtn() {
    this.onClickCloseBtn();
 
    if (this.reset_type == HeroConst.ResetType.eHeroReset) {
      this.onHeroComfirm();
    } else if (this.reset_type == HeroConst.ResetType.eChipReset) {
      this.onChipComfirm();
    }
  },
  onClickCloseBtn: function onClickCloseBtn() {
    this.ctrl.openHeroResetOfferPanel(false);
  },
  setItemsData: function setItemsData(item_list) {
    var cur_list = [];
 
    for (var item_i in item_list) {
      var item_data = {};
      item_data.bid = item_list[item_i].id;
      item_data.num = item_list[item_i].num;
      cur_list.push(item_data);
    }
 
    this.item_scrollview.setData(cur_list, null, {
      is_show_tips: true,
      is_other: false
    });
  },
  onHeroComfirm: function onHeroComfirm() {
    if (this.is_show_tips) {
      var str = Utils.TI18N("本次献祭含有5星或以上英雄,是否确认献祭?");
      var other_args = {};
      other_args.title = Utils.TI18N("英雄献祭");
      other_args.delayS = 10;
      var alert = CommonAlert.show(str, Utils.TI18N("确定"), function () {
        if (this.close_cb) {
          this.close_cb();
        }
      }.bind(this), Utils.TI18N("取消"), null, null, null, other_args);
    } else {
      if (this.close_cb) {
        this.close_cb();
      }
    }
  },
  onChipComfirm: function onChipComfirm() {
    if (this.is_show_tips) {
      var str = Utils.TI18N("本次献祭的碎片满足召唤英雄要求,献祭后可能会失去召唤的机会,是否继续?");
      var other_args = {};
      other_args.title = Utils.TI18N("碎片献祭");
      other_args.delayS = 5; //点击跳转
 
      other_args.extend_str = Utils.TI18N("<on click='handler'><u>前往召唤英雄</u></on>");
 
      other_args.callFunc = function () {
        var BackpackController = require("backpack_controller");
 
        var BackPackConst = require("backpack_const");
 
        BackpackController.getInstance().openMainWindow(true, BackPackConst.item_tab_type.HERO);
        alert.close();
      }.bind(this);
 
      var alert = CommonAlert.show(str, Utils.TI18N("确定"), function () {
        if (this.close_cb) {
          this.close_cb();
        }
      }.bind(this), Utils.TI18N("取消"), null, null, null, other_args);
    } else {
      if (this.close_cb) {
        this.close_cb();
      }
    }
  }
});
 
cc._RF.pop();