201 lines
6.2 KiB
JavaScript
201 lines
6.2 KiB
JavaScript
/****************
|
|
* 僚机科研单项
|
|
*/
|
|
|
|
const ElfinController = require( "elfin_controller" );
|
|
const ElfinConst = require("elfin_const");
|
|
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
icon : { default: null, type : cc.Node, displayName : "宝箱底图" },
|
|
nodStatus : { default: null, type : cc.Node, displayName : "状态" },
|
|
nodLock : { default: null, type : cc.Node, displayName : "锁定状态" },
|
|
nodTime : { default: null, type : cc.Node, displayName : "时间显示" },
|
|
},
|
|
|
|
onLoad(){
|
|
|
|
},
|
|
|
|
|
|
freshAll:function( _data ){
|
|
|
|
let data = _data;
|
|
this.open = data.is_open;
|
|
this.state = data.state;
|
|
this.endTime = data.all_end_time;
|
|
this.info = _data;
|
|
|
|
this.setLocked();
|
|
this.setTime();
|
|
this.setStatus();
|
|
this.setIcon();
|
|
|
|
},
|
|
|
|
setLocked: function (){
|
|
|
|
let desc = game.configs.sprite_data.data_hatch_data[this.info.id];
|
|
|
|
if( this.nodLock ){
|
|
nx.gui.setActive( this.nodLock,"", this.open != 1 );
|
|
nx.gui.setString( this.nodLock, "txt", desc.desc1 );
|
|
}
|
|
|
|
if( nx.gui.find( this, "add" ) ){
|
|
nx.gui.setActive( nx.gui.find( this, "add" ),"", this.open == 1 );
|
|
}
|
|
},
|
|
|
|
setTime: function (){
|
|
|
|
//设置时间
|
|
|
|
nx.gui.setActive( this.nodTime, "", this.endTime != 0 );
|
|
let wfg = game.configs.sprite_data.data_const.liaoji_materials;
|
|
let action = parseInt( this.info.do_id - wfg.val[0] + 1 ) ;
|
|
let cmp = nx.gui.getComponent( this, "finish", "nx.fx.spine" );
|
|
if( this.endTime != 0 ){
|
|
if( this.info.state == 1 ){
|
|
if( cmp ){
|
|
cmp.stop();
|
|
cmp.load( "resDB/effects/E80031/action", ( _e ) => {
|
|
if( !_e ) {
|
|
cmp.action( "action", true );
|
|
} else {
|
|
cmp.stop();
|
|
}
|
|
} );
|
|
|
|
}
|
|
this.setFreeCD( ( this.endTime ) );
|
|
}
|
|
if( this.info.state == 2 ){
|
|
nx.gui.setString( this.nodTime, "txt", nx.text.getKey( "elfin_hatch_item_4" ) );
|
|
if( cmp ){
|
|
cmp.stop();
|
|
cmp.load( "resDB/effects/E80032/action", ( _e ) => {
|
|
if( !_e ) {
|
|
cmp.action( ("action" + action ), true );
|
|
} else {
|
|
cmp.stop();
|
|
}
|
|
} );
|
|
|
|
}
|
|
}
|
|
|
|
if( this.info.state == 0 ){
|
|
nx.gui.setActive( this.nodTime, "", false );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nx.gui.setActive( this, "finish", this.info.state != 0 );
|
|
|
|
|
|
},
|
|
|
|
|
|
// 免费倒计时
|
|
setFreeCD: function( _dtFree ) {
|
|
|
|
this.unscheduleAllCallbacks();
|
|
|
|
if( !nx.dt.numPositive( _dtFree, false ) ) {
|
|
return;
|
|
}
|
|
|
|
let self = this;
|
|
// let rate = game.configs.sprite_data.data_const.hatch_rate.val;
|
|
let tick = function() {
|
|
let interval = Utils.getTimeInterval( _dtFree );
|
|
// console.log( "当前的倒计时" + interval );
|
|
if( interval <= 0 ) {
|
|
self.unscheduleAllCallbacks();
|
|
nx.gui.setString( self.nodTime, "txt", "" );
|
|
return;
|
|
}
|
|
|
|
let time = Utils.changeIntevalToDate( interval );
|
|
let txt = time.H + ":" + time.M + ":" + time.S;
|
|
nx.gui.setString( self.nodTime, "txt", txt );
|
|
};
|
|
|
|
this.schedule( tick, 1, cc.macro.REPEAT_FOREVER );
|
|
tick();
|
|
|
|
},
|
|
|
|
setStatus: function (){
|
|
|
|
if( this.info.is_open != 0 && this.info.is_open != 2 ){
|
|
//设置状态
|
|
|
|
let clr = cc.Color.WHITE;
|
|
// let clr = ( this.state == ElfinConst.Hatch_Status.Hatch || this.state == ElfinConst.Hatch_Status.Over ) ? new cc.Color().fromHEX( "#066926" ) : new cc.Color().fromHEX("#896202");
|
|
let path = ( this.state == ElfinConst.Hatch_Status.Hatch ) ? cc.path.join( "prefab/partner/wing/ui/partner_62" ) : this.state == ElfinConst.Hatch_Status.Over ? cc.path.join( "prefab/partner/wing/ui/partner_61" ) :cc.path.join( "prefab/partner/wing/ui/partner_62" );
|
|
let pathbg = ( this.state == ElfinConst.Hatch_Status.Hatch || this.state == ElfinConst.Hatch_Status.Over ) ? "prefab/partner/wing/ui/partner_63" : "prefab/partner/wing/ui/partner_64" ;
|
|
nx.gui.setSpriteFrame( this.nodStatus, "bg", path );
|
|
nx.gui.setSpriteFrame( this, "sbg", pathbg );
|
|
nx.gui.setActive( this, "sbg", true );
|
|
nx.gui.setColor( this.nodStatus, "txt", clr );
|
|
nx.gui.setString( this.nodStatus, "txt", this.info.state == 0 ? nx.text.getKey( "ScientficFree" ) : nx.text.getKey( "ScientficState" + this.state ) );
|
|
|
|
|
|
}else{
|
|
nx.gui.setActive( this.nodLock, "tipSp", this.info.is_open == 2 );
|
|
nx.gui.setString( this.nodStatus, "txt", nx.text.getKey( "ScientficState" + this.state ) );
|
|
nx.gui.setActive( this, "sbg", false );
|
|
|
|
}
|
|
nx.gui.setActive( this.nodStatus, "", this.state != 0 );
|
|
|
|
},
|
|
|
|
setIcon: function (){
|
|
|
|
let id = this.info.do_id ;
|
|
let cfg = game.configs.sprite_data.data_const;
|
|
let cj = cfg.liaoji_materials.val[0];
|
|
let mj = cfg.liaoji_target.val[0];
|
|
let path = "";
|
|
|
|
if( id > 0 ){
|
|
|
|
if( id == cj ){
|
|
path = "prefab/partner/wing/ui/partner_69";
|
|
}else if( id == mj ){
|
|
path = "prefab/partner/wing/ui/partner_70";
|
|
}else{
|
|
path = "prefab/partner/wing/ui/partner_68";
|
|
}
|
|
|
|
nx.gui.setSpriteFrame( this.icon, "", path );
|
|
nx.gui.setActive( this, "add", false );
|
|
}else{
|
|
nx.gui.setSpriteFrame( this.icon, "", "" );
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
getInfo: function () {
|
|
return this.info;
|
|
},
|
|
|
|
onTouch: function() {
|
|
|
|
|
|
}
|
|
|
|
});
|