Files

204 lines
6.1 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '024495FxaZIZrUWZYb2CzNE', 'cmp.act.partnertrial.pv');
// Scripts/mod/acts/partnertrial/cmp/cmp.act.partnertrial.pv.js
"use strict";
/******************************************************************
*
* 星界初體驗
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var NxSpine = require("nx.fx.spine");
var PathTool = require("pathtool");
var 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 onLoad() {
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: function 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: function onPreClosed() {},
touchStepNext: function touchStepNext() {
var _this = this;
if (!this.is_allow_next) return;
this.is_allow_next = false;
var 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;
var rolePath = PathTool.getSpinePath(this.data_info.pv_res, "show", false);
this.roleSp.load(rolePath, function (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(function () {
_this.setSkillInfo();
_this.setPlaySkill();
});
} else {
this.mod.send31006();
this.close();
return;
}
this.step_num++;
this.clockNext();
},
clockNext: function 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: function playPvAction(_cb) {
var _this2 = this;
if (this.is_show) {
this.bookSp.action("action3", false, function (_key, _name) {
if (_key == "complete") {
_this2.bookSp.action("action", false, function (_key, _name) {
if (_key == "complete") {
_this2.bookSp.action("action2", true);
if (_cb) {
_cb();
}
}
});
}
});
} else {
this.is_show = true;
this.bookSp.action("action", false, function (_key, _name) {
if (_key == "complete") {
_this2.bookSp.action("action2", true);
if (_cb) {
_cb();
}
}
});
}
},
setDetail: function setDetail() {
nx.gui.setActive(this.infoNd, "book/info", true);
var info = nx.gui.find(this.infoNd, "book/info");
var key = "story" + this.bid;
var text = nx.text.getKey(key);
var 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: function setPlaySkill() {
var _this3 = this;
var 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"));
var skillPath = PathTool.getSpinePath(this.data_info.spine_id, "action", false);
this.pvSp.load(skillPath, function (e) {
_this3.is_pv_done = true;
if (e) {
_this3.pvSp.stop();
} else {
_this3.skill_num++;
var bar = nx.gui.getComponent(load, "bar", cc.ProgressBar);
bar.progress = 1;
_this3.pvSp.action(_this3.data_info.action1, true);
}
});
var delay = 3;
this.schedule(function () {
if (delay > 0) {
delay--;
}
var 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: function setSkillInfo() {
nx.gui.setActive(this.infoNd, "book/skillshow", true);
var skillInfo = nx.gui.find(this.infoNd, "book/skillshow");
var text = this.data_info.desc[this.skill_num];
nx.gui.setString(skillInfo, "skillname", text[0]);
nx.gui.setString(skillInfo, "desc", text[1]);
}
});
cc._RF.pop();