"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: // 这里是描述这个窗体的作用的 //
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();