75 lines
1.9 KiB
JavaScript
75 lines
1.9 KiB
JavaScript
const ItemBase = require("cmp.item.base");
|
|
const Act7Mod = require("act.training7.mod");
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
dayNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
tipNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
goalBtn:{
|
|
default:null,
|
|
type:cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
start () {
|
|
|
|
},
|
|
|
|
setGoal(goal_data){
|
|
this.goal_data = goal_data;
|
|
},
|
|
|
|
freshAll(){
|
|
this._super();
|
|
|
|
//设置天数
|
|
let index = this.goal_data.id % 100;
|
|
this.today = index;
|
|
nx.gui.setString(this.dayNd,"num",cc.js.formatStr(nx.text.getKey("action_str16"),index));
|
|
|
|
let last_score = Act7Mod.getInstance().getLastScore();
|
|
if(last_score >= this.goal_data.goal){
|
|
nx.gui.setActive(this.goalBtn,"",true);
|
|
nx.gui.setActive(this.tipNd,"",true);
|
|
}
|
|
|
|
let finish_list = Act7Mod.getInstance().getSevenGoalBoxList();
|
|
if(finish_list){
|
|
for(let i in finish_list){
|
|
if(finish_list[i].goal_id == this.goal_data.id){
|
|
nx.gui.setActive(this.nodFocus.node,"",finish_list[i].status == 2);
|
|
if(finish_list[i].status == 2){
|
|
nx.gui.setActive(this.tipNd,"",false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
onTouchGoal(){
|
|
if(nx.dt.objEmpty(this.goal_data))return;
|
|
let item_cfg = gitemdata(this.goal_data.award[0][0]);
|
|
let str = cc.js.formatStr(nx.text.getKey("lab_taskHuoyue"),item_cfg.name,this.goal_data.award[0][1]);
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
|
_box.close();
|
|
if(_key == "confirm"){
|
|
Act7Mod.getInstance().sender13602(5, this.today, this.goal_data.id, 0);
|
|
}
|
|
});
|
|
}
|
|
|
|
// update (dt) {},
|
|
});
|