/****************************************************************** * * 七日周期任务 * ******************************************************************/ const ActPopup = require( "act.popup.base" ); const PathTool = require("pathtool"); const NxExpand = require("nx.fx.sv.expand"); const ItemLay = require("cmp.common.itemlayout"); const TipsController = require("tips_controller"); const SevenMod = require("act.seven.mod"); const NxSpine = require("nx.fx.spine"); const FxTog = require("nx.fx.togs"); cc.Class( { extends: ActPopup, properties: { titles:{ default:[], type:[cc.Node] }, list:{ default:null, type:NxExpand }, expBar:{ default:null, type:cc.ProgressBar }, expIco:{ default:null, type:cc.Node }, expLev:{ default:null, type:cc.Node }, expScore:{ default:null, type:cc.Node }, curList:{ default:null, type:ItemLay }, nextList:{ default:null, type:ItemLay }, daysTogs:{ default:null, type:cc.Node // type:FxTog }, togs:{ default:null, type:FxTog }, lastTime:{ default:null, type:cc.Node }, roleSp:{ default:null, type:NxSpine } }, // 初始化 onLoad: function( ) { this.mod = SevenMod.getInstance(); this.goals_data = game.configs.day_goals_new_data; this.task_index = 0; this.cur_day = 0; this.select_day = 0; this.togs.posTog = this.onTogMenu.bind( this ); // 活动监听 this.mod.vbind( this, [ [ "sevenGoalData", this.freshInfos.bind( this ) ], ] ); }, onTogMenu(_index){ if(_index >= this.cur_day){ nx.tbox("Locked"); return this.togs.togTo(_index - 1); } this.select_day = _index + 1; let data = this.mod.vget("sevenGoalData"); this.setTaskList(this.select_day,data.list); }, onOpenConfigs(_params){ this._super( _params ); this.mod.send13604(); this.mod.send13607(); let cds = this.daysTogs.children; for(let i=0;i { let res_path1 = PathTool.getSpinePath( "H30059", "show", false ); this.roleSp.load( res_path1, ( _e ) => { if( !_e ) { this.roleSp.action( "action1", true ); } else { this.roleSp.stop(); } } ); }, 0.2 ); }, onPreClosed(){ this.list.rebuild([]); this.curList.rebuild([]); this.nextList.rebuild([]); // 活动监听解除 if( this.mod ) { this.mod.vunbind( this ); } }, onSelectTaskType(_index){ let idx = Number(_index); if(idx == this.task_index)return; this.task_index = idx; let data = this.mod.vget("sevenGoalData"); this.setTaskList(this.cur_day,data.list); }, freshInfos(data){ if(nx.dt.objEmpty(data))return; let lev = this.mod.getLev(); let exp = this.mod.getExp(); this.period = data.period; //判断一下第几期 nx.gui.setActive(this.titles[0],"",(this.period%2) == 0); nx.gui.setActive(this.titles[1],"",(this.period%2) == 1); this.cur_day = data.cur_day; this.select_day = this.cur_day; this.togs.togTo(data.cur_day-1); let cds = this.daysTogs.children; for(let i=0;i%s/%s",exp,max_exp)); //计算进度条,每次都从0开始 let last_exp = 0; if(cfg[lev - 1]){ last_exp = cfg[lev - 1].exp; } this.expBar.progress = (exp - last_exp)/(max_exp - last_exp); //获取积分图标 let item_id = this.goals_data.data_circle_exp_item[this.period].item_id; nx.bridge.setIcon(this.expIco,"",item_id); //设置当前和下级奖励 this.setLevReward(lev); //设置任务 this.setTaskList(this.cur_day,data.list); //設置時間 nx.gui.setCdTxt(this.lastTime,"",data.end_time - client.socket.getTime()); }, setLevReward(lev){ let cur_awards = []; let next_awards = []; let cfg = this.goals_data.data_make_lev_list[this.period]; if(!cfg)return; cur_awards = cfg[lev].reward; if(cfg[lev + 1]){ next_awards = cfg[lev + 1].reward; } this.curList.rebuild(cur_awards); this.nextList.rebuild(next_awards); }, setTaskList(curDay,tasks){ if(nx.dt.arrEmpty(tasks))return; //需要区分任务和累充任务 0 1 let cfg = {}; if(this.task_index == 0){ let groups = this.goals_data.data_group_list[this.period]; for(let gid in groups){ if(groups[gid].day == curDay){ cfg[gid] = groups[gid]; } } }else{ cfg = this.goals_data.data_charge_list[this.period]; } if(nx.dt.objEmpty(cfg))return; let list1 = []; let list2 = []; let list3 = []; for(let i = 0;i < tasks.length;i++){ if(cfg[tasks[i].id]){ tasks[i].cfgs = cfg[tasks[i].id]; if(tasks[i].finish == 1){ list1.push(tasks[i]); }else if(tasks[i].finish == 0){ list2.push(tasks[i]); }else if(tasks[i].finish == 2){ list3.push(tasks[i]); } } } let list = list1.concat(list2.concat(list3)); this.list.rebuild(list); }, onClickRule(){ let TC = TipsController.getInstance(); if( TC ) { let key = (this.period%2 == 0)?"tips":"tips_1"; let config = this.goals_data.data_constant[key]; TC.showTextPanel(null,config.desc ); } }, onClickLevAward(){ nx.bridge.createPanel("WndActSevenGoalAward",{mod:this.mod,period:this.period}); }, } );