/*-----------------------------------------------------+ * 主角色数据模块 * @author whjing2012@163.com +-----------------------------------------------------*/ var RoleModel = cc.Class({ ctor:function(){ this.role_vo = null; }, initConfig:function(){ this.open_srv_day = 0; // 开服天数. this.world_lev = 0; }, // -- 设世界等级 setWorldLev(lev){ this.world_lev = lev; }, // -- 获取世界等级 getWorldLev(){ return this.world_lev; }, // 初始化角色基础数据 initRoleBaseData : function(data){ this.initAttribute(data); this.role_vo.dispatchUpdateBaseAttr(); }, // 资产信息变化 initRoleAssetsData : function(data){ this.initAttribute(data); }, // 更新角色所有属性 initAttribute : function(data){ if(!this.role_vo){ var RoleVo = require("role_vo"); this.role_vo = new RoleVo(); } this.role_vo.initAttributeData(data); }, // 更新角色单个属性 setRoleAttribute : function(key, value){ if(this.role_vo){ this.role_vo.setRoleAttribute(key, value); } }, // 特权礼包 setPrivilegeData:function(data_list){ this.privilege_data = data_list; }, getPrivilegeData:function(){ return this.privilege_data; }, /** * 监测当前的特权状态 * @param {*} id 1快速作战特权 2远航普通特权 3远航高级特权 4元素聖殿特權 5特權靈窩 */ checkPrivilegeStatus:function(id){ var status = false; if(this.privilege_data){ for (let index = 0; index < this.privilege_data.length; index++) { const element = this.privilege_data[index]; if (element.id == id){ status = (element.status == 1); break; } } } return status; }, // 1快速作戰特權 2遠航普通特權 3遠航高級特權 4元素聖殿特權 5特權靈窩 getPrivilegeDataById( id ){ if(this.privilege_data){ for (let i in this.privilege_data) { if (this.privilege_data[i].id == id){ return this.privilege_data[i] } } } }, getRoleVo:function(){ return this.role_vo; }, // 设置开服天数 setOpenSrvDay:function(day){ this.open_srv_day = day; this.setRoleAttribute("open_day", day); gcore.GlobalEvent.fire(EventId.OPEN_SRV_DAY, day); }, getOpenSrvDay:function(){ return this.open_srv_day; }, //是否在本服里面 isTheSame:function(srv_id){ if(this.serverList && srv_id){ return this.serverList[srv_id] != null } return true }, // --活动资产信息改变 initRoleActionAssetsData(holiday_assets, is_update){ if (!this.role_vo){ var RoleVo = require("role_vo"); this.role_vo = new RoleVo(); } if (holiday_assets){ this.role_vo.initActionAssetsData(holiday_assets, is_update) } }, //--獲取徽章點數對應的名字 getHonorPointName(pos){ let point = pos || 0; let list = game.configs.room_feat_data.data_honor_title_info if (!list) return; list.sort(function(a,b){ return a.min < b.min; }); let count = list.length; for (let i in list) { let v = list[i]; if (point >= v.min && point <= v.max) { if (i >= count-1) { return [v.name, v.res_id, -1] }else{ return [v.name, v.res_id, list[i + 1].min, list[i + 1].name, list[i + 1].res_id] } } } if (Utils.next(list) != null){ return [list[count-1].name , list[count-1].res_id, -1] } }, });