Files

132 lines
4.0 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
const ItemBase = require("nx.fx.sv.expand.item");
const HEACT = require("heaven_controller");
cc.Class({
extends: ItemBase,
properties: {
mainNd:{
default:null,
type:cc.Node
},
normal:{
default:null,
type:cc.Node
},
boss:{
default:null,
type:cc.Node
},
stars:{
default:[],
type:[cc.Node]
},
lockNd:{
default:null,
type:cc.Node
},
powerNd:{
default:null,
type:cc.Node
},
levNum:{
default:null,
type:cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
rebind(_index,_data,_key){
this._super(_index,_data,_key);
this.setData(_data);
},
setData(data){
if(nx.dt.objEmpty(data))return;
this.data = data;
nx.gui.setString(this.levNum,"",cc.js.formatStr("%s-%s",data.id,data.order_id));
if(data.order_id % 2 == 0){
this.mainNd.y = -75;
}else{
this.mainNd.y = 75;
}
this.is_pass = false;
this.updateInfo();
},
updateInfo(){
this.custom_data = HEACT.getInstance().getModel().getCustomsDataById(this.data.id,this.data.order_id);
if(nx.dt.objEmpty(this.custom_data))return;
let star_info = this.custom_data.star_info;
for(let i = 0;i < star_info.length;i++){
let nd = this.stars[i];
let info = star_info[i];
if(info && nd){
nx.gui.setActive(nd,"star",info.flag == 1);
}
}
//判斷最大通關id
let max_id = HEACT.getInstance().getModel().getMaxDunId();
//判斷是否通關
let is_done = HEACT.getInstance().getModel().checkCustomsIsPassByDunId(this.data.dun_id);
let btnCmp = nx.gui.getComponent(this.normal,"",cc.Button);
let bossCmp = nx.gui.getComponent(this.boss,"",cc.Button);
this.lockNd.active = false;
this.powerNd.active = true;
// this.levNum.active = true;
if(is_done){//已通過且當前關卡不是最大通關關卡
if(this.custom_data.star < 3){
this.is_pass = false;
}else{
this.is_pass = true;
}
if(this.data.order_id == 10){//boss關卡
bossCmp.interactable = true;
this.boss.active = true;
this.normal.active = false;
}else{
btnCmp.interactable = true;
this.boss.active = false;
this.normal.active = true;
// nx.gui.setActive(this.normal,"select",false);
}
}else{
this.is_pass = false;
if((max_id == 0 && this.data.order_id == 1) || this.data.dun_id == (max_id + 1)){//未通關可挑戰
if(this.data.order_id == 10){//boss關卡
bossCmp.interactable = true;
this.boss.active = true;
this.normal.active = false;
}else{
btnCmp.interactable = true;
this.boss.active = false;
this.normal.active = true;
// nx.gui.setActive(this.normal,"select",true);
}
}else{
if(this.data.order_id == 10){//boss關卡
this.boss.active = true;
this.normal.active = false;
bossCmp.interactable = false;
}else{
this.boss.active = false;
this.normal.active = true;
btnCmp.interactable = false;
}
this.lockNd.active = true;
this.powerNd.active = false;
// this.levNum.active = false;
}
}
},
clickFightInfo(){
if(!this.data)return;
nx.bridge.createPanel("WndHeavenFightinfo",{cfg:this.data,is_pass:this.is_pass});
}
// update (dt) {},
});