"use strict"; cc._RF.push(module, 'b8c23UwNytK6oKjkXgsjzI7', 'heroexpedit_model'); // Scripts/mod/heroexpedit/heroexpedit_model.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2019-03-11 14:13:49 // -------------------------------------------------------------------- var MainuiController = require("mainui_controller"); var RoleController = require("role_controller"); var HeroExpeditEvent = require("heroexpedit_event"); var EsecsiceConst = require("esecsice_const"); var MainUiConst = require("mainui_const"); var HeroexpeditModel = cc.Class({ "extends": BaseClass, ctor: function ctor() { this.ctrl = arguments[0]; }, properties: {}, initConfig: function initConfig() { this.levelRedPointStatus = 0; this.sendRedPointStatus = 0; }, // 24406 setEmployPartner: function setEmployPartner(data) { this.employPartner = data; }, getEmployPartner: function getEmployPartner() { return this.employPartner || {}; }, //24404 setPartnerMessage: function setPartnerMessage(data) { this.partnerMessage = data; }, getPartnerMessage: function getPartnerMessage() { return this.partnerMessage || {}; }, //远征的主界面数据 setExpeditData: function setExpeditData(data) { if (!data) return; this.expeditData = data; this.guard_id = data.guard_id; this.updateRedPoint(); }, updateRedPoint: function updateRedPoint() { RedMgr.getInstance().addCalHandler(this.checkRed.bind(this), RedIds.Heroexpedit); }, checkRed: function checkRed() { var status = this.checkRedStatus(); var SceneConst = require("scene_const"); MainuiController.getInstance().setBtnRedPoint(MainUiConst.btn_index.esecsice, { bid: SceneConst.RedPointType.heroexpedit, status: status }); }, getExpeditData: function getExpeditData() { return this.expeditData || {}; }, // 通关红点 setLevelRedPoint: function setLevelRedPoint(status) { this.levelRedPointStatus = status; }, // 派遣红点 setHeroSendRedPoint: function setHeroSendRedPoint(status) { if (status == 0) { status = 1; } else { status = 0; } this.sendRedPointStatus = status; gcore.GlobalEvent.fire(HeroExpeditEvent.Red_Point_Event); }, getHeroSendRedPoint: function getHeroSendRedPoint() { if (this.sendRedPointStatus == 1) { return true; } else { return false; } }, //远征红点 checkRedStatus: function checkRedStatus() { var open_data = Config.dailyplay_data.data_exerciseactivity; var bool = MainuiController.getInstance().checkIsOpenByActivate(open_data[EsecsiceConst.execsice_index.heroexpedit].activate); if (bool == false) return false; var num = this.levelRedPointStatus + this.sendRedPointStatus; var status = false; if (num <= 0) { status = false; } else { status = true; } return status; }, //获取宝箱的位置 getExpeditBoxData: function getExpeditBoxData() { var box = []; var data = Config.expedition_data.data_sign_info; for (var i in data) { if (data[i].type == 2) { box.push(i); } } return box; }, // 血条 setHeroBloodById: function setHeroBloodById(data) { this.HeroBloodData = []; this.hireHeroData = []; this.hireHeroIsUsedData = []; //雇佣的英雄是否使用过 this.setExpeditEmployData(data.list); // 本身的 var role_vo = RoleController.getInstance().getRoleVo(); var rid = 0; var srv_id = ""; if (role_vo) { rid = role_vo.rid; srv_id = role_vo.srv_id; } for (var i in data.p_list) { var key = Utils.getNorKey(rid, srv_id, data.p_list[i].id); this.HeroBloodData[key] = data.p_list[i].hp_per; } // 雇佣的 if (Utils.next(data.list) != null) { for (var j in data.list) { var key = Utils.getNorKey(data.list[j].rid, data.list[j].srv_id, data.list[j].id); this.hireHeroData[key] = true; this.HeroBloodData[key] = data.list[j].hp_per; this.hireHeroIsUsedData[key] = data.list[j].is_used; } } }, getHeroBloodById: function getHeroBloodById(id, rid, srv_id) { if (!this.HeroBloodData) return 100; if (!id || typeof id != "number") return 100; rid = rid || 0; srv_id = srv_id || ""; var key = Utils.getNorKey(rid, srv_id, id); if (this.HeroBloodData[key] == null) { return 100; } return this.HeroBloodData[key]; }, // 雇佣的 getHireHero: function getHireHero(id, rid, srv_id) { if (!this.hireHeroData) return false; if (!id || typeof id != "number") return false; rid = rid || 0; srv_id = srv_id || ""; var key = Utils.getNorKey(rid, srv_id, id); return this.hireHeroData[key] || false; }, // 雇佣使用的 getHireHeroIsUsed: function getHireHeroIsUsed(id, rid, srv_id) { if (!this.hireHeroIsUsedData) return 0; if (!id || typeof id != "number") return 0; rid = rid || 0; srv_id = srv_id || ""; var key = Utils.getNorKey(rid, srv_id, id); return this.hireHeroIsUsedData[key] || 0; }, // 英雄出征的雇佣英雄 setExpeditEmployData: function setExpeditEmployData(data) { this.expeditEmployData = data; }, getExpeditEmployData: function getExpeditEmployData() { return this.expeditEmployData || {}; }, __delete: function __delete() {} }); cc._RF.pop();