Files

354 lines
9.2 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '1de9cbcvl1E36uC0rgaL5nG', 'pop.rewards.wnd');
// Scripts/mod/tips/popup/pop.rewards.wnd.js
"use strict";
/******************************************************************
*
* 奖励弹窗
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var FxSpine = require("nx.fx.spine");
var BackpackController = require("backpack_controller");
var BackPackConst = require("backpack_const");
var BBC = BackPackConst.Bag_Code;
var DELAY_CLOSE = 3;
cc.Class({
"extends": BridgeWindow,
properties: {
spAnim: {
"default": null,
type: FxSpine
},
nodRewards: {
"default": null,
type: cc.Node
},
nodOps: {
"default": null,
type: cc.Node
},
nodTouch: {
"default": null,
type: cc.Node
}
},
// 关闭
onDisable: function onDisable() {
this.unscheduleAllCallbacks();
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
this.params = _params ? _params.params : null;
this.initLst = _params.list;
// 道具拆解
this.items = [];
_params.list.forEach(function (_t) {
_this.items.push([_t.bid, _t.num || 1]);
});
// 判空
if (nx.dt.arrEmpty(this.items)) {
this.close();
nx.error("[REWARD]无效的道具表!");
return;
}
var cmp = null;
var mul = this.items.length > 6;
if (mul) {
nx.gui.setActive(this.nodRewards, "ml", true);
nx.gui.setActive(this.nodRewards, "sl", false);
cmp = nx.gui.getComponent(this.nodRewards, "ml", "nx.fx.sv.expand");
} else {
nx.gui.setActive(this.nodRewards, "ml", false);
nx.gui.setActive(this.nodRewards, "sl", true);
cmp = nx.gui.getComponent(this.nodRewards, "sl", "cmp.item.layout");
}
// 道具刷新
cmp.rebuild(this.items);
this.nodRewards.active = false;
// 节点统计
this.glowers = [];
if (mul) {
var root = cmp.bindSCV.content;
for (var i in root.children) {
var node = root.children[i];
if (node && node.children[0]) {
node.children[0].opacity = 0;
this.glowers.push(node.children[0]);
}
}
} else {
var _root = cmp.node;
for (var _i in _root.children) {
var _node2 = _root.children[_i];
if (_node2) {
_node2.opacity = 0;
this.glowers.push(_node2);
}
}
}
// 动画流程
this.doAnimation();
// 音效
nx.audio.playSFX("audios/effects/item", false);
},
// 动画流程
doAnimation: function doAnimation() {
var _this2 = this;
// 隐藏操作
this.hideOps();
this.spAnim.action("action", false, function (_key, _name) {
if (_key == "reward") {
_this2.nodRewards.active = true;
var dsec = 0;
var _loop = function _loop() {
var glow = _this2.glowers[i];
if (!glow) return "continue";
nx.tween.delayFadeIn(glow, "", dsec, 0.01, function () {
var comp = glow.getComponent("cmp.item.glow");
if (comp) {
comp.glowShow();
var pfg = gdata("item_data", "data_unit6", comp.mdata[0]);
if (pfg) {
if (pfg.eqm_jie == 5) {
nx.gui.setActive(glow, "icon/focus", true);
}
}
}
});
dsec += 0.05;
};
for (var i in _this2.glowers) {
var _ret2 = _loop();
if (_ret2 === "continue") continue;
}
// 操作展示
_this2.freshAndDelayShowOps();
return;
}
// 第二阶段
if (_key == "complete") {
_this2.spAnim.action("action2", true);
return;
}
}, 2.0);
},
// ==================================================
// 不同的操作栏处理
// ==================================================
// 隐藏操作
hideOps: function hideOps() {
this.nodOps.active = false;
this.nodTouch.active = false;
},
// 操作展示
freshAndDelayShowOps: function freshAndDelayShowOps() {
var _this3 = this;
// 辨别展示节点
this.optype = false;
if (nx.dt.objNEmpty(this.params)) {
this.nodOps.children.forEach(function (_node) {
_node.active = _node.name == _this3.params.op;
});
this.optype = true;
switch (this.params.op) {
// 召唤面板
case "summon":
{
this.freshSummonOps(this.params);
}
break;
// 无限十连抽
case "infinite":
{
this.freshInfiniteOps(this.params);
}
break;
// 戰鬥義肢祈禱
case "pray":
{
this.freshPrayOps(this.params);
}
break;
// 无法识别
default:
{
this.optype = false;
// nx.error( "无效道具展示操作类型:", this.params.op );
}
break;
}
}
// 延迟关闭
var node = this.optype ? this.nodOps : this.nodTouch;
this.scheduleOnce(function () {
node.active = true;
nx.tween.fadeIn(node, "", 0.5);
_this3.checkAutoClose();
}, 0.5);
},
// 自动关闭
checkAutoClose: function checkAutoClose() {
var params = this.params ? this.params.delay : null;
if (nx.dt.objEmpty(params)) {
return;
}
var self = this;
var secs = params.secs || DELAY_CLOSE;
var tick = function tick() {
if (secs < 0) {
self.onTouchClose();
return;
}
var txt = nx.text.format("TouchBlankCloseAuto", secs);
nx.gui.setString(self.nodTouch, "txt", txt);
--secs;
};
this.unscheduleAllCallbacks();
this.schedule(tick, 1, DELAY_CLOSE);
tick();
},
// 点击关闭
onTouchClose: function onTouchClose() {
this.unscheduleAllCallbacks();
if (this.params && this.params.delay) {
nx.dt.fnInvoke(this.params.delay.cb);
}
this.close();
this.checkPlot();
},
// 召唤相关
// 刷新召唤面板
/**
* 参数结构
* op: "summon",
* bid: 所需道具编号
* need: 所需道具数量
* txt: 按钮文本
* cb: 点击回调
*/
freshSummonOps: function freshSummonOps(_args) {
var node = nx.gui.find(this.nodOps, "summon/draw");
if (node) {
var cfg = gitemdata(_args.bid);
nx.bridge.setIcon(node, "need/list/icon", cfg ? cfg.icon : 0);
nx.gui.setString(node, "need/list/num", _args.need);
nx.gui.setString(node, "btn/txt", nx.text.getKey(_args.txt));
}
},
// 点击召唤取消
onTouchSummonCancel: function onTouchSummonCancel() {
nx.dt.fnInvoke(this.params.cb, false);
},
// 点击召唤
onTouchSummonConfirm: function onTouchSummonConfirm() {
nx.dt.fnInvoke(this.params.cb, true);
},
// 刷新无限十连抽
/**
* 参数结构
* op: "infinite",
* cb: 点击回调(0:再抽 1:满意)
*/
freshInfiniteOps: function freshInfiniteOps(_args) {},
// 点击不满意
onTouchInfiniteAgain: function onTouchInfiniteAgain() {
nx.dt.fnInvoke(this.params.cb, false);
},
// 点击满意
onTouchInfiniteOK: function onTouchInfiniteOK() {
nx.dt.fnInvoke(this.params.cb, true);
},
// 刷新戰鬥 祈禱
/**
* 参数结构
* op: "pray",
* cb: 点击回调(0:再抽 1:满意)
*/
freshPrayOps: function freshPrayOps(_args) {
var options = _args.options;
this.sells = [];
for (var i in this.glowers) {
var glow = this.glowers[i];
if (!glow) continue;
var comp = glow.getComponent("cmp.item.glow");
if (comp) {
var pfg = gdata("item_data", "data_unit3", comp.mdata[0]);
var cfg = game.configs.item_data.data_unit3[comp.mdata[0]];
var id = this.initLst[i].id;
if (cfg) {
for (var j = 0; j < options.length; j++) {
var op = options[j];
if (op && op.flag == 1 && j + 1 == pfg.eqm_star) {
nx.gui.setActive(glow, "icon/swap", true);
this.sells.push({
id: id,
bid: pfg.id,
num: comp.mdata[1]
});
}
}
}
}
}
this.optype = nx.dt.arrEmpty(this.sells) ? false : true;
// let node = optype ? this.nodOps : this.nodTouch;
// node.active = true;
// this.checkAutoClose();
// "options":[{"flag":0},{"flag":1},{"flag":1},{"flag":1},{"flag":0}]
},
// 点击满意
onTouchPrayOK: function onTouchPrayOK() {
BackpackController.getInstance().sender10522(BBC.EQUIPS, this.sells);
this.close();
},
// ==================================================
// 引导相关
// ==================================================
// 道具引导
checkPlot: function checkPlot() {
// 引导未开启
if (!nx.bridge.plot) {
return;
}
// 进行中
var cur = nx.bridge.plot.vget("id");
if (nx.dt.strNEmpty(cur)) {
return;
}
var queue = nx.dt.objClone(nx.bridge.plot.configs.base.reward);
var check = function check() {
if (nx.dt.arrEmpty(queue)) {
return;
}
nx.bridge.plot.fire(queue.shift(), function (_ret, _data) {
if (!_ret) {
check();
}
});
};
check();
}
});
cc._RF.pop();