213 lines
6.4 KiB
JavaScript
213 lines
6.4 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 星界初體驗
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const BridgeWindow = require("bridge.window");
|
||
|
|
const NxSpine = require("nx.fx.spine");
|
||
|
|
const PathTool = require("pathtool");
|
||
|
|
const HeroTrialMod = require("act.partnertrial.mod");
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
roleSp:{
|
||
|
|
default:null,
|
||
|
|
type:NxSpine
|
||
|
|
},
|
||
|
|
pvSp:{
|
||
|
|
default:null,
|
||
|
|
type:NxSpine
|
||
|
|
},
|
||
|
|
bookSp:{
|
||
|
|
default:null,
|
||
|
|
type:NxSpine
|
||
|
|
},
|
||
|
|
showNd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
infoNd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
|
||
|
|
stepTip:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
onLoad: function( ) {
|
||
|
|
this.mod = HeroTrialMod.getInstance();
|
||
|
|
this.step_num = 0;//步骤计数
|
||
|
|
this.skill_num = 0;//技能展示
|
||
|
|
this.is_allow_next = true;
|
||
|
|
this.is_pv_done = false;
|
||
|
|
this.is_show = false;//卷轴是否展开
|
||
|
|
this.try_data = game.configs.partner_try_data;
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs(params){
|
||
|
|
this.bid = params.bid;
|
||
|
|
if(this.bid == 0){
|
||
|
|
this.bid = this.try_data.data_const.partner_id.val;
|
||
|
|
}
|
||
|
|
this.data_info = this.try_data.data_info[this.bid];
|
||
|
|
// this.skill_num = thisd.data_info.desc.length;
|
||
|
|
this.touchStepNext();
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed(){
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
touchStepNext(){
|
||
|
|
if(!this.is_allow_next)return;
|
||
|
|
this.is_allow_next = false;
|
||
|
|
let load = nx.gui.find(this.infoNd,"book/load");
|
||
|
|
nx.gui.setString(load,"txt","");
|
||
|
|
nx.gui.setActive(this.showNd, "", this.step_num == 0);
|
||
|
|
nx.gui.setActive(this.infoNd, "", this.step_num > 0);
|
||
|
|
nx.gui.setActive(this.infoNd, "book/info", false);
|
||
|
|
nx.gui.setActive(this.infoNd, "book/skillshow", false);
|
||
|
|
|
||
|
|
this.roleSp.stop();
|
||
|
|
if(this.step_num == 0){
|
||
|
|
if(!this.data_info.pv_res)return;
|
||
|
|
let rolePath = PathTool.getSpinePath(this.data_info.pv_res,"show",false);
|
||
|
|
this.roleSp.load(rolePath,(e)=>{
|
||
|
|
if(!e){
|
||
|
|
this.roleSp.action("action1",true);
|
||
|
|
}else{
|
||
|
|
this.roleSp.stop();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}else if(this.step_num == 1){
|
||
|
|
this.playPvAction(this.setDetail.bind(this));
|
||
|
|
}else if(this.step_num >= 2 && this.step_num<5){
|
||
|
|
if(!this.data_info.spine_id)return;
|
||
|
|
this.playPvAction(()=>{
|
||
|
|
this.setSkillInfo();
|
||
|
|
this.setPlaySkill();
|
||
|
|
});
|
||
|
|
}else{
|
||
|
|
this.mod.send31006();
|
||
|
|
this.close();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.step_num++;
|
||
|
|
this.clockNext();
|
||
|
|
},
|
||
|
|
|
||
|
|
clockNext(){
|
||
|
|
// let delay = 4;
|
||
|
|
// this.schedule(()=>{
|
||
|
|
// if(delay > 0){
|
||
|
|
// delay--
|
||
|
|
// }
|
||
|
|
// nx.gui.setString(this.stepTip, "", cc.js.formatStr(nx.text.getKey("TryPartNextStep"),delay));
|
||
|
|
|
||
|
|
// if(delay == 0){
|
||
|
|
// this.is_allow_next = true;
|
||
|
|
// nx.gui.setString(this.stepTip,"",nx.text.getKey("TryPartNext"));
|
||
|
|
// }
|
||
|
|
// },1,delay-1,1);
|
||
|
|
this.is_allow_next = true;
|
||
|
|
nx.gui.setString(this.stepTip,"",nx.text.getKey("TryPartNext"));
|
||
|
|
},
|
||
|
|
|
||
|
|
playPvAction(_cb){
|
||
|
|
if(this.is_show){
|
||
|
|
this.bookSp.action("action3",false,(_key, _name)=>{
|
||
|
|
if(_key == "complete"){
|
||
|
|
this.bookSp.action("action",false,(_key, _name)=>{
|
||
|
|
if(_key == "complete"){
|
||
|
|
this.bookSp.action("action2",true);
|
||
|
|
if(_cb){
|
||
|
|
_cb();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}else{
|
||
|
|
this.is_show = true;
|
||
|
|
this.bookSp.action("action",false,(_key, _name)=>{
|
||
|
|
if(_key == "complete"){
|
||
|
|
this.bookSp.action("action2",true);
|
||
|
|
if(_cb){
|
||
|
|
_cb();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
setDetail(){
|
||
|
|
nx.gui.setActive(this.infoNd, "book/info", true);
|
||
|
|
let info = nx.gui.find(this.infoNd,"book/info");
|
||
|
|
let key = `story${ this.bid }`;
|
||
|
|
let text = nx.text.getKey( key );
|
||
|
|
let arr = text.split( "#" );
|
||
|
|
|
||
|
|
nx.gui.setString(info,"name",arr[0]);
|
||
|
|
nx.gui.setString(info,"canceer/txt",arr[1]);
|
||
|
|
nx.gui.setString(info,"detail/txt",arr[2]);
|
||
|
|
nx.gui.setString(info,"scroll/story",arr[3]);
|
||
|
|
},
|
||
|
|
|
||
|
|
setPlaySkill(){
|
||
|
|
let load = nx.gui.find(this.infoNd,"book/load");
|
||
|
|
if(!this.is_pv_done){
|
||
|
|
load.active = true;
|
||
|
|
nx.gui.setString(load,"txt",nx.text.getKey("load_str1"));
|
||
|
|
let skillPath = PathTool.getSpinePath(this.data_info.spine_id,"action",false);
|
||
|
|
this.pvSp.load(skillPath,(e)=>{
|
||
|
|
this.is_pv_done = true;
|
||
|
|
if(e){
|
||
|
|
this.pvSp.stop();
|
||
|
|
}else{
|
||
|
|
this.skill_num++;
|
||
|
|
let bar = nx.gui.getComponent(load,"bar",cc.ProgressBar);
|
||
|
|
bar.progress = 1;
|
||
|
|
this.pvSp.action(this.data_info.action1,true);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
let delay = 3;
|
||
|
|
this.schedule(()=>{
|
||
|
|
if(delay > 0){
|
||
|
|
delay--
|
||
|
|
}
|
||
|
|
|
||
|
|
let bar = nx.gui.getComponent(load,"bar",cc.ProgressBar);
|
||
|
|
bar.progress += 0.1;
|
||
|
|
if(delay == 0){
|
||
|
|
bar.progress = 1;
|
||
|
|
load.active = false;
|
||
|
|
}
|
||
|
|
},0.1,delay-1,1);
|
||
|
|
}else{
|
||
|
|
if(this.skill_num == 1){
|
||
|
|
this.pvSp.action(this.data_info.action2,true);
|
||
|
|
}else if(this.skill_num == 2){
|
||
|
|
this.pvSp.action(this.data_info.action3,true);
|
||
|
|
}
|
||
|
|
this.skill_num++;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
setSkillInfo(){
|
||
|
|
nx.gui.setActive(this.infoNd, "book/skillshow", true);
|
||
|
|
let skillInfo = nx.gui.find(this.infoNd,"book/skillshow");
|
||
|
|
let text = this.data_info.desc[this.skill_num];
|
||
|
|
nx.gui.setString(skillInfo,"skillname",text[0]);
|
||
|
|
nx.gui.setString(skillInfo,"desc",text[1]);
|
||
|
|
},
|
||
|
|
} );
|