Files
fc/dev/project/library/imports/b9/b9a6f882-fbcd-45c3-825d-b4d83e3f90bd.js
2026-05-24 10:21:26 +08:00

223 lines
5.9 KiB
JavaScript

"use strict";
cc._RF.push(module, 'b9a6fiC+81Fw4JdtNg+P5C9', 'wnd.worldmap');
// Scripts/mod/pve/worldmap/wnd.worldmap.js
"use strict";
/******************************************************************
*
* 世界地图
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var FxSVC = require("nx.fx.sv.expand");
var Drama = require("battle_drama_controller");
var LevelInfo = require("cmp.worldmap.level");
var LevelDetails = require("cmp.worldmap.level.details");
cc.Class({
"extends": BridgeWindow,
properties: {
lstChapters: {
"default": null,
type: FxSVC
},
lstPlots: {
"default": null,
type: cc.ScrollView
},
levelInfos: {
"default": null,
type: LevelInfo
},
levelDetails: {
"default": null,
type: LevelDetails
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
// 相关参数
this.clevel = null;
this.current = null;
this.chapters = [];
this.data = Drama.getInstance().getModel().getDramaData();
this.rebuildChapters();
this.lstChapters.rebuild(this.chapters);
var index = 0;
for (var i = 0; i < this.chapters.length; ++i) {
var cha = this.chapters[i];
if (cha && cha.chapter_id == this.data.chapter_id) {
index = i;
break;
}
}
var self = this;
this.scheduleOnce(function () {
var length = _this.chapters.length;
var max = _this.lstChapters.bindSCV.getMaxScrollOffset().y;
var ofsy = index / length * (max + _this.lstChapters.node.height);
_this.lstChapters.bindSCV.scrollToOffset(cc.v2(0, ofsy), 0.1);
_this.lstChapters.freshRange(0, true);
_this.scheduleOnce(function () {
self.onSelectChapter({
index: index,
mdata: self.chapters[index]
});
}, 0.1);
}, 0.01);
},
// 章节切换
onSelectChapter: function onSelectChapter(_item) {
// 無效
if (!_item.mdata || this.lstChapters.isFocus(_item.index)) {
return;
}
// 未解锁
if (_item.mdata.locked) {
nx.tbox("章节未解锁");
return;
}
// 聚焦
this.lstChapters.cleanFocus();
this.lstChapters.addFocus(_item.index);
// 当前更新
this.currentChapter(_item.mdata.chapter_id);
if (this.current) {
this.freshPlots();
this.freshLevels();
}
},
// 关卡更新
freshLevels: function freshLevels() {
this.levelInfos.setData(this.current.focus);
this.levelDetails.setData(this.current.focus);
},
// 剧情更新
freshPlots: function freshPlots() {
var data = this.current.plots || [];
if (nx.dt.arrEmpty(data)) {
this.lstPlots.node.active = false;
return;
}
this.lstPlots.node.active = true;
var chds = this.lstPlots.content.children;
nx.gui.gocChildren(this.lstPlots.content, "", data.length, chds[0]);
for (var i = 0; i < data.length; ++i) {
var cmp = nx.gui.getComponent(chds[i], "", "cmp.worldmap.plot.item");
cmp.setData(i + 1, data[i]);
}
this.lstPlots.scrollToTop(0.1);
},
// ------------------------------------------------------
// 章节信息相关
// ------------------------------------------------------
// 重构章节列表
rebuildChapters: function rebuildChapters() {
var DDT = game.configs.dungeon_data;
var IFO = DDT.data_drama_world_info[this.data.mode];
var DFO = DDT.data_drama_info[this.data.mode];
this.chapters = [];
for (var id in IFO) {
// 章节信息
var cha = nx.dt.objClone(IFO[id]);
cha.cur = 0;
cha.max = 0;
cha.chapters = [];
cha.plots = [];
cha.locked = this.data.chapter_id < cha.chapter_id;
if (cha.locked) {
this.chapters.push(cha);
continue;
}
// 关卡信息
var subs = DFO[cha.chapter_id];
cha.max = Object.keys(subs).length;
if (this.data.chapter_id == cha.chapter_id) {
cha.cur = this.data.dun_id % 1000 / 10;
} else {
cha.cur = cha.max;
}
this.chapters.push(cha);
}
},
// 聚焦某章节
currentChapter: function currentChapter(_chapter_id) {
this.current = null;
var cha = null;
for (var i in this.chapters) {
var ct = this.chapters[i];
if (ct && ct.chapter_id == _chapter_id) {
cha = ct;
break;
}
}
// 无效
if (!cha) {
nx.error("$WorldMap:章节无效!", _chapter_id);
return;
}
// 缓存
if (nx.dt.arrNEmpty(cha.levels)) {
this.current = cha;
return;
}
// 统计关卡信息
cha.levels = [];
var DDT = game.configs.dungeon_data;
var DFO = DDT.data_drama_info[this.data.mode][_chapter_id];
var LVS = DDT.data_drama_dungeon_info;
var level = {
order: 1,
subs: []
};
for (var id in DFO) {
var tmp = DFO[id];
var lv = nx.dt.objClone(LVS[id]);
lv.locked = this.data.dun_id < lv.id;
lv.cur = this.data.dun_id == lv.id;
level.subs.push(lv);
if (tmp.is_big > 0) {
cha.levels.push(nx.dt.objClone(level));
++level.order;
level.subs = [];
}
if (lv.cur) {
cha.focus = lv;
}
}
if (!cha.focus) {
var end = cha.levels[cha.levels.length - 1];
cha.focus = end.subs[end.subs.length - 1];
}
// 统计剧情信息
// 1 是需要引导,2 是不需要引导,0是常驻
var flag = nx.bridge.plot.opened ? 1 : 2;
cha.plots = [];
var POT = DDT.data_drama_story_info[_chapter_id];
if (nx.frame.vget("hMode")) {
POT = DDT.data_drama_story_info_h[_chapter_id];
}
for (var _id in POT) {
var pt = nx.dt.objClone(POT[_id]);
if (pt.show == 0 || pt.show == flag) {
var ret = nx.bridge.checkConditions(['dun', pt.dun]);
pt.locked = nx.dt.objNEmpty(ret);
cha.plots.push(pt);
}
}
this.current = cha;
}
});
cc._RF.pop();