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
"use strict";
cc._RF.push(module, 'ecb27MwWT5Ibpl9bd08hiPn', 'seerpalace_preview_window');
// Scripts/mod/seerpalace/view/seerpalace_preview_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//    -- 先知殿预览
// <br/>Create: 2019-03-25 19:30:32
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var SeerpalaceConst = require("seerpalace_const");
 
var SeerpalaceController = require("seerpalace_controller");
 
var SeerpalacePreviewWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("seerpalace", "seerpalace_preview_window");
    this.viewTag = SCENE_TAG.ui; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Full; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.is_full_screen = false;
    this.ctrl = SeerpalaceController.getInstance();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {},
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    var self = this;
    self.background = this.root_wnd.getChildByName("background");
 
    if (self.background) {// self.background.setScale(display.getMaxScale())
    }
 
    var container = self.root_wnd.getChildByName("container");
    self.container = container;
    var win_title = container.getChildByName("win_title"); // win_title:setString(TI18N("奖励预览"))
 
    self.list_panel = container.getChildByName("list_panel");
    self.viewContent = this.seekChild("content"); // self.root_wnd.getComponent(cc.Animation).play("seerpalace_preview_window")
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.background.on("touchend", this._onClickBtnClose, this);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(index) {
    var self = this;
    self.group_id = SeerpalaceConst.Index_To_GroupId[index];
 
    if (self.group_id) {
      self.setData();
    }
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    this.list_panel.stopAllActions();
 
    for (var i = 0; i < this.backpackItem.length; ++i) {
      if (this.backpackItem[i]) {
        this.backpackItem[i].deleteMe();
        this.backpackItem[i] = null;
      }
    }
 
    this.ctrl.openSeerpalacePreviewWindow(false);
  },
  setData: function setData() {
    var _this = this;
 
    var self = this;
    var award_config = Config.recruit_high_data.data_seerpalace_award[self.group_id];
 
    if (award_config) {
      (function () {
        _this.backpackItem = [];
        var five_star_config = award_config[5];
        var four_star_config = award_config[4];
        var scale = 0.9;
        var desc_height = 40; //--概率描述的高度
 
        var row = 4; //-- 5列英雄
 
        var start_x = 22;
        var space_x = 35;
        var space_y = 20;
        var offset_y = 10; //-- 两种星级之间的间隔
 
        var content_h = 0;
 
        for (var i in award_config) {
          var v = award_config[i];
 
          if (v.desc && v.desc != "") {
            content_h = content_h + desc_height;
          }
 
          var item_num = v.items.length; // -- 数量
 
          var item_col = Math.ceil(item_num / row); //-- 行数
 
          content_h = content_h + 119 * scale * item_col + (item_col - 1) * space_y + offset_y;
        }
 
        var y = 568 / 2 - content_h;
        self.viewContent.height = content_h;
        self.viewContent.y = y;
        var max_height = content_h; //-- 5星
 
        Utils.createLabel(22, new cc.Color(234, 181, 80, 255), null, start_x, content_h - desc_height / 2, five_star_config.desc, self.viewContent, null, cc.v2(0, 0.5));
 
        var _loop = function _loop(_i) {
          var v = five_star_config.items[_i];
          Utils.delayRun(self.list_panel, _i / 60, function () {
            var bid = v[0];
            var num = v[1];
            var item_node = ItemsPool.getInstance().getItem("backpack_item");
            item_node.show();
            item_node.setParent(self.viewContent);
            item_node.setScale(0.9);
            item_node.setData({
              bid: bid,
              num: num
            });
            var index = _i + 1;
            var row_index = index % row;
 
            if (row_index == 0) {
              row_index = row;
            }
 
            var col_index = Math.ceil(index / row);
            var pos_x = start_x + (row_index - 1) * (119 * scale + space_x) + 60 * 0.9;
            var pos_y = max_height - desc_height - (col_index - 1) * (119 * scale + space_y) - 60 * 0.9;
            item_node.setPosition(pos_x, pos_y);
            self.backpackItem.push(item_node);
          });
        };
 
        for (var _i = 0; _i < five_star_config.items.length; ++_i) {
          _loop(_i);
        } // -- 4星
 
 
        var start_y = max_height - desc_height - Math.ceil(five_star_config.items.length / row) * (119 * scale + space_y) + space_y - offset_y;
        Utils.createLabel(22, new cc.Color(234, 181, 80, 255), null, start_x, start_y - desc_height / 2, four_star_config.desc, self.viewContent, null, cc.v2(0, 0.5));
 
        var _loop2 = function _loop2(_i2) {
          var v = four_star_config.items[_i2];
          Utils.delayRun(self.list_panel, _i2 / 60, function () {
            var bid = v[0];
            var num = v[1];
            var item_node = ItemsPool.getInstance().getItem("backpack_item");
            item_node.show();
            item_node.setParent(self.viewContent);
            item_node.setScale(0.9);
            item_node.setData({
              bid: bid,
              num: num
            });
            var index = _i2 + 1;
            var row_index = index % row;
 
            if (row_index == 0) {
              row_index = row;
            }
 
            var col_index = Math.ceil(index / row);
            var pos_x = start_x + (row_index - 1) * (119 * scale + space_x) + 60 * 0.9;
            var pos_y = start_y - desc_height - (col_index - 1) * (119 * scale + space_y) - 60 * 0.9;
            item_node.setPosition(pos_x, pos_y);
            self.backpackItem.push(item_node);
          });
        };
 
        for (var _i2 = 0; _i2 < four_star_config.items.length; ++_i2) {
          _loop2(_i2);
        }
      })();
    }
  },
  _onClickBtnClose: function _onClickBtnClose() {
    Utils.playButtonSound(2);
    this.ctrl.openSeerpalacePreviewWindow(false);
  }
});
 
cc._RF.pop();