From 73e5d96ab4f8659fa5c025bca935ecec40fdc143 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 18 Jan 2018 03:01:46 +0800 Subject: [PATCH] View Maps --- libs/core.js | 14 ++++++++++++ libs/data.js | 1 + libs/events.js | 59 ++++++++++++++++++++++++++++++++++++++++++++------ libs/ui.js | 39 +++++++++++++++++++++++++++++---- 4 files changed, 102 insertions(+), 11 deletions(-) diff --git a/libs/core.js b/libs/core.js index 67b33586..76eb3636 100644 --- a/libs/core.js +++ b/libs/core.js @@ -653,6 +653,10 @@ core.prototype.keyDown = function(keyCode) { core.events.keyDownFly(keyCode); return; } + if (core.status.event.id == 'viewMaps') { + core.events.keyDownViewMaps(keyCode); + return; + } if (core.status.event.id=='shop') { core.events.keyDownShop(keyCode); return; @@ -764,6 +768,10 @@ core.prototype.keyUp = function(keyCode) { core.events.keyUpFly(keyCode); return; } + if (core.status.event.id == 'viewMaps') { + core.events.keyUpViewMaps(keyCode); + return; + } if (core.status.event.id=='shop') { core.events.keyUpShop(keyCode); return; @@ -1052,6 +1060,12 @@ core.prototype.onclick = function (x, y, stepPostfix) { return; } + // 查看地图 + if (core.status.event.id == 'viewMaps') { + core.events.clickViewMaps(x,y); + return; + } + // 开关 if (core.status.event.id == 'switchs') { core.events.clickSwitchs(x,y); diff --git a/libs/data.js b/libs/data.js index bef69f52..91b7dc40 100644 --- a/libs/data.js +++ b/libs/data.js @@ -168,6 +168,7 @@ data.prototype.init = function() { "displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关 "enableGentleClick": true, // 是否允许轻触(获得面前物品) "potionWhileRouting": false, // 寻路算法是否经过血瓶;如果该项为false,则寻路算法会自动尽量绕过血瓶 + "enableViewMaps": true, // 是否支持在菜单栏中查看所有楼层的地图 } } diff --git a/libs/events.js b/libs/events.js index 635898a3..696177ae 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1048,6 +1048,38 @@ events.prototype.keyUpFly = function (keycode) { return; } +////// 查看地图界面时的点击操作 ////// +events.prototype.clickViewMaps = function (x,y) { + if(y<=4) { + core.ui.drawMaps(core.status.event.data+1); + } + else if (y>=8) { + core.ui.drawMaps(core.status.event.data-1); + } + else { + core.clearMap('data', 0, 0, 416, 416); + core.ui.closePanel(); + } +} + +////// 查看地图界面时,按下某个键的操作 ////// +events.prototype.keyDownViewMaps = function (keycode) { + if (keycode==37 || keycode==38) core.ui.drawMaps(core.status.event.data+1); + else if (keycode==39 || keycode==40) core.ui.drawMaps(core.status.event.data-1); + return; +} + +////// 查看地图界面时,放开某个键的操作 ////// +events.prototype.keyUpViewMaps = function (keycode) { + if (keycode==71 || keycode==27 || keycode==88) { + core.clearMap('data', 0, 0, 416, 416); + core.ui.closePanel(); + } + return; +} + + + ////// 商店界面时的点击操作 ////// events.prototype.clickShop = function(x,y) { var shop = core.status.event.data.shop; @@ -1414,7 +1446,7 @@ events.prototype.keyUpSL = function (keycode) { events.prototype.clickSwitchs = function (x,y) { if (x<5 || x>7) return; var choices = [ - "背景音乐", "背景音效", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单" + "背景音乐", "背景音效", "战斗动画", "怪物显伤", "领域显伤", "下载离线版本", "返回主菜单" ]; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y7) return; var choices = [ - "系统设置", "快捷商店", "同步存档", "重新开始", "数据统计", "操作帮助", "关于本塔", "返回游戏" + "系统设置", "快捷商店", "浏览地图", "同步存档", "重新开始", "数据统计", "操作帮助", "关于本塔", "返回游戏" ]; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y=core.floorIds.length) index=core.floorIds.length-1; + + core.lockControl(); + core.status.event.id = 'viewMaps'; + core.status.event.data = index; + + var floorId = core.floorIds[index]; + + clearTimeout(core.interval.tipAnimate); + + core.clearMap('ui', 0, 0, 416, 416); + core.setAlpha('ui', 1); + this.drawThumbnail(floorId, 'ui', core.status.maps[floorId].blocks, 0, 0, 416); + + core.clearMap('data', 0, 0, 416, 416); + core.setOpacity('data', 0.2); + core.canvas.data.textAlign = 'left'; + + var text = core.floors[floorId].title; + var textX = 16, textY = 18, width = textX + core.canvas.data.measureText(text).width + 16, height = 42; + core.fillRect('data', 5, 5, width, height, '#000'); + core.setOpacity('data', 0.5); + core.fillText('data', text, textX + 5, textY + 15, '#fff', '16px Arial'); + +} + ////// 绘制道具栏 ////// ui.prototype.drawToolbox = function(index) {