This commit is contained in:
oc 2019-03-23 00:40:09 +08:00
parent 817c3b81e7
commit e7af2ec476
4 changed files with 118 additions and 8 deletions

View File

@ -13,14 +13,21 @@ var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
"_type": "event",
"_range": "thiseval instanceof Array",
"_event": "commonEvent",
"_data": "打败怪物后进行加点"
"_data": "打败怪物后加点"
},
"毒衰咒处理": {
"_leaf": true,
"_type": "event",
"_range": "thiseval instanceof Array",
"_event": "commonEvent",
"_data": "对毒衰咒效果进行的处理"
"_data": "毒衰咒效果处理"
},
"滑冰事件": {
"_leaf": true,
"_type": "event",
"_range": "thiseval instanceof Array",
"_event": "commonEvent",
"_data": "滑冰事件"
},
}
if (obj[key]) return obj[key];

View File

@ -657,10 +657,17 @@ control.prototype._moveAction_moving = function (callback) {
}
// 执行该点的阻激夹域事件
core.checkBlock();
// 执行该点事件
if (!hasTrigger)
core.events._trigger(nowx, nowy);
core.updateStatusBar();
// 检查该点是否是滑冰
if (core.getBgFgNumber('bg') == 167) {
core.insertAction("滑冰事件");
}
if (callback) callback();
});
}

View File

@ -331,13 +331,13 @@ maps.prototype.getMapBlocksObj = function (floorId, showDisable) {
}
////// 将背景前景层变成二维数组的形式 //////
maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
maps.prototype.getBgFgMapArray = function (name, floorId, noCache) {
floorId = floorId || core.status.floorId;
if (!floorId) return [];
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
if (useCache && core.status[name + "maps"][floorId])
if (!noCache && core.status[name + "maps"][floorId])
return core.status[name + "maps"][floorId];
var arr = core.clone(core.floors[floorId][name + "map"] || []);
@ -352,11 +352,17 @@ maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
if (main.mode == 'editor') arr[y][x] = arr[y][x].idnum || arr[y][x] || 0;
}
}
if (useCache)
if (!noCache)
core.status[name + "maps"][floorId] = core.clone(arr);
return arr;
}
maps.prototype.getBgFgNumber = function (name, x, y, floorId, noCache) {
if (x == null) x = core.getHeroLoc('x');
if (y == null) y = core.getHeroLoc('y');
return this.getBgFgMapArray(name, floorId, noCache)[y][x];
}
// ------ 当前能否朝某方向移动,能否瞬间移动 ------ //
////// 生成全图的当前可移动信息 //////
@ -364,8 +370,8 @@ maps.prototype.generateMovableArray = function (floorId, x, y, direction) {
floorId = floorId || core.status.floorId;
if (!floorId) return null;
var width = core.floors[floorId].width, height = core.floors[floorId].height;
var bgArray = this.getBgFgMapArray('bg', floorId, true),
fgArray = this.getBgFgMapArray('fg', floorId, true),
var bgArray = this.getBgFgMapArray('bg', floorId),
fgArray = this.getBgFgMapArray('fg', floorId),
eventArray = this.getMapArray(floorId);
var generate = function (x, y, direction) {
@ -477,6 +483,8 @@ maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
maps.prototype._canMoveDirectly_bfs = function (sx, sy, ex, ey) {
var canMoveArray = this.generateMovableArray();
var blocksObj = this.getMapBlocksObj(core.status.floorId);
// 滑冰
var bgMap = this.getBgFgMapArray('bg');
var visited = [], queue = [];
visited[sx + "," + sy] = 0;
@ -488,6 +496,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, ex, ey) {
if (!core.inArray(canMoveArray[x][y], direction)) continue;
var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny;
if (visited[nindex]) continue;
if (bgMap[ny][nx] == 167) continue;
if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue;
visited[nindex] = visited[now] + 1;
if (nx == ex && ny == ey) return visited[nindex];
@ -744,7 +753,7 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
if (!core.status[name + "maps"])
core.status[name + "maps"] = {};
var arr = this.getBgFgMapArray(name, floorId);
var arr = this.getBgFgMapArray(name, floorId, true);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
var block = this.initBlock(x, y, arr[y][x], true);

View File

@ -150,6 +150,93 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
}
]
}
],
"滑冰事件": [
{
"type": "comment",
"text": "公共事件:滑冰事件"
},
{
"type": "if",
"condition": "core.canMoveHero()",
"true": [
{
"type": "comment",
"text": "检测下一个点是否可通行"
},
{
"type": "setValue",
"name": "flag:nx",
"value": "core.nextX()"
},
{
"type": "setValue",
"name": "flag:ny",
"value": "core.nextY()"
},
{
"type": "if",
"condition": "core.noPass(flag:nx, flag:ny)",
"true": [
{
"type": "comment",
"text": "不可通行,触发下一个点的事件"
},
{
"type": "trigger",
"loc": [
"flag:nx",
"flag:ny"
]
}
],
"false": [
{
"type": "comment",
"text": "可通行,先移动到下个点,然后检查阻激夹域,并尝试触发该点事件"
},
{
"type": "moveHero",
"time": 80,
"steps": [
"forward"
]
},
{
"type": "function",
"function": "function(){\ncore.checkBlock();\n}"
},
{
"type": "comment",
"text": "【触发事件】如果该点存在事件则会立刻结束当前事件"
},
{
"type": "trigger",
"loc": [
"flag:nx",
"flag:ny"
]
},
{
"type": "comment",
"text": "如果该点不存在事件,则继续检测该点是否是滑冰点"
},
{
"type": "if",
"condition": "core.getBgFgNumber('bg') == 167",
"true": [
{
"type": "insert",
"name": "滑冰事件"
}
],
"false": []
}
]
}
],
"false": []
}
]
}
}