"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: // -- 先知殿预览 //
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();