242 lines
7.4 KiB
JavaScript
242 lines
7.4 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const HEACT = require("heaven_controller");
|
||
|
|
const HeavenEvent = require("heaven_event");
|
||
|
|
const RankConstant = require("rank_constant");
|
||
|
|
const TipsController = require( "tips_controller" );
|
||
|
|
const ItemLay = require("cmp.common.itemlayout");
|
||
|
|
|
||
|
|
const TipAward = {
|
||
|
|
[1]:"heaven.fight.ten",
|
||
|
|
[2]:"heaven.fight.twenty",
|
||
|
|
[3]:"heaven.fight.thirty"
|
||
|
|
}
|
||
|
|
cc.Class({
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
chapter:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
starNum:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
scoreBar:{
|
||
|
|
default:null,
|
||
|
|
type:cc.ProgressBar
|
||
|
|
},
|
||
|
|
scoreGifts:{
|
||
|
|
default:[],
|
||
|
|
type:[cc.Node]
|
||
|
|
},
|
||
|
|
// lines:{
|
||
|
|
// default:null,
|
||
|
|
// type:cc.Node
|
||
|
|
// },
|
||
|
|
stages:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
stageList:{
|
||
|
|
default:null,
|
||
|
|
type:ItemLay
|
||
|
|
},
|
||
|
|
fabStage:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
},
|
||
|
|
challengeNum:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
buyNum:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad () {
|
||
|
|
this.ctrl = HEACT.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
// this.custom_stage = {};
|
||
|
|
// this.bindGEvent(HeavenEvent.Get_Chapter_Data_Event,this.updateCurInfos.bind(this));
|
||
|
|
this.bindGEvent(HeavenEvent.Add_Chapter_Data_Event,this.updateCurInfos.bind(this));
|
||
|
|
this.bindGEvent(HeavenEvent.Get_Chapter_Award_Event,this.updateGetAwardInfos.bind(this));
|
||
|
|
//更新關卡數據
|
||
|
|
this.bindGEvent(HeavenEvent.Update_Chapter_Basedata_Event,this.refreshStageItems.bind(this));
|
||
|
|
//刷新購買次數
|
||
|
|
this.bindGEvent(HeavenEvent.Update_Chapter_Count_Event,this.updateBuyCount.bind(this));
|
||
|
|
},
|
||
|
|
|
||
|
|
updateBuyCount(){
|
||
|
|
//挑戰信息更新
|
||
|
|
let challengeStr = cc.js.formatStr("%s/%s",this.model.getLeftChallengeCount(),game.configs.dungeon_heaven_data.data_const.refresh_number.val);
|
||
|
|
nx.gui.setString(this.challengeNum,"",challengeStr);
|
||
|
|
//購買次數更新
|
||
|
|
nx.gui.setString(this.buyNum,"",this.model.getTodayLeftBuyCount());
|
||
|
|
},
|
||
|
|
|
||
|
|
updateGetAwardInfos(id){
|
||
|
|
if(id != this.chapter_data.id)return;
|
||
|
|
this.refreshAwards(this.chapter_data.id,this.chapter_data.all_star,this.chapter_data.award_info);
|
||
|
|
},
|
||
|
|
|
||
|
|
//更新信息
|
||
|
|
updateCurInfos(id){
|
||
|
|
this.updateBuyCount();
|
||
|
|
//章節信息
|
||
|
|
if(!id){
|
||
|
|
id = this.model.getOpenMaxChapterId();
|
||
|
|
}
|
||
|
|
this.chapter_data = this.model.getChapterDataById(id);
|
||
|
|
nx.gui.setString(this.chapter,"",cc.js.formatStr(nx.text.getKey("HeaChapter"),this.chapter_data.id));
|
||
|
|
this.refreshAwards(this.chapter_data.id,this.chapter_data.all_star,this.chapter_data.award_info);
|
||
|
|
|
||
|
|
//請求關卡數據
|
||
|
|
this.ctrl.sender25201(this.chapter_data.id);
|
||
|
|
|
||
|
|
//次级查找界面需要关闭
|
||
|
|
nx.bridge.closePanel("WndHeavenChapter");
|
||
|
|
},
|
||
|
|
|
||
|
|
refreshAwards(chapter_id,all_star,infos){
|
||
|
|
let award_data = game.configs.dungeon_heaven_data.data_star_award[chapter_id];
|
||
|
|
let max_star = all_star;//每章的最大星級
|
||
|
|
infos.sort((a,b)=>{
|
||
|
|
return a.id - b.id;
|
||
|
|
});
|
||
|
|
for(let i = 0;i < this.scoreGifts.length;i++){
|
||
|
|
let nd = this.scoreGifts[i];
|
||
|
|
let data = infos[i];
|
||
|
|
if(data){
|
||
|
|
let cfg = null;
|
||
|
|
for(let a in award_data){
|
||
|
|
if(award_data[a].award_id == data.id){
|
||
|
|
cfg = award_data[a];
|
||
|
|
max_star = cfg.limit_star;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setActive(nd,"lock",data.flag == 0);
|
||
|
|
nx.gui.setActive(nd,"get",data.flag == 2);
|
||
|
|
nx.gui.setString(nd,"score",cfg.limit_star || "");
|
||
|
|
let cmp = nx.gui.getComponent( nd, "show", "cmp.common.itemlayout" );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.rebuild( cfg.award );
|
||
|
|
}
|
||
|
|
nx.gui.setActive( nd, "show", false );
|
||
|
|
nx.gui.setActive( this, "main/hideall", false );
|
||
|
|
nx.mTip.openTip(TipAward[data.id],data.flag == 1)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setString(this.starNum,"",cc.js.formatStr("%s/%s",all_star,max_star));
|
||
|
|
this.scoreBar.progress = all_star / max_star;
|
||
|
|
},
|
||
|
|
|
||
|
|
refreshStageItems(){
|
||
|
|
let customs_data = game.configs.dungeon_heaven_data.data_customs[this.chapter_data.id];
|
||
|
|
if(!customs_data)return;
|
||
|
|
// this.lines.active = true;
|
||
|
|
let list = [];
|
||
|
|
for(let i in customs_data){
|
||
|
|
list.push(customs_data[i]);
|
||
|
|
}
|
||
|
|
this.stageList.rebuild(list);
|
||
|
|
},
|
||
|
|
|
||
|
|
start () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs(params) {
|
||
|
|
this.ctrl.sender25200((_data)=>{
|
||
|
|
if(_data){
|
||
|
|
this.updateCurInfos();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed() {
|
||
|
|
this.stageList.rebuild([]);
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchHideAll: function(){
|
||
|
|
|
||
|
|
for (let i = 0; i < this.scoreGifts.length; i++) {
|
||
|
|
let nod = this.scoreGifts[i];
|
||
|
|
nx.gui.setActive( nod, "show", false );
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setActive( this, "main/hideall", false );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
clickStarAward(_index){
|
||
|
|
let index = Number(_index);
|
||
|
|
let award_info = this.chapter_data.award_info[index];
|
||
|
|
if( award_info.flag != 1){
|
||
|
|
for (let i = 0; i < this.scoreGifts.length; i++) {
|
||
|
|
let nod = this.scoreGifts[i];
|
||
|
|
if( i != index ){
|
||
|
|
nx.gui.setActive( nod, "show", false );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
let show = nx.gui.find( this.scoreGifts[index], "show" );
|
||
|
|
nx.gui.setActive( show, "", !show.active );
|
||
|
|
nx.gui.setActive( this, "main/hideall", show.active == true );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// if(award_info.flag == 0){
|
||
|
|
|
||
|
|
// }else if(award_info.flag == 1){
|
||
|
|
this.ctrl.sender25215(this.chapter_data.id,award_info.id);
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
|
||
|
|
clickBuyChallengeNums(){//購買挑戰次數
|
||
|
|
if(this.model.getTodayLeftBuyCount() > 0){
|
||
|
|
let buy_num = this.model.getTodayBuyCount()
|
||
|
|
let buy_cfg = game.configs.dungeon_heaven_data.data_count_buy[ buy_num + 1 ];
|
||
|
|
if( buy_cfg ) {
|
||
|
|
let str = cc.js.formatStr(nx.text.getKey("lab_star_tower_main_window_tip7"),3,buy_cfg.cost);
|
||
|
|
let fun = () => {
|
||
|
|
this.ctrl.sender25207()
|
||
|
|
}
|
||
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
||
|
|
_box.close();
|
||
|
|
if(_key == "confirm"){
|
||
|
|
fun();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
nx.tbox("MonoBuyNoTime");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
clickFindAllChapters(){
|
||
|
|
nx.bridge.createPanel("WndHeavenChapter",{});
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickRank() {
|
||
|
|
nx.bridge.createPanel( "WndPVERankAward", {
|
||
|
|
type: RankConstant.RankType.heaven,
|
||
|
|
ops: [ "RankNow" ],
|
||
|
|
show: "RankNow",
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchHelp: function(){
|
||
|
|
|
||
|
|
let TC = TipsController.getInstance();
|
||
|
|
let explain = game.configs.dungeon_heaven_data.data_const;
|
||
|
|
TC.showTextPanel( "tip", explain.dunheaven_rule.desc );
|
||
|
|
},
|
||
|
|
// update (dt) {},
|
||
|
|
});
|