163 lines
5.3 KiB
JavaScript
163 lines
5.3 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* PVP单项入口
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeComponent = require( "bridge.component" );
|
|
const ItemLayout = require( "cmp.item.layout" );
|
|
const PVPMod = require( "pvp.mod" );
|
|
const BattleController = require("battle_controller");
|
|
const BattleConst = require( "battle_const" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeComponent,
|
|
|
|
properties: {
|
|
|
|
tagId: { default: 0 },
|
|
nodLock: { default: null, type: cc.Node },
|
|
nodDesc: { default: null, type: cc.Node },
|
|
nodBg: { default: null, type: cc.Node },
|
|
nodTitle: { default: null, type: cc.Node },
|
|
lstRewards: { default: null, type: ItemLayout },
|
|
},
|
|
|
|
// 展示
|
|
onEnable: function() {
|
|
|
|
// 刷新
|
|
this.fresh();
|
|
|
|
},
|
|
|
|
setTagId: function( _id ){
|
|
|
|
this.tagId = _id;
|
|
|
|
},
|
|
|
|
// 刷新
|
|
fresh: function() {
|
|
|
|
// 配置无效
|
|
let cfgs = PVPMod.getInstance().queryCGData( this.tagId );
|
|
|
|
let nodSp = nx.gui.getComponent( this.nodBg, "", cc.Sprite );
|
|
let nodTp = nx.gui.getComponent( this.nodTitle, "", cc.Sprite );
|
|
|
|
|
|
|
|
let material = cc.Material.getBuiltinMaterial( '2d-gray-sprite' ) ;
|
|
let nmaterial = cc.Material.getBuiltinMaterial( '2d-sprite' ) ;
|
|
|
|
let setGray = function( _nod, _mat ){
|
|
|
|
let nod = _nod;
|
|
let sp = nx.gui.getComponent( nod, "qa", cc.Sprite );
|
|
let isp = nx.gui.getComponent( nod, "icon", cc.Sprite );
|
|
let ssp = nx.gui.getComponent( nod, "star", cc.Sprite );
|
|
let rt = nx.gui.getComponent( nod, "rt/img", cc.Sprite );
|
|
let material = _mat == 1 ? cc.Material.getBuiltinMaterial( '2d-gray-sprite' ) : cc.Material.getBuiltinMaterial( '2d-sprite' ) ;
|
|
|
|
sp.setMaterial( 0,material );
|
|
isp.setMaterial( 0,material );
|
|
ssp.setMaterial( 0,material );
|
|
rt.setMaterial( 0,material );
|
|
|
|
}
|
|
|
|
if( nx.dt.objEmpty( cfgs ) ) {
|
|
this.lockInfo = { key: "unknown", desc: nx.text.getKey( "Locked" ) };
|
|
this.nodDesc.active = false;
|
|
nodSp.setMaterial( 0, material );
|
|
nodTp.setMaterial( 0, material );
|
|
|
|
for (let i = 0; i < this.lstRewards.node.children.length; i++) {
|
|
let nod = this.lstRewards.node.children[i];
|
|
|
|
setGray( nod, 1 );
|
|
}
|
|
// this.nodLock.active = true;
|
|
// nx.gui.setString( this.nodLock, "limit", nx.text.getKey( "Locked" ) );
|
|
return;
|
|
}
|
|
|
|
let lev = cfgs.open_limit[1] ? cfgs.open_limit[1][1] : cfgs.open_limit[0][1];
|
|
let txt = cc.js.formatStr( nx.text.getKey("lab_stone_dungeon_open_level_haveval"), lev );
|
|
|
|
let path = "prefab/pvp/ui/" + cfgs.res_id;
|
|
nx.gui.setSpriteFrame( this.nodBg, "", path );
|
|
// let title = "prefab/pvp/ui/" + cfgs.res_id;
|
|
nx.gui.setSpriteFrame( this.nodBg, "", path );
|
|
|
|
|
|
this.lstRewards.rebuild( cfgs.award );
|
|
|
|
|
|
|
|
// 是否解锁
|
|
this.lockInfo = nx.bridge.checkConditions( cfgs.open_limit );
|
|
|
|
if( nx.dt.objNEmpty( this.lockInfo ) ) {
|
|
this.nodDesc.active = false;
|
|
nodSp.setMaterial( 0, material );
|
|
nodTp.setMaterial( 0, material );
|
|
|
|
// nx.gui.setString( this, "locker/txt", txt );
|
|
for (let i = 0; i < this.lstRewards.node.children.length; i++) {
|
|
let nod = this.lstRewards.node.children[i];
|
|
|
|
setGray( nod, 1 );
|
|
}
|
|
// this.nodLock.active = true;
|
|
// nx.gui.setString( this.nodLock, "limit", this.lockInfo.desc );
|
|
return;
|
|
}
|
|
|
|
for (let i = 0; i < this.lstRewards.node.children.length; i++) {
|
|
let nod = this.lstRewards.node.children[i];
|
|
|
|
setGray( nod, 0 );
|
|
}
|
|
|
|
nodSp.setMaterial( 0, nmaterial );
|
|
nodTp.setMaterial( 0, nmaterial );
|
|
|
|
// 正常状态
|
|
// this.nodLock.active = false;
|
|
this.nodDesc.active = true;
|
|
|
|
|
|
// 时间刷新
|
|
nx.gui.setString( this.nodDesc, "tnod/time", nx.text.getKey( cfgs.desc ) );
|
|
nx.gui.setActive( this.nodDesc, "tnod/doing", false );
|
|
|
|
},
|
|
|
|
// 点击
|
|
onTouch: function() {
|
|
|
|
// 未解锁
|
|
if( nx.dt.objNEmpty( this.lockInfo ) ) {
|
|
if( nx.dt.strNEmpty( this.lockInfo.desc ) ) {
|
|
nx.tbox( this.lockInfo.desc );
|
|
}
|
|
return;
|
|
}
|
|
|
|
switch( this.tagId ){
|
|
case 1009 :{BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.Arena);} break;
|
|
case 1004 :{ BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.CrossChampion);} break;
|
|
case 1001 :{ BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.LadderWar );} break;
|
|
case 1010 :{ BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.newYearBoss );} break;
|
|
case 1002 :{ BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.EliteMatchWar );} break;
|
|
default: { nx.tbox( "NoImplementation" ); } break;
|
|
}
|
|
|
|
|
|
},
|
|
|
|
} );
|