From 050138f486a303c1444b2f6e2ca286331fb61608 Mon Sep 17 00:00:00 2001 From: echo Date: Sun, 17 Dec 2017 16:35:03 +0800 Subject: [PATCH] core: add arrow block --- README.md | 2 +- libs/core.js | 17 ++++++++++++++++- libs/maps.js | 6 +++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 452775e4..ba7776ea 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! HTML5魔塔交流群群号: `539113091` -如有其它意见或建议,也可以通过发issues、或邮件至[ckcz123.com](mailto:ckcz123.com)联系我。 +如有其它意见或建议,也可以通过发[issues](https://github.com/ckcz123/mota-js/issues)、或邮件至[ckcz123.com](mailto:ckcz123.com)联系我。 diff --git a/libs/core.js b/libs/core.js index 82d7ddd6..0f2df930 100644 --- a/libs/core.js +++ b/libs/core.js @@ -878,10 +878,25 @@ core.prototype.automaticRoute = function (destX, destY) { var nowX = parseInt(f / 13), nowY = f % 13; for (var direction in scan) { - + var nowArrow, nowId, nowBlock = core.getBlock(nowX,nowX); + if (nowBlock!=null){ + nowId = nowBlock.block.event.id; + nowArrow = nowId.slice(5).toLowerCase(); + if (direction != nowArrow) continue; + } + var nx = nowX + scan[direction].x; var ny = nowY + scan[direction].y; + if (nx<0 || nx>12 || ny<0 || ny>12) continue; + + var nextId, nextArrow, nextBlock = core.getBlock(nx,ny); + if (nextBlock!=null){ + nextId = nextBlock.block.event.id; + nextArrow = nextId.slice(5).toLowerCase(); + if ( (scan[direction].x + scan[nextArrow].x) == 0 && (scan[direction].y + scan[nextArrow].y) == 0 ) continue; + } + var nid = 13 * nx + ny; if (core.isset(route[nid])) continue; diff --git a/libs/maps.js b/libs/maps.js index 5a929f2f..e26c277a 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -78,7 +78,11 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 12) tmp.event = {'cls': 'animates', 'id': 'poisonNet', 'noPass': false, 'trigger': 'passNet'}; // 毒网 if (id == 13) tmp.event = {'cls': 'animates', 'id': 'weakNet', 'noPass': false, 'trigger': 'passNet'}; // 衰网 if (id == 14) tmp.event = {'cls': 'animates', 'id': 'curseNet', 'noPass': false, 'trigger': 'passNet'}; // 咒网 - + // 单向箭头 + if (id == 15) tmp.event = {'cls': 'terrains', 'id': 'arrowUp','noPass': false}; // 上行箭头 + if (id == 16) tmp.event = {'cls': 'terrains', 'id': 'arrowLeft','noPass': false}; // 左行箭头 + if (id == 17) tmp.event = {'cls': 'terrains', 'id': 'arrowDown','noPass': false}; // 下行箭头 + if (id == 18) tmp.event = {'cls': 'terrains', 'id': 'arrowRight','noPass': false}; // 右行箭头 // 21-80 物品 if (id == 21) tmp.event = {'cls': 'items', 'id': 'yellowKey'}; // 黄钥匙 if (id == 22) tmp.event = {'cls': 'items', 'id': 'blueKey'}; // 蓝钥匙