分区砍层插件

This commit is contained in:
ckcz123 2020-06-16 18:24:19 +08:00
parent 9a343dd8af
commit 69b688bdfd
9 changed files with 123 additions and 7 deletions

View File

@ -1748,6 +1748,17 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!type": "number",
"!doc": "窗口宽度的一半为6或7"
},
"floorIds": {
"!type": "[string]",
"!doc": "全部楼层ID列表"
},
"floors": {
"!doc": "全部楼层信息"
},
"floorPartitions": {
"!type": "[[string]]",
"!doc": "楼层分区信息"
},
"material": {
"!doc": "游戏所用到的资源",
"animates": {
@ -3990,6 +4001,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "恢复某一些被删除楼层。<br/>fromId: 开始恢复的楼层ID<br/>toId: 恢复到的楼层编号可选不填则视为fromId<br/>例如core.resumeMaps(\"MT1\", \"MT300\") 恢复MT1~MT300之间的全部层<br/>core.resumeMaps(\"MT10\") 只删恢复MT10层",
"!type": "fn(fromId: string, toId?: string)"
},
"autoRemoveMaps": {
"!doc": "根据楼层分区信息自动砍层与恢复",
"!type": "fn(floorId: string)"
},
"openItemShop": {
"!doc": "打开一个道具商店",
"!type": "fn(itemShopId: string)"

View File

@ -387,6 +387,42 @@ var code = '{"title": "'+EvalString_0+'", "name": "'+EvalString_1+'", "hard": '+
return code;
*/;
floorPartition_m
: '高层塔分区管理' BGNL? floorPartitionList+ BEND
/* floorPartition_m
tooltip : 高层塔分区管理
helpUrl : /_docs/#/instruction
var code = '[\n'+floorPartitionList_0+']\n';
return code;
*/;
floorPartitionList
: floorPartitionItem
| floorPartitionEmpty;
floorPartitionEmpty
: Newline
/* floorPartitionEmpty
var code = ' \n';
return code;
*/;
floorPartitionItem
: '分区项' '起始楼层ID' IdString '终止楼层ID不填代表到最后一层' IdString? BEND
/* floorPartitionItem
tooltip : 难度分歧项
helpUrl : /_docs/#/instruction
default : ['MTx','']
IdString_1 = IdString_1 ? (', "'+IdString_1+'"') : '';
var code = '["'+IdString_0+'"'+IdString_1+'],\n';
return code;
*/;
// equip 事件编辑器入口之一
equip_m
: '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ BEND

View File

@ -58,6 +58,14 @@ ActionParser.prototype.parse = function (obj,type) {
}
return MotaActionBlocks['levelChoose_m'].xmlText([text_choices]);
case 'floorPartition':
if(!obj) obj=[];
var text_choices = null;
for(var ii=obj.length-1,choice;choice=obj[ii];ii--) {
text_choices=MotaActionBlocks['floorPartitionItem'].xmlText([obj[0], obj[1]||"", text_choices]);
}
return MotaActionBlocks['floorPartition_m'].xmlText([text_choices]);
case 'equip':
if(!obj) obj={};
var buildEquip = function (obj) {

View File

@ -65,6 +65,9 @@ editor_blocklyconfig=(function(){
MotaActionBlocks['firstArrive_m'].xmlText(),
MotaActionBlocks['eachArrive_m'].xmlText(),
MotaActionBlocks['level_m'].xmlText(),
MotaActionFunctions.actionParser.parse([
['MTx', '']
], 'floorPartition'),
MotaActionBlocks['commonEvent_m'].xmlText(),
MotaActionBlocks['item_m'].xmlText(),
MotaActionFunctions.actionParser.parse([

View File

@ -18,6 +18,13 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_docs": "楼层列表",
"_data": "在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器、浏览地图和上/下楼器的顺序"
},
"floorPartitions": {
"_leaf": true,
"_type": "event",
"_event": "floorPartition",
"_docs": "分区指定",
"_data": "可以在这里指定楼层分区;主要适用于不可返回的高层塔;进入新分区后将自动调用砍层插件以减少空间消耗;未在任何分区的楼层将被视为公共区域"
},
"images": {
"_leaf": true,
"_type": "material",

View File

@ -236,7 +236,7 @@ main.prototype.init = function (mode, callback) {
main.loadFloors(function() {
var coreData = {};
["dom", "statusBar", "canvas", "images", "tilesets", "materials",
"animates", "bgms", "sounds", "floorIds", "floors"].forEach(function (t) {
"animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) {
coreData[t] = main[t];
})
main.core.init(coreData, callback);

View File

@ -8,6 +8,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"sample3",
"MT0"
],
"floorPartitions": [],
"images": [
"bg.jpg",
"winskin.png",
@ -79,8 +80,18 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"statusLeftBackground": "url(project/materials/ground.png) repeat",
"statusTopBackground": "url(project/materials/ground.png) repeat",
"toolsBackground": "url(project/materials/ground.png) repeat",
"borderColor": [204,204,204,1],
"statusBarColor": [255,255,255,1],
"borderColor": [
204,
204,
204,
1
],
"statusBarColor": [
255,
255,
255,
1
],
"floorChangingStyle": "background-color: black; color: white",
"font": "Verdana"
}

View File

@ -110,6 +110,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// core.deleteAllCanvas();
// }
// 根据分区信息自动砍层与恢复
if (core.autoRemoveMaps) core.autoRemoveMaps(floorId);
// 重置画布尺寸
core.maps.resizeMap(floorId);
// 设置勇士的位置

View File

@ -252,10 +252,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId);
if (toIndex < 0) toIndex = core.floorIds.length - 1;
flags.__visited__ = flags.__visited__ || {};
flags.__removed__ = flags.__removed__ || [];
flags.__disabled__ = flags.__disabled__ || [];
flags.__disabled__ = flags.__disabled__ || {};
for (var i = fromIndex; i <= toIndex; ++i) {
var floorId = core.floorIds[i];
if (core.status.maps[floorId].deleted) continue;
delete flags.__visited__[floorId];
flags.__removed__.push(floorId);
delete flags.__disabled__[floorId];
@ -276,12 +278,43 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
flags.__removed__ = flags.__removed__ || [];
for (var i = fromIndex; i <= toIndex; ++i) {
var floorId = core.floorIds[i];
if (!core.status.maps[floorId].deleted) continue;
flags.__removed__ = flags.__removed__.filter(function (f) { return f != floorId; });
if (core.status.maps[floorId].deleted) {
core.status.maps[floorId] = core.loadFloor(floorId);
}
core.status.maps[floorId] = core.loadFloor(floorId);
}
}
// 分区砍层相关
var inAnyPartition = function (floorId) {
var inPartition = false;
(core.floorPartitions || []).forEach(function (floor) {
var fromIndex = core.floorIds.indexOf(floor[0]);
var toIndex = core.floorIds.indexOf(floor[1]);
var index = core.floorIds.indexOf(floorId);
if (fromIndex < 0 || index < 0) return;
if (toIndex < 0) toIndex = core.floorIds.length - 1;
if (index >= fromIndex && index <= toIndex) inPartition = true;
});
return inPartition;
}
// 分区砍层
this.autoRemoveMaps = function (floorId) {
if (main.mode != 'play' || !inAnyPartition(floorId)) return;
// 根据分区信息自动砍层与恢复
(core.floorPartitions || []).forEach(function (floor) {
var fromIndex = core.floorIds.indexOf(floor[0]);
var toIndex = core.floorIds.indexOf(floor[1]);
var index = core.floorIds.indexOf(floorId);
if (fromIndex < 0 || index < 0) return;
if (toIndex < 0) toIndex = core.floorIds.length - 1;
if (index >= fromIndex && index <= toIndex) {
core.resumeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
} else {
core.removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
}
});
}
},
"fiveLayers": function () {
// 是否启用五图层增加背景2层和前景2层 将__enableFiveLayers置为true即会启用启用后请保存后刷新编辑器