352 lines
12 KiB
JavaScript
352 lines
12 KiB
JavaScript
const BasePage = require( "act.page.base" );
|
|
const NXSpine = require( "nx.fx.spine" );
|
|
const BCController = require( "backpack_controller" );
|
|
const FID = require( "bridge.function.ids" );
|
|
const TipsController = require( "tips_controller" );
|
|
|
|
cc.Class({
|
|
extends: BasePage,
|
|
|
|
properties: {
|
|
|
|
nodRole: { default: null, type: NXSpine, displayName: "顯示的夥伴節點" },
|
|
nodMiniRole: { default: null, type: NXSpine, displayName: "小顯示的夥伴節點" },
|
|
nodTimesInfo: { default: null, type: cc.Node, displayName: "結束時間" },
|
|
nodOp : { default: null, type: cc.Node, displayName: "操作節點" },
|
|
nodInfo : { default: null, type: cc.Node, displayName: "夥伴信息節點" },
|
|
nodMat : { default: null, type: cc.Node, displayName: "材料显示" },
|
|
nodRank : { default: null, type: cc.Node, displayName: "排行显示" },
|
|
nodLog : { default: null, type: cc.Node, displayName: "日志" },
|
|
},
|
|
|
|
|
|
build: function( _data ) {
|
|
|
|
this._super( _data );
|
|
// console.log( "當前的相關數據顯示" + JSON.stringify( _data ) );
|
|
|
|
// 获取指定主题信息
|
|
if( !this.mod ){
|
|
return;
|
|
}
|
|
this.unscheduleAllCallbacks();
|
|
|
|
this.totaldiamond = gdata( this.data.config, "data_const" ).diamond_times.val;
|
|
|
|
let mats = this.mod.getNewHeroMat();
|
|
|
|
for (let m = 0; m < this.nodMat.children.length; m++) {
|
|
let mat = mats[m];
|
|
let nod = this.nodMat.children[m];
|
|
let cmp = nx.gui.getComponent( nod, "", "bridge.binder.item.icon.count" );
|
|
if( cmp ){
|
|
cmp.setID( mat );
|
|
}
|
|
}
|
|
|
|
nx.gui.setString( this.nodTimesInfo, "date/txt", nx.bridge.time.toNeedTime( this.data.end_time ) );
|
|
// 取相關的配置
|
|
let showinfo = this.mod.getNewHeroCfg();
|
|
this.showinfo = showinfo;
|
|
if( nx.dt.objNEmpty( showinfo ) ){
|
|
|
|
let roleInfo = game.configs.partner_data.data_partner_base[showinfo.bid];
|
|
|
|
this.roleInfo = roleInfo;
|
|
let skills = gdata( "partner_data", "data_partner_star", roleInfo.bid + "_" + roleInfo.init_star ).skills;
|
|
let path = "resDB/models/" + roleInfo.draw_res + "/show";
|
|
let spath = "resDB/models/" + roleInfo.draw_res + "/" + roleInfo.draw_res;
|
|
this.nodRole.load( path, ( _e ) => {
|
|
if( !_e ) {
|
|
this.nodRole.action( showinfo.action, true );
|
|
} else {
|
|
this.nodRole.stop();
|
|
}
|
|
} );
|
|
|
|
this.nodMiniRole.load( spath, ( _e ) => {
|
|
if( !_e ) {
|
|
this.nodMiniRole.action( "stand2", true );
|
|
} else {
|
|
this.nodMiniRole.stop();
|
|
}
|
|
} );
|
|
nx.gui.setString( this.nodInfo, "base/name", roleInfo.name );
|
|
nx.gui.setSpriteFrame( this.nodInfo, "base/camp", cc.path.join( "coms/images/camps" + roleInfo.camp_type ) );
|
|
nx.gui.setSpriteFrame( this.nodInfo, "stars", cc.path.join( "coms/images", "star" + roleInfo.init_star ) );
|
|
nx.gui.setSpriteFrame( this.nodInfo, "qa", cc.path.join( "coms/images", "mk_partner_qa" + roleInfo.quality ) );
|
|
|
|
let ccskills = nx.dt.objClone( skills );
|
|
let delskill = ccskills.shift();
|
|
|
|
let skillsnod = nx.gui.find( this.nodInfo, "skills" );
|
|
nx.gui.gocChildren( skillsnod, "", ccskills.length );
|
|
|
|
this.scheduleOnce( ()=>{
|
|
let skillsnods= nx.gui.find( this.nodInfo, "skills" ).children;
|
|
for (let i = 0; i < skillsnods.length; i++) {
|
|
let skill = ccskills[i];
|
|
let skillnod = skillsnods[i];
|
|
let cmp = nx.gui.getComponent( skillnod, "", "cmp.skill.base" );
|
|
if( cmp ){
|
|
cmp.setData( skill[1] );
|
|
}
|
|
}
|
|
}, 0.1 );
|
|
|
|
|
|
|
|
}
|
|
|
|
this.mod.vbind( this, [
|
|
[ "newheroSummonInfo", this.freshInfo.bind( this ) ],
|
|
[ "newheroSummonLog", this.freshLog.bind( this ) ]
|
|
] )
|
|
|
|
// 12秒調用相關請求接口
|
|
this.schedule( ()=>{
|
|
this.mod.reqSummonLog();
|
|
}, 12, cc.macro.REPEAT_FOREVER );
|
|
|
|
this.mod.reqSummonLog();
|
|
|
|
},
|
|
|
|
|
|
onEnable: function(){
|
|
|
|
// this.unscheduleAllCallbacks();
|
|
this.mod.reqBaseInfo();
|
|
|
|
},
|
|
|
|
// 销毁
|
|
onDestroy: function() {
|
|
|
|
// 活动监听解除
|
|
if( this.mod ) {
|
|
this.mod.vunbind( this );
|
|
}
|
|
|
|
this._super();
|
|
},
|
|
|
|
/***
|
|
* [11:22:57:463][recv] <<<[23270]:{
|
|
* "camp_id":51174,
|
|
* "free_time":0,
|
|
* "gold_time":20,
|
|
* "times":0,
|
|
* "start_time":1717603200,
|
|
* "end_time":1718812559,
|
|
* "item_id":1006,
|
|
* "item_num":0,"must_count":110,"lucky_bid":20514,"my_idx":0,"name":"明月之極速","my_val1":0,"rank_list":[]}
|
|
*/
|
|
freshInfo: function( _data ){
|
|
|
|
|
|
if( !_data ){
|
|
return;
|
|
}
|
|
this.herodatacfg = gdata( this.data.config, "data_const" );
|
|
this.summoninfo = _data;
|
|
let gold_times = _data.gold_time;
|
|
let must_time = _data.must_count;
|
|
|
|
nx.gui.setString( this.nodTimesInfo, "times/must/times", must_time );
|
|
nx.gui.setString( this.nodTimesInfo, "times/diamond/times", gold_times + "/" + this.totaldiamond );
|
|
nx.gui.setString( this.nodTimesInfo, "times/diamond/desc", this.herodatacfg.diamond_times.desc );
|
|
nx.gui.setString( this.nodTimesInfo, "times/must/desc", nx.text.format( "ActNewHeroMustTip", this.roleInfo.name ) );
|
|
|
|
this.freshOp();
|
|
|
|
let ranks = _data.rank_list;
|
|
|
|
/***
|
|
* <<[23270]:{"camp_id":51174,
|
|
* "free_time":1717689600,"gold_time":7,
|
|
* "times":14,"start_time":1717603200,
|
|
* "end_time":1718812559,"item_id":1006,
|
|
* "item_num":0,"must_count":96,"lucky_bid":20514,
|
|
* "my_idx":1,"name":"愛你半夏","my_val1":14,
|
|
* "rank_list":[{"name":"愛你半夏","val1":14,"idx":1},{"name":"琉璃冷漠","val1":1,"idx":2}]}
|
|
*/
|
|
nx.gui.gocChildren( this.nodRank, "list/view/content", _data.rank_list.length );
|
|
let chd = nx.gui.find( this.nodRank, "list/view/content" ).children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
|
|
|
|
let info = ranks[i];
|
|
if( info ){
|
|
nx.gui.setString( nod, "name", info.name );
|
|
nx.gui.setString( nod, "times", info.val1 );
|
|
nx.gui.setActive( nod, "rank/"+ ( "rank"+ info.idx ), true );
|
|
}
|
|
}
|
|
nx.gui.setString( this.nodRank, "me/name", _data.name );
|
|
nx.gui.setString( this.nodRank, "me/rank/rank4/txt", _data.my_idx );
|
|
|
|
nx.gui.setActive( this.nodRank, _data.my_idx <= 3 ? "me/rank/"+ ( "rank"+ _data.my_idx ) : "me/rank/rank4" , true );
|
|
nx.gui.setString( this.nodRank, "me/name", _data.name );
|
|
nx.gui.setString( this.nodRank, "me/times", _data.my_val1 );
|
|
},
|
|
|
|
|
|
freshOp: function( ){
|
|
|
|
nx.gui.setString( this.nodOp, "once/free/time", this.summoninfo.free_time == 0 ? nx.text.getKey( "Free" ) : nx.text.format( "FreeCD", nx.bridge.time.toNeedTime( this.summoninfo.free_time ) ) );
|
|
// nx.gui.setActive( this.nodOp, "once/free", this.summoninfo.free_time != 0 );
|
|
nx.gui.setActive( this.nodOp, "once/tip", this.summoninfo.free_time == 0 );
|
|
let mat = this.showinfo.loss_item_once[0][0];
|
|
let BC = BCController.getInstance().getModel();
|
|
let have = BC.getItemNumByBid( mat );
|
|
let matfirst = [];
|
|
let matten = [];
|
|
|
|
let self = this;
|
|
|
|
let dealShow = function(){
|
|
|
|
if( have == 0 ){
|
|
|
|
matfirst = self.showinfo.loss_gold_once[0];
|
|
matten = self.showinfo.loss_gold_ten[0];
|
|
|
|
}else if( have >= self.showinfo.loss_item_ten[0][1] ){
|
|
|
|
matfirst = self.showinfo.loss_item_once[0];
|
|
matten = self.showinfo.loss_item_ten[0];
|
|
}else if( have >= self.showinfo.loss_item_once[0][1] && have < self.showinfo.loss_item_ten[0][1] ) {
|
|
matfirst = self.showinfo.loss_item_once[0];
|
|
matten = self.showinfo.loss_gold_ten[0];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if( this.summoninfo.gold_time != 0 ){
|
|
|
|
|
|
if( this.summoninfo.gold_time >= 10 ){
|
|
|
|
/**
|
|
* 沒有材料,顯示鑽石
|
|
* 材料不小於十次時 顯示的都是材料
|
|
* 材料不多於十次消耗 一次抽顯示的材料 十次抽顯示的鑽石
|
|
* */
|
|
dealShow();
|
|
|
|
}else{
|
|
matfirst = this.showinfo.loss_gold_once[0];
|
|
matten = this.showinfo.loss_gold_ten[0];
|
|
}
|
|
|
|
}else{
|
|
dealShow();
|
|
}
|
|
|
|
// ActNewHeroSum
|
|
nx.gui.setString( this.nodOp, "once/btn/list/num", matfirst[1] );
|
|
nx.bridge.setIconS( this.nodOp, "once/btn/list/icon", matfirst[0] );
|
|
nx.gui.setString( this.nodOp, "once/btn/txt", nx.text.format( "ActNewHeroSum", this.showinfo.loss_item_once[0][1] ) );
|
|
nx.gui.find( this.nodOp, "once/btn" ).times = this.showinfo.loss_item_once[0][1];
|
|
nx.gui.find( this.nodOp, "once/btn" ).itemm = matfirst;
|
|
nx.gui.find( this.nodOp, "ten/btn" ).times = this.showinfo.loss_item_ten[0][1];
|
|
nx.gui.setString( this.nodOp, "ten/btn/list/num", matten[1] );
|
|
nx.gui.find( this.nodOp, "ten/btn" ).itemm = matten;
|
|
nx.bridge.setIconS( this.nodOp, "ten/btn/list/icon", matten[0] );
|
|
nx.gui.setString( this.nodOp, "ten/btn/txt", nx.text.format( "ActNewHeroSum", this.showinfo.loss_item_ten[0][1] ) );
|
|
},
|
|
|
|
|
|
// 傳入 次數 類型 --1 免費 --3 鑽石 --4 道具
|
|
onTouchSum: function( _nod ){
|
|
|
|
let type = 0;
|
|
if( _nod.times == this.showinfo.loss_item_once[0][1] ){
|
|
if( this.summoninfo.free_time == 0 ){
|
|
type = 1;
|
|
}else{
|
|
if( _nod.itemm[0] == this.showinfo.loss_item_once[0][0] ){
|
|
type = 4;
|
|
}else{
|
|
type = 3;
|
|
}
|
|
}
|
|
}else{
|
|
if( _nod.itemm[0] == this.showinfo.loss_item_ten[0][0] ){
|
|
type = 4;
|
|
}else{
|
|
type = 3;
|
|
}
|
|
}
|
|
|
|
let mat = _nod.itemm[0];
|
|
let num = _nod.itemm[1];
|
|
|
|
let BC = BCController.getInstance().getModel();
|
|
let have = BC.getItemNumByBid( mat );
|
|
|
|
if( ( this.summoninfo.gold_time - _nod.times ) < 0 && type == 3 ){
|
|
nx.tbox( "ActNewHeroDiaTimeNoEnough" );
|
|
return;
|
|
}
|
|
|
|
if( have < num ){
|
|
nx.tbox( "SummonItemNotEnough" );
|
|
return;
|
|
}
|
|
|
|
|
|
this.mod.reqSummon( _nod.times, type );
|
|
|
|
|
|
},
|
|
|
|
freshLog: function( _log ){
|
|
|
|
if( !_log ){
|
|
return;
|
|
}
|
|
// if( _log )
|
|
let log = _log.logs;
|
|
nx.gui.gocChildren( this.nodLog, "", log.length );
|
|
let chd = this.nodLog.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
let logss = log[i];
|
|
nx.gui.setString( nod, "", logss.msg );
|
|
}
|
|
|
|
},
|
|
|
|
onTouchExchange: function(){
|
|
|
|
nx.bridge.jumper.jump2ActPage( this.showinfo.exchange );
|
|
|
|
},
|
|
|
|
onTouchGift: function(){
|
|
|
|
nx.bridge.jumper.jump2ActPage( this.showinfo.jump );
|
|
},
|
|
|
|
onTouchRank: function(){
|
|
|
|
nx.bridge.createPanel( "WndRankInfo", { type: 66, camp_id : this.data.camp_id } );
|
|
},
|
|
|
|
onTouchRate: function(){
|
|
|
|
let txt = this.mod.getNewHeroRate();
|
|
TipsController.getInstance().showTextPanel( "PrayRate", txt );
|
|
},
|
|
|
|
onTouchHelp: function(){
|
|
let explain = this.mod.getNewHeroHelp();
|
|
TipsController.getInstance().showTextPanel( explain.name, explain.desc );
|
|
}
|
|
|
|
});
|