Files
fc/dev/project/library/imports/55/5515b9d5-2b0e-48f0-8970-0db3a2cf9de1.js
T

158 lines
3.9 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '5515bnVKw5I8IlwDbOiz53h', 'cmp.partner.body.show');
// Scripts/mod/partner/cmps/basic/cmp.partner.body.show.js
"use strict";
/******************************************************************
*
* 伙伴全身立绘动画展示
*
******************************************************************/
var NxSpine = require("nx.fx.spine");
var BridgeComponent = require("bridge.component");
cc.Class({
"extends": BridgeComponent,
properties: {
spRole: {
"default": null,
type: NxSpine
},
nodLoading: {
"default": null,
type: cc.Node
},
nodTouch: {
"default": null,
type: cc.Node
},
nodDialog: {
"default": null,
type: cc.Node
}
},
// 设置伙伴
setPartner: function setPartner(_partner) {
// 置空
var sinfo = _partner ? nx.bridge.partner.getShowInfo(_partner) : null;
if (!sinfo) {
this.setEmpty();
return;
}
this.partner = _partner;
this.setModel(sinfo.sp_show, sinfo.voice, sinfo.phonetic_text);
},
// 设置模型动画, 区别显示了 主场景伙伴与 伙伴背包伙伴详情 点击动画与 展示动画
setModel: function setModel(_spath, _voice, _desc, _from) {
var _this = this;
this.fromOther = _from;
// 重复
if (this.modelPath == _spath) {
return;
}
this.setEmpty();
// 更新
this.modelPath = _spath;
this.voicePath = _voice;
this.desc = nx.dt.objEmpty(this.desc) ? _desc : this.desc;
if (nx.dt.strEmpty(this.modelPath)) {
return;
}
// 模型展示
this.spRole.load(this.modelPath, function (_e) {
if (!_e) {
_this.nodLoading.active = false;
_this.nodTouch.active = true;
_this.spRole.action(_from ? "drama1" : "action1", true);
_this.spRole.node.active = true;
} else {
_this.spRole.node.active = false;
}
});
if (this.nodDialog) {
nx.gui.setString(this.nodDialog, "txt", this.desc);
}
},
// 置空
setEmpty: function setEmpty() {
this.modelPath = "";
this.spRole.stop();
this.spRole.node.active = false;
this.nodLoading.active = false;
this.nodTouch.active = false;
if (this.nodDialog && this.tween) {
this.nodDialog.scale = 0;
this.tween.stop();
nx.gui.setActive(this.nodDialog, "", false);
}
},
// 点击动画
onTouchSpine: function onTouchSpine() {
var _this2 = this;
// 加载中
if (this.nodLoading.active) {
return;
}
if (this.fromOther) {
if (this.spRole.spAction != "drama1") {
return;
}
} else {
// 屏蔽频繁点击打断
if (this.spRole.spAction != "action1") {
return;
}
}
// 播放 -> 常态
this.spRole.action(this.fromOther ? "drama3" : "action2", false, function (_event) {
// 播放语音
if (_event == "start") {
_this2.playVoice();
}
if (_event == "complete") {
_this2.spRole.action(_this2.fromOther ? "drama1" : "action1", true);
}
});
// this.unscheduleAllCallbacks();
if (this.nodDialog) {
nx.gui.setActive(this.nodDialog, "", nx.dt.strNEmpty(this.desc));
this.tween = cc.tween(this.nodDialog).to(0.2, {
scale: 1
}).to(3, {
scale: 1
}).to(0.2, {
scale: 0
}).to(0, function () {
nx.gui.setActive(_this2.nodDialog, "", false);
}).start();
// this.scheduleOnce( ()=>{
// nx.gui.setActive( this.nodDialog, "", false );
// },3 );
}
},
// 播放语音
playVoice: function playVoice() {
var _this3 = this;
if (nx.dt.strEmpty(this.voicePath)) {
return;
}
if (this.voiceHandle) {
nx.audio.stopSFX(this.voiceHandle);
this.voiceHandle = null;
}
nx.audio.playVoice(this.voicePath, function (_err, _id) {
if (!_err) {
_this3.voiceHandle = _id;
}
});
}
});
cc._RF.pop();