可通行度显示

This commit is contained in:
ckcz123 2021-08-08 15:50:03 +08:00
parent 2868d5557c
commit 6740f54f5a
7 changed files with 96 additions and 21 deletions

View File

@ -54,7 +54,7 @@ function editor() {
lastUsedDiv: document.getElementById('lastUsedDiv'),
lastUsed: document.getElementById('lastUsed'),
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
lockMode: document.getElementById('lockMode'),
showMovable: document.getElementById('showMovable'),
gameInject: document.getElementById('gameInject'),
undoFloor: document.getElementById('undoFloor'),
editorTheme: document.getElementById('editorTheme'),
@ -118,6 +118,8 @@ function editor() {
// tile
lockMode: false,
showMovable: false,
// 最近使用的图块
lastUsedType: null,
@ -375,9 +377,17 @@ editor.prototype.drawEventBlock = function () {
if (editor.uivalues.bigmap) return this._drawEventBlock_bigmap();
var firstData = editor.game.getFirstData();
// 不可通行性
var movableArray = {};
if (editor.uivalues.showMovable) {
movableArray = core.generateMovableArray() || {};
fg.fillStyle = "rgba(0,0,0,0.4)";
fg.fillRect(0, 0, core.__PIXELS__, core.__PIXELS__);
}
for (var i=0;i<core.__SIZE__;i++) {
for (var j=0;j<core.__SIZE__;j++) {
var loc=(i+core.bigmap.offsetX/32)+","+(j+core.bigmap.offsetY/32);
var x = i+core.bigmap.offsetX/32, y = j+core.bigmap.offsetY/32;
var loc= x + ',' + y;
if (editor.currentFloorId == firstData.floorId
&& loc == firstData.hero.loc.x + "," + firstData.hero.loc.y) {
fg.textAlign = 'center';
@ -411,6 +421,29 @@ editor.prototype.drawEventBlock = function () {
editor.game.doCoreFunc("fillText", fg, "🔃", 32 * i + offset, 32 * j + 8, null, "8px Verdana");
offset += 8;
}
var directions = (movableArray[x]||{})[y];
if (directions == null) continue;
if (!directions.includes('left') && x != 0) {
core.drawLine(fg, 32 * i + 1, 32 * j + 10, 32 * i + 1, 32 * j + 22, '#FF0000', 2);
core.drawLine(fg, 32 * i + 6, 32 * j + 13, 32 * i + 2, 32 * j + 16);
core.drawLine(fg, 32 * i + 6, 32 * j + 19, 32 * i + 2, 32 * j + 16);
}
if (!directions.includes('right') && x != editor.currentFloorData.width - 1) {
core.drawLine(fg, 32 * i + 31, 32 * j + 10, 32 * i + 31, 32 * j + 22, '#FF0000', 2);
core.drawLine(fg, 32 * i + 26, 32 * j + 13, 32 * i + 30, 32 * j + 16);
core.drawLine(fg, 32 * i + 26, 32 * j + 19, 32 * i + 30, 32 * j + 16);
}
if (!directions.includes('up') && y != 0) {
core.drawLine(fg, 32 * i + 10, 32 * j + 1, 32 * i + 22, 32 * j + 1, '#FF0000', 2);
core.drawLine(fg, 32 * i + 13, 32 * j + 6, 32 * i + 16, 32 * j + 2);
core.drawLine(fg, 32 * i + 19, 32 * j + 6, 32 * i + 16, 32 * j + 2);
}
if (!directions.includes('down') && y != editor.currentFloorData.height - 1) {
core.drawLine(fg, 32 * i + 10, 32 * j + 31, 32 * i + 22, 32 * j + 31, '#FF0000', 2);
core.drawLine(fg, 32 * i + 13, 32 * j + 26, 32 * i + 16, 32 * j + 30);
core.drawLine(fg, 32 * i + 19, 32 * j + 26, 32 * i + 16, 32 * j + 30);
}
}
}
}
@ -418,6 +451,14 @@ editor.prototype.drawEventBlock = function () {
editor.prototype._drawEventBlock_bigmap = function () {
var fg=editor.dom.efgCtx;
var info = editor.uivalues.bigmapInfo, size = info.size, psize = size / 4;
// 不可通行性
var movableArray = {};
if (editor.uivalues.showMovable) {
movableArray = core.generateMovableArray() || {};
fg.fillStyle = "rgba(0,0,0,0.4)";
fg.fillRect(0, 0, core.__PIXELS__, core.__PIXELS__);
}
for (var i = 0; i < editor.currentFloorData.width; ++i) {
for (var j = 0; j < editor.currentFloorData.height; ++j) {
@ -426,6 +467,22 @@ editor.prototype._drawEventBlock_bigmap = function () {
fg.fillStyle = cc;
fg.fillRect(info.left + size * i + psize * kk, info.top + size * (j + 1) - psize, psize, psize);
}
var directions = (movableArray[i]||{})[j];
if (directions == null) continue;
if (!directions.includes('left') && i != 0) {
core.drawLine(fg, info.left + size * i + 1, info.top + size * j + size / 3, info.left + size * i + 1, info.top + size * j + size * 2 / 3, '#FF0000', 2);
}
if (!directions.includes('right') && i != editor.currentFloorData.width - 1) {
core.drawLine(fg, info.left + size * i + size - 1, info.top + size * j + size / 3, info.left + size * i + size - 1, info.top + size * j + size * 2 / 3, '#FF0000', 2);
}
if (!directions.includes('up') && j != 0) {
core.drawLine(fg, info.left + size * i + size / 3, info.top + size * j + 1, info.left + size * i + size * 2 / 3, info.top + size * j + 1, '#FF0000', 2);
}
if (!directions.includes('down') && j != editor.currentFloorData.height - 1) {
core.drawLine(fg, info.left + size * i + size / 3, info.top + size * j + size - 1, info.left + size * i + size * 2 / 3, info.top + size * j + size - 1, '#FF0000', 2);
}
}
}
}
@ -444,15 +501,13 @@ editor.prototype._drawEventBlock_getColor = function (loc) {
}
}
if (editor.currentFloorData.beforeBattle[loc])
color.push('#009090');
color.push('#0000FF');
if (editor.currentFloorData.afterBattle[loc])
color.push('#FFFF00');
if (editor.currentFloorData.changeFloor[loc])
color.push('#00FF00');
if (editor.currentFloorData.afterGetItem[loc])
color.push('#00FFFF');
if (editor.currentFloorData.cannotMove[loc] && editor.currentFloorData.cannotMove[loc].length > 0)
color.push('#0000FF');
if (editor.currentFloorData.afterOpenDoor[loc])
color.push('#FF00FF');
return color;

View File

@ -42,7 +42,7 @@ editor_listen_wrapper = function (editor) {
editor.dom.lastUsed.onmouseup = editor.uifunctions.lastUsed_click;
editor.dom.lastUsed.oncontextmenu = function (e) { e.preventDefault(); }
editor.dom.clearLastUsedBtn.onclick = editor.uifunctions.clearLastUsedBtn_click;
editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange;
editor.dom.showMovable.onchange = editor.uifunctions.showMovable_onchange;
editor.dom.brushMod.onchange = editor.uifunctions.brushMod_onchange
if (editor.dom.brushMod2) editor.dom.brushMod2.onchange = editor.uifunctions.brushMod2_onchange;

View File

@ -774,12 +774,13 @@ editor_mappanel_wrapper = function (editor) {
}
/**
* editor.dom.lockMode.onchange
* editor.dom.showMovable.onchange
* 点击
*/
editor.uifunctions.lockMode_onchange = function () {
printf('锁定模式开启下将不再点击空白处自动保存,请谨慎操作。');
editor.uivalues.lockMode = editor.dom.lockMode.checked;
editor.uifunctions.showMovable_onchange = function () {
printf('此模式下将显示每个点的不可通行状态。<br/>请注意,修改了图块属性的不可出入方向后需要刷新才会正确显示在地图上。');
editor.uivalues.showMovable = editor.dom.showMovable.checked;
editor.drawEventBlock();
}
/**

View File

@ -627,8 +627,18 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"prefix": ["上: ", "下: ", "<br>左: ", "右: "],
"key": ["up", "down", "left", "right"]
},
"_docs": "不可通行性",
"_data": "该点不可通行的方向 \n 可以在这里定义该点不能前往哪个方向,可以达到悬崖之类的效果\n例如 [\"up\", \"left\"] 代表该点不能往上和左走"
"_docs": "不可出方向",
"_data": "该点不可通行出的方向 \n 可以在这里定义该点不能前往哪个方向,可以达到悬崖之类的效果"
},
"cannotMoveIn": {
"_leaf": true,
"_type": "checkboxSet",
"_checkboxSet": {
"prefix": ["上: ", "下: ", "<br>左: ", "右: "],
"key": ["up", "down", "left", "right"]
},
"_docs": "不可入方向",
"_data": "该点不可通行入的方向 \n 可以在这里定义从哪个方向前往该点,可以达到悬崖之类的效果"
},
}
}
@ -664,7 +674,8 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"afterGetItem": {},
"afterOpenDoor": {},
"autoEvent": {},
"cannotMove": {}
"cannotMove": {},
"cannotMoveIn": {}
}
}
}

View File

@ -357,8 +357,8 @@
<option value="commonevent">公共事件</option>
<option value="plugins">插件编写</option>
</select>
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定</span>
<select id="editorTheme">
<span style="font-size: 12px"><input type="checkbox" id="showMovable"/>通行度</span>
<select id="editorTheme" style="font-size: 11px;">
<option value="editor_color">默认白</option>
<option value="editor_color_dark">夜间黑</option>
</select>

View File

@ -316,8 +316,8 @@
<option value="commonevent">公共事件</option>
<option value="plugins">插件编写</option>
</select>
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定</span>
<select id="editorTheme" style="margin-left: 3px;">
<span style="font-size: 12px"><input type="checkbox" id="showMovable"/>通行度</span>
<select id="editorTheme" style="margin-left: 3px; font-size: 11px;">
<option value="editor_color">默认白</option>
<option value="editor_color_dark">夜间黑</option>
</select>
@ -348,6 +348,7 @@
<input type="button" value="保存地图" id='saveFloor'/>
<input type="button" value="后退" id="undoFloor" />
<input type="button" value="查看帮助文档" id="openDoc" />
<input type="button" value="前往游戏" onclick="window.open('./index.html', '_blank')"/>
</div>
</div>
<div id="mid2">

View File

@ -23,6 +23,8 @@ maps.prototype._initFloors = function (floorId) {
// 战前事件兼容性
if (!core.floors[floorId].beforeBattle) core.floors[floorId].beforeBattle = {}
// cannotMoveIn兼容性
if (!core.floors[floorId].cannotMoveIn) core.floors[floorId].cannotMoveIn = {}
}
maps.prototype._resetFloorImages = function () {
@ -74,7 +76,8 @@ maps.prototype.loadFloor = function (floorId, map) {
maps.prototype._loadFloor_doNotCopy = function () {
return [
"firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap",
"events", "changeFloor", "beforeBattle", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove"
"events", "changeFloor", "beforeBattle", "afterBattle", "afterGetItem", "afterOpenDoor",
"cannotMove", "cannotMoveIn"
];
}
@ -725,15 +728,19 @@ maps.prototype._canMoveHero_checkPoint = function (x, y, direction, floorId, arr
if (nx < 0 || ny < 0 || nx >= core.floors[floorId].width || ny >= core.floors[floorId].height)
return false;
// 2. 检查该点素材的 cannotOut 和下一个点的 cannotIn
// 2. 检查下个点的 cannotMoveIn
if (core.inArray((core.floors[floorId].cannotMoveIn || {})[nx + "," + ny], core.turnDirection(":back", direction)))
return false;
// 3. 检查该点素材的 cannotOut 和下一个点的 cannotIn
if (this._canMoveHero_checkCannotInOut(Object.keys(arrays).map(function (name) { return arrays[name][y][x]; }), "cannotOut", direction))
return false;
if (this._canMoveHero_checkCannotInOut(Object.keys(arrays).map(function (name) { return arrays[name][ny][nx]; }), "cannotIn", direction))
return false;
// 3. 检查是否能进将死的领域
// 4. 检查是否能进将死的领域
if (floorId == core.status.floorId && !core.flags.canGoDeadZone && !core.status.lockControl &&
Math.max(core.status.hero.hp, 1) <= (core.status.checkBlock.damage[nx + "," + ny]||0) && arrays.eventArray[ny][nx] == 0)
Math.max(core.status.hero.hp, 1) <= ((core.status.checkBlock.damage||{})[nx + "," + ny]||0) && arrays.eventArray[ny][nx] == 0)
return false;
return true;