83 lines
2.0 KiB
JavaScript
83 lines
2.0 KiB
JavaScript
const ItemBase = require( "nx.fx.sv.expand.item" );
|
|
const HallowsController = require("hallows_controller");
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
base_item:{
|
|
default:null,
|
|
type:cc.Prefab
|
|
},
|
|
task_desc:{
|
|
default:null,
|
|
type:cc.RichText
|
|
},
|
|
complete:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
btn_go:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
btn_get:{
|
|
default:null,
|
|
type:cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
start () {
|
|
|
|
},
|
|
|
|
setEmpty(){
|
|
this.complete.active = false;
|
|
this.btn_get.active = false;
|
|
this.btn_go.active = false;
|
|
},
|
|
|
|
setData(data,index,tag){
|
|
this.setEmpty();
|
|
|
|
if(nx.dt.objEmpty(data)){
|
|
return false;
|
|
}
|
|
this.data = data;
|
|
let task_info = game.configs.hallows_data.data_task[data.id];
|
|
this.config = task_info;
|
|
this.task_desc.string = cc.js.formatStr("%s(%s/%s)", task_info.desc, this.data.value || 0, this.data.target_val || 0);
|
|
if(data.finish == 0){
|
|
this.btn_go.active = true;
|
|
}else if(data.finish == 1){
|
|
this.btn_get.active = true;
|
|
}else if(data.finish == 2){
|
|
this.complete.active = true;
|
|
}
|
|
|
|
let item = cc.instantiate(this.base_item);
|
|
item.parent = this.node;
|
|
item.position = cc.v2(-193,0);
|
|
item.scale = 0.6;
|
|
let cmp = item.getComponent("cmp.item.base");
|
|
cmp.rebind(0,{bid:task_info.items[0][0], num:task_info.items[0][1]},"");
|
|
},
|
|
|
|
clickGetItem(){
|
|
if(!this.data.id)return;
|
|
HallowsController.getInstance().requestSubmitHallowsTask(this.data.id);
|
|
},
|
|
|
|
clickGoTask(){
|
|
|
|
if(this.data && this.config){
|
|
nx.bridge.jumper.jump2Window( this.config.source_id );
|
|
}
|
|
}
|
|
// update (dt) {},
|
|
});
|