2022-11-19 13:07:42 +08:00
|
|
|
|
///<reference path="../../src/types/core.d.ts" />
|
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
|
|
|
|
events: {
|
|
|
|
|
resetGame: function (hero, hard, floorId, maps, values) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 重置整个游戏;此函数将在游戏开始时,或者每次读档时最先被调用
|
|
|
|
|
// hero:勇士信息;hard:难度;floorId:当前楼层ID;maps:地图信息;values:全局数值信息
|
|
|
|
|
|
|
|
|
|
// 清除游戏数据
|
|
|
|
|
// 这一步会清空状态栏和全部画布内容,并删除所有动态创建的画布
|
|
|
|
|
core.clearStatus();
|
|
|
|
|
// 初始化status
|
|
|
|
|
core.status = core.clone(core.initStatus, function (name) {
|
|
|
|
|
return name != 'hero' && name != 'maps';
|
|
|
|
|
});
|
|
|
|
|
core.control._bindRoutePush();
|
|
|
|
|
core.status.played = true;
|
|
|
|
|
// 初始化人物,图标,统计信息
|
|
|
|
|
core.status.hero = core.clone(hero);
|
|
|
|
|
window.hero = core.status.hero;
|
|
|
|
|
window.flags = core.status.hero.flags;
|
|
|
|
|
core.events.setHeroIcon(core.status.hero.image, true);
|
|
|
|
|
core.control._initStatistics(core.animateFrame.totalTime);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.hero.statistics.totalTime =
|
|
|
|
|
core.animateFrame.totalTime = Math.max(
|
|
|
|
|
core.status.hero.statistics.totalTime,
|
|
|
|
|
core.animateFrame.totalTime
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.status.hero.statistics.start = null;
|
|
|
|
|
// 初始难度
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.hard = hard || '';
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 初始化地图
|
|
|
|
|
core.status.floorId = floorId;
|
|
|
|
|
core.status.maps = maps;
|
|
|
|
|
core.maps._resetFloorImages();
|
|
|
|
|
// 初始化怪物和道具
|
|
|
|
|
core.material.enemys = core.enemys.getEnemys();
|
|
|
|
|
core.material.items = core.items.getItems();
|
|
|
|
|
// 初始化全局数值和全局开关
|
|
|
|
|
core.values = core.clone(core.data.values);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
for (var key in values || {}) core.values[key] = values[key];
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.flags = core.clone(core.data.flags);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var globalFlags = core.getFlag('globalFlags', {});
|
|
|
|
|
for (var key in globalFlags) core.flags[key] = globalFlags[key];
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core._init_sys_flags();
|
|
|
|
|
// 初始化界面,状态栏等
|
|
|
|
|
core.resize();
|
|
|
|
|
// 状态栏是否显示
|
|
|
|
|
if (core.hasFlag('hideStatusBar'))
|
|
|
|
|
core.hideStatusBar(core.hasFlag('showToolbox'));
|
2022-11-14 17:11:23 +08:00
|
|
|
|
else core.showStatusBar();
|
2023-01-04 10:29:01 +08:00
|
|
|
|
if (main.mode === 'play' && !main.replayChecking) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.fly.splitArea();
|
2023-08-05 12:12:02 +08:00
|
|
|
|
ancTe.game.hook.emit('reset');
|
2023-04-25 20:50:23 +08:00
|
|
|
|
} else {
|
|
|
|
|
flags.autoSkill ??= true;
|
2023-01-04 10:29:01 +08:00
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
win: function (reason, norank, noexit) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 游戏获胜事件
|
|
|
|
|
// 请注意,成绩统计时是按照hp进行上传并排名
|
|
|
|
|
// 可以先在这里对最终分数进行计算,比如将2倍攻击和5倍黄钥匙数量加到分数上
|
|
|
|
|
|
|
|
|
|
// 如果不退出,则临时存储数据
|
|
|
|
|
if (noexit) {
|
|
|
|
|
core.status.extraEvent = core.clone(core.status.event);
|
|
|
|
|
}
|
2023-04-23 11:11:34 +08:00
|
|
|
|
|
|
|
|
|
if (reason === '智慧之始') {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.hero.hp +=
|
|
|
|
|
core.itemCount('yellowKey') * 5000 +
|
|
|
|
|
core.itemCount('blueKey') * 15000;
|
2023-04-23 11:11:34 +08:00
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
// 游戏获胜事件
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.ui.closePanel();
|
|
|
|
|
var replaying = core.isReplaying();
|
|
|
|
|
if (replaying) core.stopReplay();
|
|
|
|
|
core.waitHeroToStop(function () {
|
|
|
|
|
if (!noexit) {
|
|
|
|
|
core.clearMap('all'); // 清空全地图
|
|
|
|
|
core.deleteAllCanvas(); // 删除所有创建的画布
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.dom.gif2.innerHTML = '';
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
reason = core.replaceText(reason);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.drawText(
|
|
|
|
|
[
|
|
|
|
|
'\t[' +
|
|
|
|
|
(reason || '恭喜通关') +
|
|
|
|
|
']你的分数是${status:hp}。'
|
|
|
|
|
],
|
|
|
|
|
function () {
|
|
|
|
|
core.events.gameOver(reason || '', replaying, norank);
|
|
|
|
|
}
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
});
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
lose: function (reason) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 游戏失败事件
|
|
|
|
|
core.ui.closePanel();
|
|
|
|
|
var replaying = core.isReplaying();
|
|
|
|
|
core.stopReplay();
|
|
|
|
|
core.waitHeroToStop(function () {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.drawText(
|
|
|
|
|
['\t[' + (reason || '结局1') + ']你死了。\n如题。'],
|
|
|
|
|
function () {
|
|
|
|
|
core.events.gameOver(null, replaying);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
changingFloor: function (floorId, heroLoc) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 正在切换楼层过程中执行的操作;此函数的执行时间是“屏幕完全变黑“的那一刻
|
|
|
|
|
// floorId为要切换到的楼层ID;heroLoc表示勇士切换到的位置
|
|
|
|
|
|
2023-02-28 17:49:34 +08:00
|
|
|
|
const { checkLoopMap } = core.plugin.loopMap;
|
|
|
|
|
|
2023-01-03 22:24:05 +08:00
|
|
|
|
flags.floorChanging = true;
|
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// ---------- 此时还没有进行切换,当前floorId还是原来的 ---------- //
|
|
|
|
|
var currentId = core.status.floorId || null; // 获得当前的floorId,可能为null
|
|
|
|
|
var fromLoad = core.hasFlag('__fromLoad__'); // 是否是读档造成的切换
|
|
|
|
|
var isFlying = core.hasFlag('__isFlying__'); // 是否是楼传造成的切换
|
|
|
|
|
if (!fromLoad) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (!core.hasFlag('__leaveLoc__'))
|
|
|
|
|
core.setFlag('__leaveLoc__', {});
|
|
|
|
|
if (currentId != null)
|
|
|
|
|
core.getFlag('__leaveLoc__')[currentId] = core.clone(
|
|
|
|
|
core.status.hero.loc
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据分区信息自动砍层与恢复
|
2023-02-28 17:49:34 +08:00
|
|
|
|
if (core.plugin.removeMap.autoRemoveMaps)
|
|
|
|
|
core.plugin.removeMap.autoRemoveMaps(floorId);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
// 重置画布尺寸
|
|
|
|
|
core.maps.resizeMap(floorId);
|
|
|
|
|
// 设置勇士的位置
|
|
|
|
|
heroLoc.direction = core.turnDirection(heroLoc.direction);
|
|
|
|
|
core.status.hero.loc = heroLoc;
|
|
|
|
|
|
|
|
|
|
// ---------- 重绘新地图;这一步将会设置core.status.floorId ---------- //
|
|
|
|
|
core.drawMap(floorId);
|
|
|
|
|
|
2023-05-15 22:38:24 +08:00
|
|
|
|
if (!main.replayChecking) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.gameShadow.updateShadow();
|
|
|
|
|
ancTe.plugin.gameCanvas.setCanvasFilterByFloorId(floorId);
|
2023-05-15 22:38:24 +08:00
|
|
|
|
}
|
2023-02-05 18:17:10 +08:00
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 切换楼层BGM
|
|
|
|
|
if (core.status.maps[floorId].bgm) {
|
|
|
|
|
var bgm = core.status.maps[floorId].bgm;
|
|
|
|
|
if (bgm instanceof Array) bgm = bgm[0];
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (!core.hasFlag('__bgm__')) core.playBgm(bgm);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
// 更改画面色调
|
|
|
|
|
var color = core.getFlag('__color__', null);
|
|
|
|
|
if (!color && core.status.maps[floorId].color)
|
|
|
|
|
color = core.status.maps[floorId].color;
|
|
|
|
|
core.clearMap('curtain');
|
|
|
|
|
core.status.curtainColor = color;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (color)
|
|
|
|
|
core.fillRect(
|
|
|
|
|
'curtain',
|
|
|
|
|
0,
|
|
|
|
|
0,
|
2023-01-04 16:23:26 +08:00
|
|
|
|
core._PX_,
|
|
|
|
|
core._PY_,
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.arrayToRGBA(color)
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 更改天气
|
|
|
|
|
var weather = core.getFlag('__weather__', null);
|
|
|
|
|
if (!weather && core.status.maps[floorId].weather)
|
|
|
|
|
weather = core.status.maps[floorId].weather;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (weather) core.setWeather(weather[0], weather[1]);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
else core.setWeather();
|
|
|
|
|
|
2023-02-28 17:49:34 +08:00
|
|
|
|
checkLoopMap();
|
2023-01-04 16:42:29 +08:00
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
afterChangeFloor: function (floorId) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 转换楼层结束的事件;此函数会在整个楼层切换完全结束后再执行
|
|
|
|
|
// floorId是切换到的楼层
|
|
|
|
|
|
2023-01-03 22:24:05 +08:00
|
|
|
|
if (flags.onChase) {
|
|
|
|
|
flags.chaseTime ??= {};
|
|
|
|
|
flags.chaseTime[floorId] = Date.now();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flags.floorChanging = false;
|
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 如果是读档,则进行检查(是否需要恢复事件)
|
|
|
|
|
if (core.hasFlag('__fromLoad__')) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.events.recoverEvents(core.getFlag('__events__'));
|
|
|
|
|
core.removeFlag('__events__');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
} else {
|
|
|
|
|
// 每次抵达楼层执行的事件
|
|
|
|
|
core.insertAction(core.floors[floorId].eachArrive);
|
|
|
|
|
|
|
|
|
|
// 首次抵达楼层时执行的事件(后插入,先执行)
|
|
|
|
|
if (!core.hasVisitedFloor(floorId)) {
|
|
|
|
|
core.insertAction(core.floors[floorId].firstArrive);
|
|
|
|
|
core.visitFloor(floorId);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-01 12:22:05 +08:00
|
|
|
|
if (!flags.debug && !main.replayChecking)
|
|
|
|
|
ancTe.plugin.completion.checkVisitedFloor();
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
flyTo: function (toId, callback) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 楼层传送器的使用,从当前楼层飞往toId
|
|
|
|
|
// 如果不能飞行请返回false
|
|
|
|
|
|
|
|
|
|
var fromId = core.status.floorId;
|
|
|
|
|
|
|
|
|
|
// 检查能否飞行
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
!core.status.maps[fromId].canFlyFrom ||
|
|
|
|
|
!core.status.maps[toId].canFlyTo ||
|
|
|
|
|
!core.hasVisitedFloor(toId)
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.playSound('操作失败');
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.drawTip('无法飞往' + core.status.maps[toId].title + '!');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 平面塔模式
|
|
|
|
|
var stair = null,
|
|
|
|
|
loc = null;
|
|
|
|
|
if (core.flags.flyRecordPosition) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
loc = core.getFlag('__leaveLoc__', {})[toId] || null;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
core.status.maps[toId].flyPoint != null &&
|
|
|
|
|
core.status.maps[toId].flyPoint.length == 2
|
|
|
|
|
) {
|
|
|
|
|
loc = {
|
|
|
|
|
x: core.status.maps[toId].flyPoint[0],
|
|
|
|
|
y: core.status.maps[toId].flyPoint[1]
|
|
|
|
|
};
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
if (loc == null) {
|
|
|
|
|
// 获得两个楼层的索引,以决定是上楼梯还是下楼梯
|
|
|
|
|
var fromIndex = core.floorIds.indexOf(fromId),
|
|
|
|
|
toIndex = core.floorIds.indexOf(toId);
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var stair = fromIndex <= toIndex ? 'downFloor' : 'upFloor';
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 地下层:同层传送至上楼梯
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
fromIndex == toIndex &&
|
|
|
|
|
core.status.maps[fromId].underGround
|
|
|
|
|
)
|
|
|
|
|
stair = 'upFloor';
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 记录录像
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.route.push('fly:' + toId);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 传送
|
|
|
|
|
core.ui.closePanel();
|
|
|
|
|
core.changeFloor(toId, stair, loc, null, callback);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
afterOpenDoor: function (doorId, x, y) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 开一个门后触发的事件
|
|
|
|
|
|
|
|
|
|
var todo = [];
|
|
|
|
|
// 检查该点的获得开门后事件。
|
|
|
|
|
if (core.status.floorId == null) return;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var event =
|
|
|
|
|
core.floors[core.status.floorId].afterOpenDoor[x + ',' + y];
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (event) core.unshift(todo, event);
|
|
|
|
|
|
|
|
|
|
if (todo.length > 0) core.insertAction(todo, x, y);
|
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (core.status.event.id == null) core.continueAutomaticRoute();
|
|
|
|
|
else core.clearContinueAutomaticRoute();
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
afterGetItem: function (itemId, x, y, isGentleClick) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 获得一个道具后触发的事件
|
|
|
|
|
// itemId:获得的道具ID;x和y是该道具所在的坐标
|
|
|
|
|
// isGentleClick:是否是轻按触发的
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
(itemId.endsWith('Potion') ||
|
|
|
|
|
itemId == 'I482' ||
|
|
|
|
|
itemId == 'I484' ||
|
|
|
|
|
itemId == 'I487' ||
|
|
|
|
|
itemId == 'I491') &&
|
|
|
|
|
core.material.items[itemId].cls == 'items'
|
|
|
|
|
)
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.playSound('回血');
|
2022-11-14 17:11:23 +08:00
|
|
|
|
else core.playSound('获得道具');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
var todo = [];
|
|
|
|
|
// 检查该点的获得道具后事件。
|
|
|
|
|
if (core.status.floorId == null) return;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var event =
|
|
|
|
|
core.floors[core.status.floorId].afterGetItem[x + ',' + y];
|
|
|
|
|
if (
|
|
|
|
|
event &&
|
|
|
|
|
(event instanceof Array ||
|
|
|
|
|
!isGentleClick ||
|
|
|
|
|
!event.disableOnGentleClick)
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.unshift(todo, event);
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (core.hasFlag('spring')) {
|
|
|
|
|
if (!core.hasFlag('springCount'))
|
|
|
|
|
core.setFlag('springCount', 0);
|
|
|
|
|
if (
|
|
|
|
|
itemId.endsWith('Potion') ||
|
|
|
|
|
itemId == 'I482' ||
|
|
|
|
|
itemId == 'I484' ||
|
|
|
|
|
itemId == 'I487' ||
|
|
|
|
|
itemId == 'I491'
|
|
|
|
|
) {
|
|
|
|
|
core.addFlag('springCount', 1);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (core.getFlag('springCount', 0) == 50) {
|
|
|
|
|
core.setFlag('springCount', 0);
|
2023-04-22 10:55:43 +08:00
|
|
|
|
core.status.hero.hpmax +=
|
|
|
|
|
core.getNakedStatus('hpmax') * 0.1;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
core.updateStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (todo.length > 0) core.insertAction(todo, x, y);
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
actions: {
|
|
|
|
|
onKeyUp: function (keyCode, altKey) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 键盘按键处理,可以在这里自定义快捷键列表
|
|
|
|
|
// keyCode:当前按键的keyCode(每个键的keyCode自行百度)
|
|
|
|
|
// altKey:Alt键是否被按下,为true代表同时按下了Alt键
|
|
|
|
|
// 可以在这里任意增加或编辑每个按键的行为
|
|
|
|
|
|
2022-11-21 20:00:34 +08:00
|
|
|
|
if (core.status.lockControl) return;
|
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 如果处于正在行走状态,则不处理
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (core.isMoving()) return;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
// Alt+0~9,快捷换上套装
|
|
|
|
|
if (altKey && keyCode >= 48 && keyCode <= 57) {
|
|
|
|
|
core.items.quickLoadEquip(keyCode - 48);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:50:23 +08:00
|
|
|
|
const [x, y] = flags.mouseLoc ?? [];
|
2023-01-06 22:42:46 +08:00
|
|
|
|
const mx = Math.round(x + core.bigmap.offsetX / 32);
|
|
|
|
|
const my = Math.round(y + core.bigmap.offsetY / 32);
|
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 根据keyCode值来执行对应操作
|
|
|
|
|
switch (keyCode) {
|
|
|
|
|
case 74: // J:打开技能树
|
2023-04-24 20:27:21 +08:00
|
|
|
|
core.useItem('skill1', true);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 27: // ESC:打开菜单栏
|
|
|
|
|
core.openSettings(true);
|
|
|
|
|
break;
|
|
|
|
|
case 88: // X:使用怪物手册
|
2023-01-04 11:32:01 +08:00
|
|
|
|
core.openBook(true);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 71: // G:使用楼传器
|
|
|
|
|
core.useFly(true);
|
|
|
|
|
break;
|
|
|
|
|
case 65: // A:读取自动存档(回退)
|
2023-01-04 11:32:01 +08:00
|
|
|
|
core.doSL('autoSave', 'load');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 87: // W:撤销回退
|
2023-01-04 11:32:01 +08:00
|
|
|
|
core.doSL('autoSave', 'reload');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 83: // S:存档
|
|
|
|
|
core.save(true);
|
|
|
|
|
break;
|
|
|
|
|
case 68: // D:读档
|
|
|
|
|
core.load(true);
|
|
|
|
|
break;
|
|
|
|
|
case 84: // T:打开道具栏
|
|
|
|
|
core.openToolbox(true);
|
|
|
|
|
break;
|
|
|
|
|
case 81: // Q:打开装备栏
|
|
|
|
|
core.openEquipbox(true);
|
|
|
|
|
break;
|
|
|
|
|
case 90: // Z:转向
|
|
|
|
|
core.turnHero();
|
|
|
|
|
break;
|
|
|
|
|
case 86: // V:打开快捷商店列表
|
|
|
|
|
core.openQuickShop(true);
|
|
|
|
|
break;
|
|
|
|
|
case 32: // SPACE:轻按
|
|
|
|
|
core.getNextItem();
|
|
|
|
|
break;
|
|
|
|
|
case 82: // R:回放录像
|
|
|
|
|
core.ui._drawReplay();
|
|
|
|
|
break;
|
|
|
|
|
case 33:
|
|
|
|
|
case 34: // PgUp/PgDn:浏览地图
|
|
|
|
|
core.ui._drawViewMaps();
|
|
|
|
|
break;
|
|
|
|
|
case 66: // B:打开数据统计
|
|
|
|
|
core.ui._drawStatistics();
|
|
|
|
|
break;
|
|
|
|
|
case 72: // H:打开帮助页面
|
2023-01-05 22:21:40 +08:00
|
|
|
|
core.useItem('I560', true);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
2023-01-08 22:59:39 +08:00
|
|
|
|
case 67: // C:怪物临界
|
|
|
|
|
if (core.getBlockCls(mx, my)?.startsWith('enemy')) {
|
|
|
|
|
core.plugin.fixedDetailPanel = 'critical';
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.fixed.showFixed.value = false;
|
|
|
|
|
ancTe.plugin.ui.fixedDetailOpened.value = true;
|
2023-01-08 22:59:39 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 69: // E:怪物属性
|
2023-01-06 22:42:46 +08:00
|
|
|
|
if (core.getBlockCls(mx, my)?.startsWith('enemy')) {
|
2023-01-08 22:59:39 +08:00
|
|
|
|
core.plugin.fixedDetailPanel = 'special';
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.fixed.showFixed.value = false;
|
|
|
|
|
ancTe.plugin.ui.fixedDetailOpened.value = true;
|
2023-01-06 22:18:33 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
2022-12-30 11:06:46 +08:00
|
|
|
|
case 77: // M:快速标记
|
|
|
|
|
const blocks = core.getMapBlocksObj();
|
|
|
|
|
const block = blocks[`${mx},${my}`];
|
|
|
|
|
if (block.event.cls.startsWith('enemy')) {
|
|
|
|
|
const name = core.material.enemys[block.event.id].name;
|
2023-08-01 12:22:05 +08:00
|
|
|
|
if (ancTe.plugin.mark.hasMarkedEnemy(block.event.id)) {
|
|
|
|
|
ancTe.plugin.utils.tip(
|
|
|
|
|
'success',
|
|
|
|
|
`已取消标记${name}!`
|
|
|
|
|
);
|
|
|
|
|
ancTe.plugin.mark.unmarkEnemy(block.event.id);
|
2022-12-30 11:06:46 +08:00
|
|
|
|
} else {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.utils.tip(
|
|
|
|
|
'success',
|
|
|
|
|
`已标记${name}!`
|
|
|
|
|
);
|
|
|
|
|
ancTe.plugin.mark.checkMarkedEnemy(block.event.id);
|
2022-12-30 11:06:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 78: // N:重新开始
|
|
|
|
|
core.confirmRestart();
|
|
|
|
|
break;
|
|
|
|
|
case 79: // O:查看工程
|
|
|
|
|
core.actions._clickGameInfo_openProject();
|
|
|
|
|
break;
|
|
|
|
|
case 80: // P:游戏主页
|
|
|
|
|
core.actions._clickGameInfo_openComments();
|
|
|
|
|
break;
|
|
|
|
|
case 49: // 1: 断灭之刃
|
2023-04-22 10:04:03 +08:00
|
|
|
|
if (!flags.bladeOn) break;
|
2023-04-22 16:09:41 +08:00
|
|
|
|
if (flags.autoSkill) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.utils.tip('error', '已开启自动切换技能!');
|
2023-04-22 10:04:03 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.route.push('key:49'); // 将按键记在录像中
|
|
|
|
|
core.playSound('光标移动');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (flags.blade) flags.blade = false;
|
|
|
|
|
else flags.blade = true;
|
2023-01-04 10:29:01 +08:00
|
|
|
|
core.updateStatusBar();
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 50: // 快捷键2: 跳跃技能 || 破
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
!flags.chase &&
|
|
|
|
|
!core.status.floorId.startsWith('tower') &&
|
|
|
|
|
flags.skill2
|
|
|
|
|
) {
|
2023-02-28 17:49:34 +08:00
|
|
|
|
core.plugin.skillEffects.jumpSkill();
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.route.push('key:50'); // 将按键记在录像中
|
2022-11-13 18:02:05 +08:00
|
|
|
|
} else {
|
|
|
|
|
if (core.hasItem('pickaxe')) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.route.push('key:50'); // 将按键记在录像中
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.useItem('pickaxe', true); // 第二个参数true代表该次使用道具是被按键触发的,使用过程不计入录像
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2023-01-04 22:11:08 +08:00
|
|
|
|
case 51: // 3: 铸剑为盾
|
2023-04-22 10:04:03 +08:00
|
|
|
|
if (!flags.shieldOn) break;
|
2023-04-22 16:09:41 +08:00
|
|
|
|
if (flags.autoSkill) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.utils.tip('error', '已开启自动切换技能!');
|
2023-04-22 10:04:03 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-01-04 22:11:08 +08:00
|
|
|
|
core.status.route.push('key:51'); // 将按键记在录像中
|
|
|
|
|
core.playSound('光标移动');
|
|
|
|
|
if (flags.shield) flags.shield = false;
|
|
|
|
|
else flags.shield = true;
|
|
|
|
|
core.updateStatusBar();
|
|
|
|
|
break;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
case 53: // 5:读取自动存档(回退),方便手机版操作
|
2023-01-04 11:32:01 +08:00
|
|
|
|
core.doSL('autoSave', 'load');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 54: // 6:撤销回退,方便手机版操作
|
2023-01-04 11:32:01 +08:00
|
|
|
|
core.doSL('autoSave', 'reload');
|
2022-11-13 18:02:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 55: // 快捷键7:绑定为轻按,方便手机版操作
|
|
|
|
|
core.getNextItem();
|
|
|
|
|
break;
|
2023-04-24 11:31:49 +08:00
|
|
|
|
case 119: // F8:开启debug模式
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.debug();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
control: {
|
|
|
|
|
saveData: function () {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 存档操作,此函数应该返回“具体要存档的内容”
|
|
|
|
|
|
|
|
|
|
// 差异化存储values
|
|
|
|
|
var values = {};
|
|
|
|
|
for (var key in core.values) {
|
|
|
|
|
if (!core.same(core.values[key], core.data.values[key]))
|
|
|
|
|
values[key] = core.clone(core.values[key]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 要存档的内容
|
|
|
|
|
var data = {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
floorId: core.status.floorId,
|
2023-01-05 22:21:40 +08:00
|
|
|
|
hero: core.clone(core.status.hero, name => name !== 'chase'),
|
2022-11-14 17:11:23 +08:00
|
|
|
|
hard: core.status.hard,
|
2022-11-30 16:42:44 +08:00
|
|
|
|
maps: core.clone(core.maps.saveMap()),
|
2022-11-14 17:11:23 +08:00
|
|
|
|
route: core.encodeRoute(core.status.route),
|
|
|
|
|
values: values,
|
|
|
|
|
version: core.firstData.version,
|
|
|
|
|
guid: core.getGuid(),
|
2022-12-30 23:28:27 +08:00
|
|
|
|
time: new Date().getTime(),
|
2023-02-28 17:49:34 +08:00
|
|
|
|
skills: core.plugin.skillTree.saveSkillTree()
|
2022-11-13 18:02:05 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
loadData: function (data, callback) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 读档操作;从存储中读取了内容后的行为
|
2023-01-03 22:24:05 +08:00
|
|
|
|
if (window.flags && flags.onChase) {
|
|
|
|
|
flags.chase.end();
|
|
|
|
|
flags.onChase = true;
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 重置游戏和路线
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.resetGame(
|
|
|
|
|
data.hero,
|
|
|
|
|
data.hard,
|
|
|
|
|
data.floorId,
|
|
|
|
|
core.maps.loadMap(data.maps, null, data.hero.flags),
|
|
|
|
|
data.values
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
core.status.route = core.decodeRoute(data.route);
|
|
|
|
|
core.control._bindRoutePush();
|
|
|
|
|
// 文字属性,全局属性
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.textAttribute = core.getFlag(
|
|
|
|
|
'textAttribute',
|
|
|
|
|
core.status.textAttribute
|
|
|
|
|
);
|
|
|
|
|
var toAttribute = core.getFlag(
|
|
|
|
|
'globalAttribute',
|
|
|
|
|
core.status.globalAttribute
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (!core.same(toAttribute, core.status.globalAttribute)) {
|
|
|
|
|
core.status.globalAttribute = toAttribute;
|
|
|
|
|
core.resize();
|
|
|
|
|
}
|
|
|
|
|
// 重置音量
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.events.setVolume(core.getFlag('__volume__', 1), 0);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 加载勇士图标
|
|
|
|
|
var icon = core.status.hero.image;
|
|
|
|
|
icon = core.getMappedName(icon);
|
|
|
|
|
if (core.material.images.images[icon]) {
|
|
|
|
|
core.material.images.hero = core.material.images.images[icon];
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.material.icons.hero.width =
|
|
|
|
|
core.material.images.images[icon].width / 4;
|
|
|
|
|
core.material.icons.hero.height =
|
|
|
|
|
core.material.images.images[icon].height / 4;
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
core.setFlag('__fromLoad__', true);
|
|
|
|
|
|
2023-02-28 17:49:34 +08:00
|
|
|
|
core.plugin.skillTree.loadSkillTree(data.skills);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
// 切换到对应的楼层
|
|
|
|
|
core.changeFloor(data.floorId, null, data.hero.loc, 0, function () {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (core.hasFlag('__bgm__')) {
|
|
|
|
|
// 持续播放
|
|
|
|
|
core.playBgm(core.getFlag('__bgm__'));
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
core.removeFlag('__fromLoad__');
|
|
|
|
|
if (callback) callback();
|
2023-01-03 22:24:05 +08:00
|
|
|
|
|
|
|
|
|
if (flags.onChase) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.fly.startChase(flags.chaseIndex);
|
2023-01-03 22:24:05 +08:00
|
|
|
|
if (flags.chaseIndex === 1) {
|
|
|
|
|
core.playBgm('escape.mp3', 43.5);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
});
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
getStatusLabel: function (name) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 返回某个状态英文名的对应中文标签,如atk -> 攻击,def -> 防御等。
|
|
|
|
|
// 请注意此项仅影响 libs/ 下的内容(如绘制怪物手册、数据统计等)
|
|
|
|
|
// 自行定义的(比如获得道具效果)中用到的“攻击+3”等需要自己去对应地方修改
|
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
return (
|
|
|
|
|
{
|
|
|
|
|
name: '名称',
|
|
|
|
|
lv: '等级',
|
|
|
|
|
hpmax: '生命回复',
|
|
|
|
|
hp: '生命',
|
|
|
|
|
manamax: '魔力上限',
|
|
|
|
|
mana: '额外攻击',
|
|
|
|
|
atk: '攻击',
|
|
|
|
|
def: '防御',
|
|
|
|
|
mdef: '智慧',
|
|
|
|
|
money: '金币',
|
|
|
|
|
exp: '经验',
|
|
|
|
|
point: '加点',
|
2022-11-30 16:42:44 +08:00
|
|
|
|
steps: '步数',
|
|
|
|
|
up: '升级',
|
|
|
|
|
none: '无'
|
2022-11-14 17:11:23 +08:00
|
|
|
|
}[name] || name
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
updateStatusBar: function () {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 更新状态栏
|
|
|
|
|
|
|
|
|
|
// 检查等级
|
|
|
|
|
core.events.checkLvUp();
|
|
|
|
|
|
|
|
|
|
// 如果是自定义添加的状态栏,也需要在这里进行设置显示的数值
|
|
|
|
|
|
|
|
|
|
// 难度
|
|
|
|
|
if (core.statusBar.hard.innerText != core.status.hard) {
|
|
|
|
|
core.statusBar.hard.innerText = core.status.hard;
|
|
|
|
|
}
|
|
|
|
|
var hardColor = core.getFlag('__hardColor__', 'red');
|
|
|
|
|
if (core.statusBar.hard.getAttribute('_style') != hardColor) {
|
|
|
|
|
core.statusBar.hard.style.color = hardColor;
|
|
|
|
|
core.statusBar.hard.setAttribute('_style', hardColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新全地图显伤
|
|
|
|
|
core.updateDamage();
|
2023-01-06 16:21:17 +08:00
|
|
|
|
|
2023-04-25 20:50:23 +08:00
|
|
|
|
if (main.replayChecking) return;
|
|
|
|
|
|
2023-01-06 16:21:17 +08:00
|
|
|
|
// 已学习的技能
|
|
|
|
|
if (
|
2023-02-28 17:49:34 +08:00
|
|
|
|
core.plugin.skillTree.getSkillLevel(11) > 0 &&
|
2023-01-06 16:21:17 +08:00
|
|
|
|
(core.status.hero.special?.num ?? []).length > 0
|
|
|
|
|
) {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.ui.showStudiedSkill.value = true;
|
2023-01-06 16:21:17 +08:00
|
|
|
|
} else {
|
2023-08-01 12:22:05 +08:00
|
|
|
|
ancTe.plugin.ui.showStudiedSkill.value = false;
|
2023-01-06 16:21:17 +08:00
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
moveOneStep: function (callback) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 勇士每走一步后执行的操作。callback为行走完毕后的回调
|
|
|
|
|
// 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。
|
|
|
|
|
// 请注意:瞬间移动不会执行该函数。如果要控制能否瞬间移动有三种方法:
|
|
|
|
|
// 1. 将全塔属性中的cannotMoveDirectly这个开关勾上,即可在全塔中全程禁止使用瞬移。
|
|
|
|
|
// 2, 将楼层属性中的cannotMoveDirectly这个开关勾上,即禁止在该层楼使用瞬移。
|
|
|
|
|
// 3. 将flag:cannotMoveDirectly置为true,即可使用flag控制在某段剧情范围内禁止瞬移。
|
|
|
|
|
|
2023-02-28 17:49:34 +08:00
|
|
|
|
const { checkLoopMap } = core.plugin.loopMap;
|
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 增加步数
|
|
|
|
|
core.status.hero.steps++;
|
|
|
|
|
// 更新跟随者状态,并绘制
|
|
|
|
|
core.updateFollowers();
|
|
|
|
|
core.drawHero();
|
|
|
|
|
|
|
|
|
|
// 从v2.7开始,每一步行走不会再刷新状态栏。
|
|
|
|
|
// 如果有特殊要求(如每走一步都加buff之类),可手动取消注释下面这一句:
|
|
|
|
|
// core.updateStatusBar(true);
|
|
|
|
|
|
|
|
|
|
// 检查自动事件
|
|
|
|
|
core.checkAutoEvents();
|
|
|
|
|
|
|
|
|
|
// ------ 检查目标点事件 ------ //
|
|
|
|
|
// 无事件的道具(如血瓶)需要优先于阻激夹域判定
|
|
|
|
|
var nowx = core.getHeroLoc('x'),
|
|
|
|
|
nowy = core.getHeroLoc('y');
|
|
|
|
|
var block = core.getBlock(nowx, nowy);
|
|
|
|
|
var hasTrigger = false;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
block != null &&
|
|
|
|
|
block.event.trigger == 'getItem' &&
|
|
|
|
|
!core.floors[core.status.floorId].afterGetItem[
|
|
|
|
|
nowx + ',' + nowy
|
|
|
|
|
]
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
hasTrigger = true;
|
|
|
|
|
core.trigger(nowx, nowy, callback);
|
|
|
|
|
}
|
|
|
|
|
// 执行目标点的阻激夹域事件
|
|
|
|
|
core.checkBlock();
|
|
|
|
|
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (!hasTrigger) core.trigger(nowx, nowy, callback);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
// 检查该点是否是滑冰
|
|
|
|
|
if (core.onSki()) {
|
|
|
|
|
// 延迟到事件最后执行,因为这之前可能有阻激夹域动画
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.insertAction(
|
|
|
|
|
{ type: 'moveAction' },
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
true
|
|
|
|
|
);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-28 17:49:34 +08:00
|
|
|
|
checkLoopMap();
|
2023-01-04 16:23:26 +08:00
|
|
|
|
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 追猎
|
2023-06-29 21:52:16 +08:00
|
|
|
|
// todo: 重写
|
2023-04-28 23:58:07 +08:00
|
|
|
|
if (
|
|
|
|
|
core.status.checkBlock.haveHunt &&
|
|
|
|
|
!core
|
|
|
|
|
.getBlockId(core.status.hero.loc.x, core.status.hero.loc.y)
|
|
|
|
|
?.endsWith('Portal')
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
var x = core.status.hero.loc.x,
|
|
|
|
|
y = core.status.hero.loc.y;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.maps[core.status.floorId].blocks.forEach(function (
|
|
|
|
|
block
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (block.x != x && block.y != y) return;
|
|
|
|
|
var id = block.event.id,
|
|
|
|
|
enemy = core.material.enemys[id];
|
|
|
|
|
if (enemy && core.hasSpecial(enemy.special, 12)) {
|
|
|
|
|
var nx = block.x,
|
|
|
|
|
ny = block.y;
|
|
|
|
|
var dx = Math.abs(x - nx),
|
|
|
|
|
dy = Math.abs(y - ny);
|
|
|
|
|
if (x == block.x) {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
y > block.y &&
|
|
|
|
|
!core.noPass(block.x, block.y + 1) &&
|
|
|
|
|
core.getBlockCls(block.x, block.y + 1) !=
|
|
|
|
|
'items'
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
dy--;
|
|
|
|
|
ny++;
|
|
|
|
|
core.insertAction([
|
|
|
|
|
{
|
2022-11-14 17:11:23 +08:00
|
|
|
|
type: 'move',
|
|
|
|
|
loc: [block.x, block.y],
|
|
|
|
|
time: 200,
|
|
|
|
|
keep: true,
|
|
|
|
|
steps: ['down:1']
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
{
|
|
|
|
|
type: 'if',
|
|
|
|
|
condition: dy + '<=1',
|
|
|
|
|
true: [
|
|
|
|
|
{ type: 'battle', loc: [nx, ny] }
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
]);
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
y < block.y &&
|
|
|
|
|
!core.noPass(block.x, block.y - 1) &&
|
|
|
|
|
core.getBlockCls(block.x, block.y - 1) !=
|
|
|
|
|
'items'
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
dy--;
|
|
|
|
|
ny--;
|
|
|
|
|
core.insertAction([
|
|
|
|
|
{
|
2022-11-14 17:11:23 +08:00
|
|
|
|
type: 'move',
|
|
|
|
|
loc: [block.x, block.y],
|
|
|
|
|
time: 200,
|
|
|
|
|
keep: true,
|
|
|
|
|
steps: ['up:1']
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
{
|
|
|
|
|
type: 'if',
|
|
|
|
|
condition: dy + '<=1',
|
|
|
|
|
true: [
|
|
|
|
|
{ type: 'battle', loc: [nx, ny] }
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
x > block.x &&
|
|
|
|
|
!core.noPass(block.x + 1, block.y) &&
|
|
|
|
|
core.getBlockCls(block.x + 1, block.y) !=
|
|
|
|
|
'items'
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
dx--;
|
|
|
|
|
nx++;
|
|
|
|
|
core.insertAction([
|
|
|
|
|
{
|
2022-11-14 17:11:23 +08:00
|
|
|
|
type: 'move',
|
|
|
|
|
loc: [block.x, block.y],
|
|
|
|
|
time: 200,
|
|
|
|
|
keep: true,
|
|
|
|
|
steps: ['right:1']
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
{
|
|
|
|
|
type: 'if',
|
|
|
|
|
condition: dx + '<=1',
|
|
|
|
|
true: [
|
|
|
|
|
{ type: 'battle', loc: [nx, ny] }
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
]);
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
if (
|
|
|
|
|
x < block.x &&
|
|
|
|
|
!core.noPass(block.x - 1, block.y) &&
|
|
|
|
|
core.getBlockCls(block.x - 1, block.y) !=
|
|
|
|
|
'items'
|
|
|
|
|
) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
dx--;
|
|
|
|
|
nx--;
|
|
|
|
|
core.insertAction([
|
|
|
|
|
{
|
2022-11-14 17:11:23 +08:00
|
|
|
|
type: 'move',
|
|
|
|
|
loc: [block.x, block.y],
|
|
|
|
|
time: 200,
|
|
|
|
|
keep: true,
|
|
|
|
|
steps: ['left:1']
|
2022-11-13 18:02:05 +08:00
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
{
|
|
|
|
|
type: 'if',
|
|
|
|
|
condition: dx + '<=1',
|
|
|
|
|
true: [
|
|
|
|
|
{ type: 'battle', loc: [nx, ny] }
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-13 18:02:05 +08:00
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如需强行终止行走可以在这里条件判定:
|
|
|
|
|
// core.stopAutomaticRoute();
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
moveDirectly: function (x, y, ignoreSteps) {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 瞬间移动;x,y为要瞬间移动的点;ignoreSteps为减少的步数,可能之前已经被计算过
|
|
|
|
|
// 返回true代表成功瞬移,false代表没有成功瞬移
|
|
|
|
|
|
|
|
|
|
// 判定能否瞬移到该点
|
|
|
|
|
if (ignoreSteps == null) ignoreSteps = core.canMoveDirectly(x, y);
|
|
|
|
|
if (ignoreSteps >= 0) {
|
|
|
|
|
core.clearMap('hero');
|
|
|
|
|
// 获得勇士最后的朝向
|
2022-11-14 17:11:23 +08:00
|
|
|
|
var lastDirection =
|
|
|
|
|
core.status.route[core.status.route.length - 1];
|
2022-11-13 18:02:05 +08:00
|
|
|
|
if (['left', 'right', 'up', 'down'].indexOf(lastDirection) >= 0)
|
|
|
|
|
core.setHeroLoc('direction', lastDirection);
|
|
|
|
|
// 设置坐标,并绘制
|
|
|
|
|
core.setHeroLoc('x', x);
|
|
|
|
|
core.setHeroLoc('y', y);
|
|
|
|
|
core.drawHero();
|
|
|
|
|
// 记录录像
|
2022-11-14 17:11:23 +08:00
|
|
|
|
core.status.route.push('move:' + x + ':' + y);
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 统计信息
|
|
|
|
|
core.status.hero.statistics.moveDirectly++;
|
|
|
|
|
core.status.hero.statistics.ignoreSteps += ignoreSteps;
|
|
|
|
|
if (core.hasFlag('poison')) {
|
|
|
|
|
core.updateStatusBar(false, true);
|
|
|
|
|
}
|
|
|
|
|
core.checkRouteFolding();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-11-14 17:11:23 +08:00
|
|
|
|
ui: {
|
|
|
|
|
drawStatistics: function () {
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 浏览地图时参与的统计项目
|
|
|
|
|
|
|
|
|
|
return [
|
2022-11-14 17:11:23 +08:00
|
|
|
|
'yellowDoor',
|
|
|
|
|
'blueDoor',
|
|
|
|
|
'redDoor',
|
|
|
|
|
'greenDoor',
|
|
|
|
|
'steelDoor',
|
|
|
|
|
'yellowKey',
|
|
|
|
|
'blueKey',
|
|
|
|
|
'redKey',
|
|
|
|
|
'greenKey',
|
|
|
|
|
'steelKey',
|
|
|
|
|
'redGem',
|
|
|
|
|
'blueGem',
|
|
|
|
|
'greenGem',
|
|
|
|
|
'yellowGem',
|
|
|
|
|
'redPotion',
|
|
|
|
|
'bluePotion',
|
|
|
|
|
'greenPotion',
|
|
|
|
|
'yellowPotion',
|
|
|
|
|
'superPotion',
|
|
|
|
|
'pickaxe',
|
|
|
|
|
'bomb',
|
|
|
|
|
'centerFly',
|
|
|
|
|
'icePickaxe',
|
|
|
|
|
'freezeBadge',
|
|
|
|
|
'earthquake',
|
|
|
|
|
'upFly',
|
|
|
|
|
'downFly',
|
|
|
|
|
'jumpShoes',
|
|
|
|
|
'lifeWand',
|
|
|
|
|
'poisonWine',
|
|
|
|
|
'weakWine',
|
|
|
|
|
'curseWine',
|
|
|
|
|
'superWine',
|
|
|
|
|
'sword1',
|
|
|
|
|
'sword2',
|
|
|
|
|
'sword3',
|
|
|
|
|
'sword4',
|
|
|
|
|
'sword5',
|
|
|
|
|
'shield1',
|
|
|
|
|
'shield2',
|
|
|
|
|
'shield3',
|
|
|
|
|
'shield4',
|
|
|
|
|
'shield5'
|
2022-11-13 18:02:05 +08:00
|
|
|
|
// 在这里可以增加新的ID来进行统计个数,只能增加道具ID
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
};
|