Files
fc/dev/project/library/imports/05/059daee7-8700-4006-bd01-96a5f6723348.js
T

253 lines
8.4 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '059da7nhwBABr0BlqX2cjNI', 'cmp.battledrama.reward');
// Scripts/mod/battle_drama/cmp/cmp.battledrama.reward.js
"use strict";
var BridgeWindow = require("bridge.window");
var FxSVC = require("nx.fx.sv.expand");
var BattleDramaController = require("battle_drama_controller");
var DramaEvent = require("battle_drama_event");
var NxSpine = require("nx.fx.spine");
var PathTool = require("pathtool");
cc.Class({
"extends": BridgeWindow,
properties: {
SVClist: {
"default": null,
type: FxSVC
},
pass_dungeon_name: {
"default": null,
type: cc.Label
},
role: {
"default": null,
type: NxSpine
},
sepGetIcon: {
"default": null,
type: cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.controller = BattleDramaController.getInstance();
this.model = this.controller.getModel();
this.config_list = {};
// this.summon_special_data = {};
this.bindGEvent(DramaEvent.BattleDrama_Drama_Reward_Data, this.updateShowInfoList.bind(this));
},
onEnable: function onEnable() {},
start: function start() {},
onOpenConfigs: function onOpenConfigs() {
this.updateShowInfoList();
},
onPreClosed: function onPreClosed() {
this.SVClist.rebuild([]);
},
// 更新显示
updateShowInfoList: function updateShowInfoList(id, type) {
if (id == null) {
this.initConfigRewardList();
} else {
if (nx.dt.arrEmpty(id.list)) {
if (type == 0) {
var object = this.config_list[id];
if (object) {
object.is_received = true; // 已领取
object.sort_index = 3; // 已领取排序id
}
}
} else {
for (var i = 0; i < id.list.length; i++) {
var info = id.list[i];
var _object = this.config_list[info.id];
if (_object) {
_object.is_received = true; // 已领取
_object.sort_index = 3; // 已领取排序id
}
}
}
//特殊奖励
// if( type == 1 ) {
// var object = this.config_list[ id ];
// object.is_spe_received = true;
// object.spe_sort_index = 3;
// this.summon_special_data.sort_index = 3;
// }
}
if (this.rewards_list) {
this.rewards_list.sort(Utils.tableLowerSorter(["sort_index", "sort"]));
this.SVClist.rebuild(this.rewards_list);
// 引导辅助
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
this.positionGet();
}
}
},
// 初始化奖励列表
initConfigRewardList: function initConfigRewardList() {
var _this = this;
if (this.rewards_list) return;
this.rewards_list = [];
var floor = 0;
var pass_list = this.model.getDramaRewardPassList(); // 已通关列表
var spe_pass_list = this.model.getDramaSpeRewardPassList(); // 特殊通关奖励
var drama_data = this.model.getDramaData(); // 当前剧情副本数据
if (nx.dt.objEmpty(drama_data)) {
return false;
}
//spine动画,显示大奖励
var res_path = PathTool.getSpinePath("H30095", "show", false);
this.role.load(res_path, function (_e) {
if (!_e) {
_this.role.action("drama1", true);
} else {
_this.role.stop();
}
});
//已经通过显示
if (drama_data.max_dun_id == null || drama_data.max_dun_id == 0) {
this.pass_dungeon_name.string = "--"; // 名字
} else {
var per_drama_dungeon_info = game.configs.dungeon_data.data_drama_dungeon_info[drama_data.max_dun_id];
this.pass_dungeon_name.string = per_drama_dungeon_info.name; // 名字
}
var max_dun_id = drama_data.max_dun_id;
var cur_drama_dungeon_info = game.configs.dungeon_data.data_drama_dungeon_info[max_dun_id];
if (cur_drama_dungeon_info) {
floor = cur_drama_dungeon_info.floor || 0; // 当前层,用于比较的
}
//特殊关卡1-4010400,id是8,策划说写死
var bShowSepGet = false;
// 遍历出整个列表
for (var key in game.configs.dungeon_data.data_drama_reward) {
var config = game.configs.dungeon_data.data_drama_reward[key];
if (config) {
var target_config = game.configs.dungeon_data.data_drama_dungeon_info[config.limit_id];
if (target_config) {
var is_spe_received = spe_pass_list[config.id];
var object = {
config_data: config,
id: config.id,
is_received: pass_list[config.id] || false,
is_spe_received: is_spe_received,
cur_dunname: target_config.name,
cur_dun: floor,
sort_index: 0,
sort: config.sort,
spe_sort_index: 0,
target_dun: target_config.floor
};
this.rewards_list.push(object);
if (max_dun_id >= config.limit_id) {
if (object.is_received) {
object.sort_index = 3; // 已领取
if (object.id == 8) {
bShowSepGet = true;
}
} else {
object.sort_index = 1; // 可领取
}
if (object.is_spe_received) {
object.spe_sort_index = 3;
} else {
object.spe_sort_index = 1;
}
} else {
object.sort_index = 2; // 条件不满足
object.spe_sort_index = 2;
}
// 储存一下
this.config_list[config.id] = object;
}
}
//是否添加通关特殊奖励
// if( config.special_items.length != 0 ) {
// this.summon_special_data.id = config.id;
// this.summon_special_data.sort_index = this.config_list[ config.id ].spe_sort_index;
// if( floor < 40 ) {
// this.tips.string = cc.js.formatStr( "(%d/%d)", floor, 40 );
// } else {
// this.tips.string = "(40/40)";
// var RoleController = require( "role_controller" );
// let role_vo = RoleController.getInstance().getRoleVo();
// let claim_p = nx.storage.get( role_vo.srv_id + "_" + role_vo.rid + "chappass" );
// if( claim_p ) {//领取过
// nx.gui.setString(this.reflect_btn,"txt",nx.text.getKey("Got"));
// nx.gui.setLocked(this.reflect_btn.node,"",true);
// } else {//未领取
// nx.gui.setLocked(this.reflect_btn.node,"",false);
// }
// }
// let cmp = nx.gui.getComponent( this.summon_item, "", "nx.fx.sv.expand.item" );
// cmp.rebind( 1, { bid: config.special_items[ 0 ][ 0 ], num: config.special_items[ 0 ][ 1 ] }, "" );
// }
}
nx.gui.setActive(this.sepGetIcon, "", bShowSepGet);
},
// touchReflect() {
// if( this.summon_special_data.sort_index == 1 ) {
// this.controller.send13009( 1, this.summon_special_data.id );
// nx.gui.setString(this.reflect_btn,"txt",nx.text.getKey("Got"));
// nx.gui.setLocked(this.reflect_btn.node,"",true);
// var RoleController = require( "role_controller" );
// let role_vo = RoleController.getInstance().getRoleVo();
// nx.storage.set( role_vo.srv_id + "_" + role_vo.rid + "chappass", 1 );
// }
// },
// ============================================
// 引导辅助
// ============================================
// 首次领奖定位
positionGet: function positionGet() {
// 查找第一个能领取的任务
var node = null;
var children = this.SVClist.bindSCV.content.children;
for (var i = 0; i < children.length; ++i) {
var temp = children[i];
if (temp.svItem && temp.svItem.mdata && temp.svItem.comfirm_btn.active && temp.svItem.mdata.id == 77) {
node = temp;
break;
}
}
if (!node) {
nx.error("$DramaReward:定位首次领奖失败!");
node = children[0];
if (!node) {
return;
}
}
var btn = node.svItem.comfirm_btn;
var cell = nx.gui.find(this, "container/plotCell");
var pos = btn.convertToWorldSpaceAR(cc.Vec2.ZERO);
cell.position = cell.parent.convertToNodeSpaceAR(pos);
cell.width = btn.width;
cell.height = btn.height;
cell.svItem = node.svItem;
},
// 点击首次领奖处理
onTouchFirstGet: function onTouchFirstGet() {
var cell = nx.gui.find(this, "container/plotCell");
if (cell && cell.svItem) {
cell.svItem.touchConfirm();
}
}
});
cc._RF.pop();