260 lines
8.5 KiB
JavaScript
260 lines
8.5 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const NxSpine = require( "nx.fx.spine" );
|
||
|
|
const ItemLayout = require( "cmp.common.itemlayout" );
|
||
|
|
const mod = require( "act.doublered.mod" );
|
||
|
|
const FID = require( "bridge.function.ids" );
|
||
|
|
const themeMod = require( "acts.mod" );
|
||
|
|
|
||
|
|
/***
|
||
|
|
*
|
||
|
|
* 翻倍红包相关
|
||
|
|
*/
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
spRole: { default: null, type: NxSpine },
|
||
|
|
|
||
|
|
nodRates:{
|
||
|
|
default: null,
|
||
|
|
type : cc.Node,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodLeft:{
|
||
|
|
default: null,
|
||
|
|
type : cc.Node,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodLeftReward:{
|
||
|
|
default: null,
|
||
|
|
type : ItemLayout,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodRight:{
|
||
|
|
default: null,
|
||
|
|
type : cc.Node,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodLeftTitle: {
|
||
|
|
default: null,
|
||
|
|
type : cc.Node,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodOp: {
|
||
|
|
default: null,
|
||
|
|
type : cc.Node,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodScroller:{
|
||
|
|
default: null,
|
||
|
|
type : cc.ScrollView,
|
||
|
|
},
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
onLoad: function() {
|
||
|
|
|
||
|
|
this.mod = mod.getInstance();
|
||
|
|
if( !this.mod ){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.spRole.load( "resDB/models/H30103/show", ( _e ) => {
|
||
|
|
if( !_e ) {
|
||
|
|
this.spRole.action( "drama1", true );
|
||
|
|
} else {
|
||
|
|
this.spRole.stop();
|
||
|
|
}
|
||
|
|
} );
|
||
|
|
let rfgs = gdata( this.mod.data.config, "data_drama_reward" );
|
||
|
|
this.rcfgs = rfgs;
|
||
|
|
this.help = gdata( this.mod.data.config, "data_desc" )[1];
|
||
|
|
let len = Object.keys( rfgs ).length;
|
||
|
|
let cfgcon = gdata( this.mod.data.config, "data_drama_const" );
|
||
|
|
this.base_diamond = cfgcon.initial_diamond.val;
|
||
|
|
this.reward = cfgcon.grand_prize.val;
|
||
|
|
let data = {
|
||
|
|
bid: this.reward[0],
|
||
|
|
num: this.reward[1],
|
||
|
|
}
|
||
|
|
this.nodLeftReward.rebuild( [data] );
|
||
|
|
|
||
|
|
nx.gui.setActive( this.nodLeftReward.node.parent, "", false );
|
||
|
|
|
||
|
|
|
||
|
|
nx.gui.gocChildren( this.nodRates, "", len );
|
||
|
|
|
||
|
|
let chd = this.nodRates.children;
|
||
|
|
for (let i in rfgs ) {
|
||
|
|
let info = rfgs[i];
|
||
|
|
let nod = chd[ info.id - 1 ];
|
||
|
|
nx.gui.setString( nod, "normal/num", info.num );
|
||
|
|
nx.gui.setString( nod, "focus/num", info.num );
|
||
|
|
nx.bridge.setIconS( nod, "normal/icon", 3 );
|
||
|
|
nx.bridge.setIconS( nod, "focus/icon", 3 );
|
||
|
|
nx.gui.setString( nod, "normal/count", nx.text.format( "ActRate", info.rate ) );
|
||
|
|
nx.gui.setString( nod, "focus/count", nx.text.format( "ActRate", info.rate ) );
|
||
|
|
nx.gui.setActive( nod, "focus", false );
|
||
|
|
nx.gui.setActive( nod, "normal", true );
|
||
|
|
}
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "doublered", this.freshDoubleRedInfo.bind( this ) ],
|
||
|
|
] );
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onEnable: function(){
|
||
|
|
|
||
|
|
this.mod.reqDoubleRedData();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
delete this.mod;
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
freshDoubleRedInfo: function( _data ){
|
||
|
|
|
||
|
|
// if( )
|
||
|
|
// {"status":1,"end_time":1696175999,"is_activate":0,"num":0,"role_ids":[]}
|
||
|
|
if( !this.nodRates ){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
let btn = nx.gui.getComponent( this.nodOp, "charge", cc.Button );
|
||
|
|
if( btn ){
|
||
|
|
btn.interactable = _data.is_activate == 0 && _data.status == 1;
|
||
|
|
nx.gui.setOutlineColor( this.nodOp, "charge/txt", _data.is_activate == 0 && _data.status == 1 ? new cc.color( "#945234" ) : cc.Color.BLACK );
|
||
|
|
}
|
||
|
|
let rate = 0;
|
||
|
|
let lucklist = "";
|
||
|
|
let pos = 0;
|
||
|
|
if( this.rcfgs ){
|
||
|
|
let len = Object.keys( this.rcfgs ).length;
|
||
|
|
for (let i in this.rcfgs ) {
|
||
|
|
let rfg = this.rcfgs[i];
|
||
|
|
let lucky_item = _data.role_ids[i-1];
|
||
|
|
if( lucky_item ){
|
||
|
|
lucklist += i + "." + lucky_item.name + "\n";
|
||
|
|
}
|
||
|
|
let next = this.rcfgs[rfg.id+1];
|
||
|
|
nx.gui.setActive( this.nodRates.children[rfg.id - 1], "focus", false );
|
||
|
|
nx.gui.setActive( this.nodRates.children[rfg.id - 1], "normal", true );
|
||
|
|
if( next ){
|
||
|
|
|
||
|
|
if( ( _data.num >= rfg.num && _data.num > 100 ) || ( _data.num >= rfg.num && _data.num < next.num ) ){
|
||
|
|
rate = rfg.rate;
|
||
|
|
pos = rfg.id;
|
||
|
|
// break;
|
||
|
|
}else{
|
||
|
|
if( _data.num > rfg.num && _data.num <= next.num ){
|
||
|
|
rate = next.rate;
|
||
|
|
pos = next.id;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}else{
|
||
|
|
next = this.rcfgs[len];
|
||
|
|
if( ( _data.num >= rfg.num && _data.num > 100 ) || ( _data.num >= rfg.num && _data.num < next.num ) ){
|
||
|
|
rate = rfg.rate;
|
||
|
|
pos = rfg.id;
|
||
|
|
// break;
|
||
|
|
}else{
|
||
|
|
if( _data.num > rfg.num && _data.num <= next.num ){
|
||
|
|
rate = next.rate;
|
||
|
|
pos = next.id;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// let nod = this.nodRates.parent.parent;
|
||
|
|
|
||
|
|
if( this.nodScroller ){
|
||
|
|
if( pos - 1 <= 4 ){
|
||
|
|
this.nodScroller.scrollToTop( 0.01 ); // scrollTo
|
||
|
|
}else{
|
||
|
|
if( pos - 1 > 4 && pos - 1 < 11 ){
|
||
|
|
let posp = cc.v2( 0, ( pos - 1 ) * 74 );
|
||
|
|
this.nodScroller.setContentPosition( posp ); // scrollTo
|
||
|
|
}else{
|
||
|
|
this.nodScroller.scrollToBottom( 0.01 ); // scrollTo
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
nx.gui.setActive( this.nodRates.children[ pos - 1 ], "focus", true );
|
||
|
|
nx.gui.setActive( this.nodRates.children[ pos - 1 ], "normal", false );
|
||
|
|
|
||
|
|
|
||
|
|
if( _data.status == 1 ){
|
||
|
|
nx.gui.setString( this.nodOp, "charge/txt", _data.is_activate == 0 ? nx.text.getKey( "GotoCharge" ) : nx.text.getKey( "ActBtnTip" ) );
|
||
|
|
nx.gui.setString( this.nodLeftTitle, "", nx.text.getKey( "ActHelpTitle" ) );
|
||
|
|
nx.gui.setStringRich( this.nodLeft, "", this.help.desc );
|
||
|
|
}else{
|
||
|
|
if( _data.end_time != 0 ){
|
||
|
|
nx.gui.setString( this.nodLeftTitle, "", nx.text.getKey( "ActHelpTitle" ) );
|
||
|
|
nx.gui.setStringRich( this.nodLeft, "", this.help.desc );
|
||
|
|
|
||
|
|
}
|
||
|
|
else{
|
||
|
|
nx.gui.setString( this.nodLeftTitle, "", nx.text.getKey( "ActLuckyList" ) );
|
||
|
|
nx.gui.setStringRich( this.nodLeft, "", lucklist );
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setString( this.nodOp, "charge/txt", nx.text.getKey( "lab_planesafk_main_have_over" ) );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
nx.bridge.setIconS( this.nodOp, "rbg/icon", 3 );
|
||
|
|
nx.gui.setString( this.nodOp, "rbg/num", rate > 0 ? rate * this.base_diamond : this.base_diamond );
|
||
|
|
nx.gui.setString( this.nodOp, "rate_bg/count", nx.text.format( "ActRate", rate ) );
|
||
|
|
nx.gui.setActive( this.nodOp, "rbg", true );
|
||
|
|
nx.gui.setActive( this.nodOp, "rate_bg", true );
|
||
|
|
nx.gui.setActive( this.nodOp, "status", _data.is_activate != 0 );
|
||
|
|
let cd = _data.end_time - Math.floor( cc.sys.now() / 1000 ) > 0 ? _data.end_time - Math.floor( cc.sys.now() / 1000 ) : 0;
|
||
|
|
if( cd > 0 ){
|
||
|
|
nx.gui.setCdTxt( this.nodRight, "tbg/time", _data.end_time - Math.floor( cc.sys.now() / 1000 ) );
|
||
|
|
}else{
|
||
|
|
nx.gui.setString( this.nodRight, "tbg/time", nx.text.getKey( "lab_recruit_hero_window_tip_6" ) );
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setString( this.nodRight, "result/num", _data.num );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchCharge: function(){
|
||
|
|
|
||
|
|
nx.bridge.createPanel( "WndPayment", { key: "recharge" } );
|
||
|
|
this.close();
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchReward: function(){
|
||
|
|
|
||
|
|
nx.gui.setActive( this.nodLeftReward.node.parent, "", !this.nodLeftReward.node.parent.active );
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchClose: function(){
|
||
|
|
|
||
|
|
this.close();
|
||
|
|
let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
|
||
|
|
|
||
|
|
nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
|
||
|
|
},
|
||
|
|
});
|