282 lines
7.8 KiB
JavaScript
282 lines
7.8 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '54dbbpfE9tEeqowDWCJ14eJ', 'cmp.wing.procurement.reward.wnd');
|
||
|
|
// Scripts/mod/partner/wings/cmp/cmp.wing.procurement.reward.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 奖励弹窗
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var BackPackConst = require("backpack_const");
|
||
|
|
var FxSpine = require("nx.fx.spine");
|
||
|
|
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
|
||
|
|
},
|
||
|
|
nodDesc: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodName: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodSpecial: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
||
|
|
var _this = this;
|
||
|
|
this.params = _params ? _params.params : null;
|
||
|
|
|
||
|
|
// 道具拆解
|
||
|
|
this.items = [];
|
||
|
|
_params.list.forEach(function (_t) {
|
||
|
|
_this.items.push([_t.base_id, _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.specials = [];
|
||
|
|
this.specialsCopy = [];
|
||
|
|
for (var i = 0; i < this.items.length; i++) {
|
||
|
|
var item = this.items[i];
|
||
|
|
var ifg = gdata("item_data", "data_unit9", item[0]);
|
||
|
|
if (ifg && ifg.quality == BackPackConst.quality.orange) {
|
||
|
|
this.specials.push(item);
|
||
|
|
this.specialsCopy.push(item);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// this.specialsCopy = this.specials;
|
||
|
|
this.nodRewards.active = false;
|
||
|
|
this.nodSpecial.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 _i2 in _root.children) {
|
||
|
|
var _node2 = _root.children[_i2];
|
||
|
|
if (_node2) {
|
||
|
|
_node2.opacity = 0;
|
||
|
|
this.glowers.push(_node2);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.dealShow();
|
||
|
|
|
||
|
|
// // 动画流程
|
||
|
|
// this.doAnimation();
|
||
|
|
},
|
||
|
|
|
||
|
|
dealShow: function dealShow() {
|
||
|
|
var self = this;
|
||
|
|
var deal = function deal(_data) {
|
||
|
|
// [[113008,1]]
|
||
|
|
var sfg = gdata("sprite_data", "data_elfin_data", _data[0][0]);
|
||
|
|
var ifg = gdata("item_data", "data_unit9", _data[0][0]);
|
||
|
|
if (ifg) {
|
||
|
|
var cmp = nx.gui.getComponent(self.nodSpecial, "item", "cmp.item.base");
|
||
|
|
if (cmp) {
|
||
|
|
cmp.setData(_data[0][0]);
|
||
|
|
}
|
||
|
|
nx.gui.setActive(self.nodSpecial, "item", false);
|
||
|
|
nx.bridge.setIcon(self.nodSpecial, "role", ifg.imageid);
|
||
|
|
if (sfg) {
|
||
|
|
var skill = gdata("skill_data4", "data_get_skill", sfg.skill);
|
||
|
|
if (skill) {
|
||
|
|
// console.log( "当前的数据信息ss" + JSON.stringify( sfg ) );
|
||
|
|
nx.gui.setString(self.nodDesc, "name", skill.name);
|
||
|
|
nx.gui.setString(self.nodDesc, "desc/view/content/txt", nx.text.getKey(skill.des));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// console.log( "当前的数据信息" + JSON.stringify( ifg ) );
|
||
|
|
nx.gui.setString(self.nodName, "name", ifg.name);
|
||
|
|
nx.gui.setString(self.nodName, "type", ifg.use_desc);
|
||
|
|
// console.log( JSON.stringify( ifg ) + "当前的奖励" + JSON.stringify( this.items[0] ) );
|
||
|
|
self.scheduleOnce(function () {
|
||
|
|
nx.gui.setActive(self.nodSpecial, "", true);
|
||
|
|
}, 0.2);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// console.log( "当前的特殊显示" + JSON.stringify( this.specials ) );
|
||
|
|
// this.specials = [[113006,1]];
|
||
|
|
|
||
|
|
if (!nx.dt.arrEmpty(this.specials)) {
|
||
|
|
var bid = this.specials.splice(0, 1);
|
||
|
|
deal(bid);
|
||
|
|
} else {
|
||
|
|
this.showRewards();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
showRewards: function showRewards() {
|
||
|
|
nx.gui.setActive(this.nodSpecial, "", false);
|
||
|
|
this.doAnimation();
|
||
|
|
},
|
||
|
|
// 动画流程
|
||
|
|
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();
|
||
|
|
if (nx.dt.arrMember(_this2.specialsCopy, comp.mdata)) {
|
||
|
|
nx.gui.setActive(glow, "icon/focus", true);
|
||
|
|
} else {
|
||
|
|
nx.gui.setActive(glow, "icon/focus", false);
|
||
|
|
}
|
||
|
|
nx.gui.setActive(glow, "icon/star", false);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
dsec += 0.05;
|
||
|
|
};
|
||
|
|
for (var i in _this2.glowers) {
|
||
|
|
var _ret = _loop();
|
||
|
|
if (_ret === "continue") continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 操作展示
|
||
|
|
_this2.freshAndDelayShowOps();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 第二阶段
|
||
|
|
if (_key == "complete") {
|
||
|
|
_this2.spAnim.action("action2", true);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// ==================================================
|
||
|
|
// 不同的操作栏处理
|
||
|
|
// ==================================================
|
||
|
|
|
||
|
|
// 隐藏操作
|
||
|
|
hideOps: function hideOps() {
|
||
|
|
this.nodOps.active = false;
|
||
|
|
this.nodTouch.active = false;
|
||
|
|
},
|
||
|
|
// 操作展示
|
||
|
|
freshAndDelayShowOps: function freshAndDelayShowOps() {
|
||
|
|
var _this3 = this;
|
||
|
|
// 辨别展示节点
|
||
|
|
var optype = false;
|
||
|
|
if (nx.dt.objNEmpty(this.params)) {
|
||
|
|
this.nodOps.children.forEach(function (_node) {
|
||
|
|
_node.active = _node.name == _this3.params.op;
|
||
|
|
});
|
||
|
|
optype = true;
|
||
|
|
switch (this.params.op) {
|
||
|
|
// 召唤面板
|
||
|
|
case "summon":
|
||
|
|
{
|
||
|
|
this.freshSummonOps(this.params);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
|
||
|
|
// 无法识别
|
||
|
|
default:
|
||
|
|
{
|
||
|
|
optype = false;
|
||
|
|
nx.error("无效道具展示操作类型:", this.params.op);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 延迟关闭
|
||
|
|
var node = optype ? this.nodOps : this.nodTouch;
|
||
|
|
this.scheduleOnce(function () {
|
||
|
|
node.active = true;
|
||
|
|
nx.tween.fadeIn(node, "", 0.5);
|
||
|
|
}, 0.5);
|
||
|
|
},
|
||
|
|
// 召唤相关
|
||
|
|
|
||
|
|
// 刷新召唤面板
|
||
|
|
/**
|
||
|
|
* 参数结构
|
||
|
|
* 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);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|