314 lines
9.1 KiB
JavaScript
314 lines
9.1 KiB
JavaScript
|
|
// /******************************************************************
|
||
|
|
// *
|
||
|
|
// * 群星轨迹
|
||
|
|
// *
|
||
|
|
// ******************************************************************/
|
||
|
|
|
||
|
|
const ActPopup = require( "act.popup.base" );
|
||
|
|
const NxTogs = require("nx.fx.togs");
|
||
|
|
const NxExpand = require("nx.fx.sv.expand");
|
||
|
|
const ItemLay = require("cmp.common.itemlayout");
|
||
|
|
const StartravelMod = require("act.star.mod");
|
||
|
|
const Payment = require( "payment.mod" );
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: ActPopup,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
starLev:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
expLb:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
expBar:{
|
||
|
|
default:null,
|
||
|
|
type:cc.ProgressBar
|
||
|
|
},
|
||
|
|
lastTime:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
changeBtn:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
cliamBtn:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
//主界面
|
||
|
|
wins:{
|
||
|
|
default:[],
|
||
|
|
type:[cc.Node]
|
||
|
|
},
|
||
|
|
expList:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
taskList:{
|
||
|
|
default:null,
|
||
|
|
type:NxExpand
|
||
|
|
},
|
||
|
|
totalLock:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
maxItem:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
maxItemLay:{
|
||
|
|
default:null,
|
||
|
|
type:ItemLay
|
||
|
|
},
|
||
|
|
fabItem:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
buyBtn:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 初始化
|
||
|
|
onLoad: function( ) {
|
||
|
|
this.mod = StartravelMod.getInstance();
|
||
|
|
this.order_data = game.configs.holiday_new_war_order_data;
|
||
|
|
this.select_index = 0;
|
||
|
|
this.task_index = 0;
|
||
|
|
// 活动监听
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "orderTasks", this.freshTasks.bind( this ) ],
|
||
|
|
[ "orderRewards", this.freshRewards.bind( this ) ],
|
||
|
|
[ "orderLastTime", this.refreshTime.bind( this ) ]
|
||
|
|
] );
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs(_params){
|
||
|
|
this._super( _params );
|
||
|
|
this.bindChain();
|
||
|
|
this.mod.reqOrderData();
|
||
|
|
this.mod.send28703();
|
||
|
|
this.mod.send28706();//档期战令卡的id
|
||
|
|
this.changePanel();
|
||
|
|
this.setMaxBaseItem();
|
||
|
|
},
|
||
|
|
|
||
|
|
bindChain(){
|
||
|
|
//任務
|
||
|
|
let dot = nx.gui.getComponent( this.changeBtn, "tip", "nx.vb.visible" );
|
||
|
|
if( !dot ) {
|
||
|
|
nx.gui.setActive( dot, "", false );
|
||
|
|
} else {
|
||
|
|
let key = this.mod.getTipKey(this.mod.tipKeys()[0]);
|
||
|
|
dot.setTarget( nx.mTip, key );
|
||
|
|
}
|
||
|
|
|
||
|
|
//獎勵
|
||
|
|
let dot2 = nx.gui.getComponent( this.cliamBtn, "tip", "nx.vb.visible" );
|
||
|
|
if( !dot2 ) {
|
||
|
|
nx.gui.setActive( dot2, "", false );
|
||
|
|
} else {
|
||
|
|
let key2 = this.mod.getTipKey(this.mod.tipKeys()[1]);
|
||
|
|
dot2.setTarget( nx.mTip, key2 );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
refreshTime(end_time){
|
||
|
|
|
||
|
|
this.tend_time = end_time;
|
||
|
|
let desc = nx.text.getKey( "act_common_time" );
|
||
|
|
nx.gui.setString(this.lastTime.parent, "txt", desc);
|
||
|
|
nx.gui.setCdTxt(this.lastTime,"",end_time - client.socket.getTime());
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed(){
|
||
|
|
this.expList.rebuild([]);
|
||
|
|
this.taskList.rebuild([]);
|
||
|
|
this.maxItemLay.rebuild([]);
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onTogMenu(_index){//切換任務類型
|
||
|
|
this.task_index = _index;
|
||
|
|
|
||
|
|
let time = _index == 0 ? this.daily_list[0].end_time : this.week_list[0].end_time;
|
||
|
|
let desc = _index == 0 ? nx.text.getKey( "ActDailyTip" ): nx.text.getKey( "ActWeeklyTip" );
|
||
|
|
nx.gui.setString(this.lastTime.parent, "txt", desc);
|
||
|
|
nx.gui.setCdTxt(this.lastTime,"", time - client.socket.getTime());
|
||
|
|
|
||
|
|
this.freshTasks();
|
||
|
|
},
|
||
|
|
|
||
|
|
changePanel(){
|
||
|
|
|
||
|
|
for(let i=0;i<this.wins.length;i++){
|
||
|
|
|
||
|
|
nx.gui.setActive(this.wins[i],"",i == this.select_index);
|
||
|
|
if( i == 0 && this.select_index == 0 ){
|
||
|
|
|
||
|
|
let desc = nx.text.getKey( "act_common_time" );
|
||
|
|
nx.gui.setString(this.lastTime.parent, "txt", desc);
|
||
|
|
this.refreshTime( this.tend_time );
|
||
|
|
// break;
|
||
|
|
}else{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
if(this.select_index == 0){
|
||
|
|
|
||
|
|
nx.gui.setString(this.changeBtn,"txt",nx.text.getKey("ActStarTasks"));
|
||
|
|
this.select_index = 1;
|
||
|
|
|
||
|
|
}else{
|
||
|
|
|
||
|
|
let desc = nx.text.getKey( "ActDailyTip" );
|
||
|
|
nx.gui.setString(this.lastTime.parent, "txt", desc);
|
||
|
|
nx.gui.setString(this.changeBtn,"txt",nx.text.getKey("ActStarTravel"));
|
||
|
|
this.select_index = 0;
|
||
|
|
this.onTogMenu( 0 );
|
||
|
|
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
freshTasks(tasks){
|
||
|
|
let data = tasks;
|
||
|
|
if(!data){
|
||
|
|
data = this.mod.vget("orderTasks");
|
||
|
|
}
|
||
|
|
|
||
|
|
//任务分类
|
||
|
|
let daily_list = [];
|
||
|
|
let week_list = [];
|
||
|
|
for(let i in data){
|
||
|
|
if(data[i].type == 7){
|
||
|
|
daily_list.push(data[i]);
|
||
|
|
}else if(data[i].type == 8){
|
||
|
|
week_list.push(data[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
daily_list.sort((a,b)=>{
|
||
|
|
return b.finish - a.finish;
|
||
|
|
});
|
||
|
|
|
||
|
|
this.daily_list = daily_list;
|
||
|
|
week_list.sort((a,b)=>{
|
||
|
|
return b.finish - a.finish;
|
||
|
|
});
|
||
|
|
this.week_list = week_list;
|
||
|
|
this.taskList.rebuild([]);
|
||
|
|
if(this.task_index == 0){
|
||
|
|
this.scheduleOnce(()=>{
|
||
|
|
this.taskList.rebuild(daily_list);
|
||
|
|
|
||
|
|
},0.3);
|
||
|
|
}else{
|
||
|
|
this.scheduleOnce(()=>{
|
||
|
|
this.taskList.rebuild(week_list);
|
||
|
|
// nx.gui.setCdTxt(this.lastTime,"",week_list[0].end_time - client.socket.getTime());
|
||
|
|
},0.3);
|
||
|
|
}
|
||
|
|
|
||
|
|
this.setInfo();
|
||
|
|
},
|
||
|
|
|
||
|
|
setInfo(){
|
||
|
|
nx.gui.setString(this.starLev,"",this.mod.getCurLev());
|
||
|
|
let period_data = this.order_data.data_lev_reward_list[this.mod.getCurPeriod()];
|
||
|
|
let cur_data = period_data[this.mod.getCurLev()];
|
||
|
|
let next_lev_data = period_data[this.mod.getCurLev() + 1];
|
||
|
|
if(next_lev_data){
|
||
|
|
nx.gui.setString(this.expLb,"",cc.js.formatStr(nx.text.getKey("ActStarExps_"),this.mod.getCurExp()-cur_data.exp,next_lev_data.exp-cur_data.exp));
|
||
|
|
this.expBar.progress = (this.mod.getCurExp()-cur_data.exp) / (next_lev_data.exp-cur_data.exp);
|
||
|
|
}else{
|
||
|
|
nx.gui.setString(this.expLb,"",cc.js.formatStr(nx.text.getKey("ActStarExps_"),this.mod.getCurExp()-cur_data.exp,400));
|
||
|
|
this.expBar.progress = (this.mod.getCurExp()-cur_data.exp) / 400;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.totalLock.active = !this.mod.getRMBStatus();
|
||
|
|
let card_data = this.order_data.data_advance_card_list[this.mod.getCurPeriod()];
|
||
|
|
let charge_data = game.configs.charge_data.data_charge_data[card_data.charge_id];
|
||
|
|
this.charge_id = card_data.charge_id;
|
||
|
|
let price = Payment.getInstance().fmtPrice(charge_data.val);
|
||
|
|
nx.gui.setString(this.buyBtn,"price",price);
|
||
|
|
},
|
||
|
|
|
||
|
|
freshRewards(rewards){
|
||
|
|
let is_rmb = this.mod.getRMBStatus();
|
||
|
|
nx.gui.setActive(this.buyBtn,"",is_rmb == 0);
|
||
|
|
let exp_datas = this.order_data.data_lev_reward_list[this.mod.getCurPeriod()];
|
||
|
|
let list = [];
|
||
|
|
for(let i in exp_datas){
|
||
|
|
let obj = {};
|
||
|
|
obj.data = exp_datas[i];
|
||
|
|
for(let j in rewards){
|
||
|
|
if(rewards[j].id == exp_datas[i].lev){
|
||
|
|
obj.cfg = rewards[j];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
list.push(obj);
|
||
|
|
}
|
||
|
|
|
||
|
|
this.scheduleOnce(()=>{
|
||
|
|
this.expList.rebuild(list);
|
||
|
|
},0.1);
|
||
|
|
},
|
||
|
|
|
||
|
|
setMaxBaseItem(){
|
||
|
|
let period_id = this.mod.getCurPeriod();
|
||
|
|
let list = this.order_data.data_lev_reward_list[period_id];
|
||
|
|
let max_data = null;
|
||
|
|
for(let i in list){
|
||
|
|
if(max_data){
|
||
|
|
if(list[i].lev > max_data.lev){
|
||
|
|
max_data = list[i];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
max_data = list[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(!max_data)return;
|
||
|
|
nx.gui.setString(this.maxItem,"idx",max_data.lev);
|
||
|
|
let awards = [];
|
||
|
|
for(let idx in max_data.rmb_reward){
|
||
|
|
awards.push({bid:max_data.rmb_reward[idx][0],num:max_data.rmb_reward[idx][1]});
|
||
|
|
}
|
||
|
|
this.maxItemLay.rebuild(awards);
|
||
|
|
let item = cc.instantiate(this.fabItem);
|
||
|
|
let tag = nx.gui.find(this.maxItem,"tag");
|
||
|
|
item.parent = tag;
|
||
|
|
let cmp = nx.gui.getComponent(item,"","cmp.item.base");
|
||
|
|
if(cmp){
|
||
|
|
cmp.rebind(0,max_data.reward[0],"");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickBuyOrder(){
|
||
|
|
nx.bridge.createPanel("WndActStartravelOrder",{mod:this.mod,period:this.mod.getCurPeriod()});
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickAllAward(){
|
||
|
|
this.mod.reqGift(0);
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickBuy(){
|
||
|
|
if(this.charge_id){
|
||
|
|
//花钱买
|
||
|
|
Payment.getInstance().reqPayment(this.charge_id );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
} );
|