楼梯、传送器

This commit is contained in:
oc 2017-12-05 11:06:52 +08:00
parent dd994e447f
commit f453f09636
5 changed files with 44 additions and 30 deletions

View File

@ -1407,6 +1407,7 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, callback) {
core.lockControl(); core.lockControl();
core.stopHero(); core.stopHero();
core.stopAutomaticRoute(); core.stopAutomaticRoute();
core.clearContinueAutomaticRoute();
core.dom.floorNameLabel.innerHTML = core.status.maps[floorId].title; core.dom.floorNameLabel.innerHTML = core.status.maps[floorId].title;
if (core.isset(stair)) { if (core.isset(stair)) {
// find heroLoc // find heroLoc
@ -1438,7 +1439,8 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, callback) {
core.events.afterChangeFloor(floorId); core.events.afterChangeFloor(floorId);
if (core.isset(callback)) callback(); if (core.isset(callback)) callback();
}); });
core.setHeroLoc('direction', heroLoc.direction); if (core.isset(heroLoc.direction))
core.setHeroLoc('direction', heroLoc.direction);
core.setHeroLoc('x', heroLoc.x); core.setHeroLoc('x', heroLoc.x);
core.setHeroLoc('y', heroLoc.y); core.setHeroLoc('y', heroLoc.y);
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
@ -1591,7 +1593,7 @@ core.prototype.drawMap = function (mapName, callback) {
var blockIcon, blockImage; var blockIcon, blockImage;
core.clearMap('all'); core.clearMap('all');
core.rmGlobalAnimate(null, null, true); core.rmGlobalAnimate(null, null, true);
core.enabledAllTrigger(); // core.enabledAllTrigger();
for (var x = 0; x < 13; x++) { for (var x = 0; x < 13; x++) {
for (var y = 0; y < 13; y++) { for (var y = 0; y < 13; y++) {
blockIcon = core.material.icons.terrains.ground; blockIcon = core.material.icons.terrains.ground;
@ -1766,28 +1768,23 @@ core.prototype.trigger = function (x, y) {
if (noPass) { if (noPass) {
core.clearAutomaticRouteNode(x, y); core.clearAutomaticRouteNode(x, y);
} }
/* if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger)) {
if(core.isset(mapBlocks[b].fg) && core.isset(mapBlocks[b].fg.trigger) && (core.isset(mapBlocks[b].fg.disabledTrigger) ? mapBlocks[b].fg.disabledTrigger == false : true)) { var trigger = mapBlocks[b].event.trigger;
core.material.events[mapBlocks[b].fg.trigger](mapBlocks[b], core, function(data) { // 转换楼层能否穿透
if (trigger=='changeFloor' && (core.status.autoHeroMove || core.status.autoStep<core.status.autoStepRoutes.length)) {
}); var canCross = core.flags.portalWithoutTrigger;
} if (core.isset(mapBlocks[b].event.portalWithoutTrigger))
*/ canCross=mapBlocks[b].event.portalWithoutTrigger;
if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger) && (core.isset(mapBlocks[b].event.disabledTrigger) ? mapBlocks[b].event.disabledTrigger == false : true) if (canCross) continue;
&& !(core.isset(mapBlocks[b].event.noTriggerCross) && mapBlocks[b].event.noTriggerCross && (core.status.autoHeroMove || core.status.autoStep<core.status.autoStepRoutes.length))) { }
core.material.events[mapBlocks[b].event.trigger](mapBlocks[b], core, function (data) { core.material.events[trigger](mapBlocks[b], core, function (data) {
});
}
else if (core.isset(mapBlocks[b].bg) && core.isset(mapBlocks[b].bg.trigger) && (core.isset(mapBlocks[b].bg.disabledTrigger) ? mapBlocks[b].bg.disabledTrigger == false : true)) {
core.material.events[mapBlocks[b].bg.trigger](mapBlocks[b], core, function (data) {
}); });
} }
} }
} }
} }
/*
core.prototype.setTrigger = function (x, y, map, triggerName) { core.prototype.setTrigger = function (x, y, map, triggerName) {
var mapBlocks = core.status.thisMap.blocks; var mapBlocks = core.status.thisMap.blocks;
for (var b = 0; b < mapBlocks.length; b++) { for (var b = 0; b < mapBlocks.length; b++) {
@ -1834,7 +1831,7 @@ core.prototype.rmTrigger = function (x, y, map) {
} }
} }
} }
*/
core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) { core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) {
if (animateMore == 2) { if (animateMore == 2) {
core.status.twoAnimateObjs.push({ core.status.twoAnimateObjs.push({

View File

@ -107,6 +107,7 @@ data.prototype.init = function() {
/****** 系统相关 ******/ /****** 系统相关 ******/
"portalWithoutTrigger": true, // 经过楼梯、传送门时是否能“穿透”。穿透的意思是,自动寻路得到的的路径中间经过了楼梯,行走时是否触发楼层转换事件
"potionWhileRouting": false, // 寻路算法是否经过血瓶如果该项为false则寻路算法会自动尽量绕过血瓶 "potionWhileRouting": false, // 寻路算法是否经过血瓶如果该项为false则寻路算法会自动尽量绕过血瓶
} }
} }

View File

@ -11,8 +11,12 @@ events.prototype.init = function () {
}, },
'changeFloor': function (data, core, callback) { 'changeFloor': function (data, core, callback) {
// core.changeFloor(data.event.data.floorId, data.event.data.heroLoc); // core.changeFloor(data.event.data.floorId, data.event.data.heroLoc);
var heroLoc = null;
if (core.isset(data.event.data.loc)) {
heroLoc = {'x': data.event.data.loc[0], 'y': data.event.data.loc[1]};
}
core.changeFloor(data.event.data.floorId, data.event.data.stair, core.changeFloor(data.event.data.floorId, data.event.data.stair,
data.event.data.heroLoc, callback); heroLoc, callback);
}, },
'getItem': function (data, core, callback) { 'getItem': function (data, core, callback) {
core.getItem(data.event.id, 1, data.x, data.y); core.getItem(data.event.id, 1, data.x, data.y);

View File

@ -20,7 +20,7 @@ main.floors.sample0 = {
[88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86], [88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86],
], ],
"firstArrive": [ // 第一次到该楼层触发的事件 "firstArrive": [ // 第一次到该楼层触发的事件
"\t[样板提示,]首次到达某层可以触发 firstArrive 事件,\n该事件可类似于RMXP中的“自动执行脚本”。", "\t[样板提示]首次到达某层可以触发 firstArrive 事件,\n该事件可类似于RMXP中的“自动执行脚本”。",
"本事件支持一切的事件类型,常常用来触发对话,\n例如", "本事件支持一切的事件类型,常常用来触发对话,\n例如",
"\t[hero]我是谁?\n我从哪来\n我又要到哪去", "\t[hero]我是谁?\n我从哪来\n我又要到哪去",
"\t[仙子,fairy]你问我...?我也不知道啊...", "\t[仙子,fairy]你问我...?我也不知道啊...",
@ -29,22 +29,23 @@ main.floors.sample0 = {
"events": { // 该楼的所有可能事件列表NPC事件和楼层转换事件也需要包括在内 "events": { // 该楼的所有可能事件列表NPC事件和楼层转换事件也需要包括在内
/****** NPC事件 ******/ /****** NPC事件 ******/
"10,9": [ // (10,9)位置:守着道具的老人 "10,9": [ // 守着道具的老人
"\t[老人,man]这些是本样板支持的所有的道具。\n\n道具分为三类items, constants, tools。\nitems 为即捡即用类道具,例如宝石、血瓶、\n剑盾等。\nconstants 为永久道具,例如怪物手册、楼层\n传送器、幸运金币等。\ntools 为消耗类道具,例如破墙镐、炸弹、中\n心对称飞行器等。\n\n后两类道具在工具栏中可以看到并使用。", "\t[老人,man]这些是本样板支持的所有的道具。\n\n道具分为三类items, constants, tools。\nitems 为即捡即用类道具,例如宝石、血瓶、\n剑盾等。\nconstants 为永久道具,例如怪物手册、楼层\n传送器、幸运金币等。\ntools 为消耗类道具,例如破墙镐、炸弹、中\n心对称飞行器等。\n\n后两类道具在工具栏中可以看到并使用。",
"\t[老人,man]有关道具效果定义在items.js中。\n目前大多数道具已有默认行为如有自定义\n的需求则需在items.js中修改代码。", "\t[老人,man]有关道具效果定义在items.js中。\n目前大多数道具已有默认行为如有自定义\n的需求则需在items.js中修改代码。",
"\t[老人,man]constants 和 tools 各最多只允许12种\n多了会导致图标溢出。", "\t[老人,man]constants 和 tools 各最多只允许12种\n多了会导致图标溢出。",
"\t[老人,man]拾取道具结束后可触发 afterGetItem 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。", "\t[老人,man]拾取道具结束后可触发 afterGetItem 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。",
{"type": "disappear"} // 消失 {"type": "disappear"} // 消失
], ],
"10,11": [ // (10,11)位置,守着门的老人 "10,11": [ // 守着门的老人
"\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", "\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。",
"\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。", "\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的\n说明。",
{'type': 'disappear'} {'type': 'disappear'}
], ],
"2,10": [ // (2,10)位置,守着楼梯、传送门、路障的老人 "2,10": [ // 守着楼梯、传送门、路障的老人
"\t[老人,womanMagician]这些是楼梯、路障、传送门。", "\t[老人,womanMagician]这些是路障、楼梯、传送门。",
"\t[老人,womanMagician]楼梯和传送门需要在events中定义目标楼层\n和位置可参见样板里已有的的写法。",
"\t[老人,womanMagician]血网的伤害数值、中毒后每步伤害数值、衰弱\n时攻防下降的数值都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。", "\t[老人,womanMagician]血网的伤害数值、中毒后每步伤害数值、衰弱\n时攻防下降的数值都在 data.js 内定义。\n\n路障同样会尽量被自动寻路绕过。",
"\t[老人,womanMagician]楼梯和传送门需要在events中定义目标楼层\n和位置可参见样板里已有的的写法。",
"\t[老人,womanMagician]楼梯和传送门是否可“穿透”由data.js中的\n全局变量所决定你也可以单独设置。\n穿透的意思是自动寻路得到的路径中间经\n过了楼梯行走时是否触发楼层转换事件。\n例如下面的“下箭头”就是不能穿透的。",
{"type": "disappear"} {"type": "disappear"}
], ],
"2,8": [ // 守着第一批怪物的老人 "2,8": [ // 守着第一批怪物的老人
@ -65,8 +66,15 @@ main.floors.sample0 = {
], ],
/****** 楼层转换事件 ******/ /****** 楼层转换事件 ******/
"6,0": {"trigger": "changeFloor", "data": {"floorId": "sample0", "stair": "downFloor"}},
"0,11": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [0,12]}},
"0,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "stair": "upFloor"}}, // 注意目标层有多个楼梯的话写stair可能会导致到达位置不确定。这时候推荐写loc指明目标点位置。
"1,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [1,12]}},
"2,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [2,12]}},
"3,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [6,1]}},
"4,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [0,9]}},
"5,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [6,10]}, "portalWithoutTrigger": false}, // 不能穿透
"6,12": {"trigger": "changeFloor", "data": {"floorId": "sample0", "loc": [10,10]}},
/****** 领域、夹击检查事件 ******/ /****** 领域、夹击检查事件 ******/

View File

@ -221,8 +221,12 @@ maps.prototype.addEvent = function (block, x, y, event) {
if (core.isset(event.trigger)) block.event.trigger=event.trigger; if (core.isset(event.trigger)) block.event.trigger=event.trigger;
else block.event.trigger='action'; else block.event.trigger='action';
} }
// 覆盖data // 覆盖其他属性
block.event.data = event.data; for (var key in event) {
if (key!="enable" && key!="trigger") {
block.event[key]=core.clone(event[key]);
}
}
} }
maps.prototype.initMaps = function (floorIds) { maps.prototype.initMaps = function (floorIds) {