diff --git a/_docs/event.md b/_docs/event.md index eef54da8..aaf97b4a 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -888,6 +888,14 @@ name是可选的,代表目标行走图的文件名。 使用`{"type": "showStatusBar"}`会重新显示状态栏。 +### hideHero:隐藏勇士 + +使用`{"type": "hideHero"}`可以隐藏勇士。 + +### showHero:显示勇士 + +使用`{"type": "showHero"}`会重新显示勇士。 + ### updateEnemys:更新怪物数据 使用 `{"type": "updateEnemys"}` 可以动态修改怪物数据。 diff --git a/_docs/personalization.md b/_docs/personalization.md index e6573e80..d7faa37f 100644 --- a/_docs/personalization.md +++ b/_docs/personalization.md @@ -562,8 +562,6 @@ core.statusBar.speed.innerHTML = core.getFlag('speed', 0); 如果flag:skill不为0,则代表当前处于某个技能开启状态,且状态栏显示flag:skillName值。伤害计算函数中只需要对flag:skill进行处理即可。 -!> 关于魔力上限:样板中默认没有提供status:manamax - ### 状态栏的显示 从V2.5开始,魔力值和技能名的状态栏项目已经被添加,可以直接使用。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index e7001609..79b11511 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -282,6 +282,8 @@ action | update_s | showStatusBar_s | hideStatusBar_s + | showHero_s + | hideHero_s | updateEnemys_s | sleep_s | wait_s @@ -995,6 +997,30 @@ var code = '{"type": "hideStatusBar"'+Bool_0+'},\n'; return code; */; +showHero_s + : '显示勇士' Newline + + +/* showHero_s +tooltip : showHero: 显示勇士 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showHero%3a+%e6%98%be%e7%a4%ba%e5%8b%87%e5%a3%ab +colour : this.soundColor +var code = '{"type": "showHero"},\n'; +return code; +*/; + +hideHero_s + : '隐藏勇士' Newline + + +/* hideHero_s +tooltip : hideHero: 隐藏勇士 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideHero%ef%bc%9a%e9%9a%90%e8%97%8f%e5%8b%87%e5%a3%ab +colour : this.soundColor +var code = '{"type": "hideHero"},\n'; +return code; +*/; + updateEnemys_s : '更新怪物数据' Newline @@ -2598,8 +2624,8 @@ Global_Value_List Global_Flag_List - : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'楼传平面塔模式'|'破墙镐四方向'|'炸弹四方向'|'冰冻徽章四方向'|'铁门不需要钥匙'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'夹击不超伤害值'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'检查控制台' - /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'flyRecordPosition', 'pickaxeFourDirections', 'bombFourDirections', 'snowFourDirections', 'steelDoorWithoutKey', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'betweenAttackMax', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'checkConsole']*/; + : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'楼传平面塔模式'|'破墙镐四方向'|'炸弹四方向'|'冰冻徽章四方向'|'铁门不需要钥匙'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'夹击不超伤害值'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'虚化前景层'|'检查控制台' + /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'flyRecordPosition', 'pickaxeFourDirections', 'bombFourDirections', 'snowFourDirections', 'steelDoorWithoutKey', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'betweenAttackMax', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'blurFg', 'checkConsole']*/; Colour : 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则 @@ -3313,6 +3339,14 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['hideStatusBar_s'].xmlText([ data.toolbox||false,this.next]); break; + case "showHero": + this.next = MotaActionBlocks['showHero_s'].xmlText([ + this.next]); + break; + case "hideHero": + this.next = MotaActionBlocks['hideHero_s'].xmlText([ + this.next]); + break; case "updateEnemys": this.next = MotaActionBlocks['updateEnemys_s'].xmlText([ this.next]); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 4c6d5257..82d3b9f8 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -154,6 +154,8 @@ editor_blockly = function () { MotaActionBlocks['moveViewport_s'].xmlText(), MotaActionBlocks['showStatusBar_s'].xmlText(), MotaActionBlocks['hideStatusBar_s'].xmlText(), + MotaActionBlocks['showHero_s'].xmlText(), + MotaActionBlocks['hideHero_s'].xmlText(), MotaActionBlocks['setCurtain_0_s'].xmlText(), MotaActionBlocks['setCurtain_1_s'].xmlText(), MotaActionBlocks['screenFlash_s'].xmlText(), diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 0748cba5..74237a8f 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -703,6 +703,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_bool": "bool", "_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。" }, + "blurFg": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "是否虚化前景层;如果此项开启,则在游戏中事件层有东西(如宝石等)时虚化前景层。" + }, "checkConsole": { "_leaf": true, "_type": "checkbox", diff --git a/libs/control.js b/libs/control.js index e6d297bc..9a981c78 100644 --- a/libs/control.js +++ b/libs/control.js @@ -772,11 +772,13 @@ control.prototype.drawHero = function (status, offset) { core.clearAutomaticRouteNode(x+dx, y+dy); core.clearMap('hero'); - this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { - core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width, - block.heroIcon.loc * block.height, block.width, block.height, - block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); - }); + if (!core.hasFlag('hideHero')) { + this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { + core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width, + block.heroIcon.loc * block.height, block.width, block.height, + block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); + }); + } core.control.updateViewport(); core.setGameCanvasTranslate('hero', 0, 0); diff --git a/libs/core.js b/libs/core.js index 6cbe83cf..a9e571bc 100644 --- a/libs/core.js +++ b/libs/core.js @@ -277,7 +277,7 @@ core.prototype._init_platform = function () { } }); core.platform.string = core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : ""; - core.platform.supportCopy = document.queryCommandSupported || document.queryCommandSupported("copy"); + core.platform.supportCopy = document.queryCommandSupported && document.queryCommandSupported("copy"); var chrome = /Chrome\/(\d+)\./i.exec(navigator.userAgent); if (chrome && parseInt(chrome[1]) >= 50) core.platform.isChrome = true; core.platform.isSafari = /Safari/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent); diff --git a/libs/events.js b/libs/events.js index b5989364..33315916 100644 --- a/libs/events.js +++ b/libs/events.js @@ -790,7 +790,7 @@ events.prototype.doEvent = function (data, x, y, prefix) { } if (this["_action_" + type]) return this["_action_" + type](data, x, y, prefix); core.insertAction("未知的自定义事件: " + type + "!"); - core.doAction(); + setTimeout(core.doAction); } events.prototype.setEvents = function (list, x, y, callback) { @@ -814,7 +814,7 @@ events.prototype.startEvents = function (list, x, y, callback) { // 停止勇士 core.waitHeroToStop(function () { core.lockControl(); - core.doAction(); + setTimeout(core.doAction); }); } @@ -863,7 +863,7 @@ events.prototype._popEvents = function (current, prefix) { else { core.status.event.data.list.shift(); // remove stack } - core.doAction(); + setTimeout(core.doAction); return true; } return false; @@ -908,7 +908,7 @@ events.prototype.recoverEvents = function (data) { core.status.event.id = 'action'; core.status.event.data = data; setTimeout(function () { - core.doAction(); + setTimeout(core.doAction); }, 30); return true; } @@ -919,7 +919,7 @@ events.prototype.recoverEvents = function (data) { events.prototype.__action_checkReplaying = function () { if (core.isReplaying()) { - core.doAction(); + setTimeout(core.doAction); return true; } return false; @@ -947,7 +947,7 @@ events.prototype.__action_doAsyncFunc = function (isAsync, func) { var parameters = Array.prototype.slice.call(arguments, 2); if (isAsync) { func.apply(this, parameters); - core.doAction(); + setTimeout(core.doAction); } else { func.apply(this, parameters.concat(core.doAction)); @@ -971,7 +971,7 @@ events.prototype._action_scrollText = function (data, x, y, prefix) { } events.prototype._action_comment = function (data, x, y, prefix) { - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setText = function (data, x, y, prefix) { @@ -992,12 +992,12 @@ events.prototype._action_setText = function (data, x, y, prefix) { } }); core.setFlag('textAttribute', core.status.textAttribute); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_tip = function (data, x, y, prefix) { core.drawTip(core.replaceText(data.text), data.icon); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_show = function (data, x, y, prefix) { @@ -1009,7 +1009,7 @@ events.prototype._action_show = function (data, x, y, prefix) { data.loc.forEach(function (t) { core.showBlock(t[0], t[1], data.floorId); }); - core.doAction(); + setTimeout(core.doAction); } } @@ -1025,7 +1025,7 @@ events.prototype._action_hide = function (data, x, y, prefix) { data.loc.forEach(function (t) { core.removeBlock(t[0], t[1], data.floorId) }); - core.doAction(); + setTimeout(core.doAction); } } @@ -1034,7 +1034,7 @@ events.prototype._action_setBlock = function (data, x, y, prefix) { data.loc.forEach(function (t) { core.setBlock(data.number, t[0], t[1], data.floorId); }); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_showFloorImg = function (data, x, y, prefix) { @@ -1058,17 +1058,17 @@ events.prototype._action_setBgFgBlock = function (data, x, y, prefix) { data.loc.forEach(function (t) { core.setBgFgBlock(data.name, data.number, t[0], t[1], data.floorId); }); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_follow = function (data, x, y, prefix) { this.follow(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_unfollow = function (data, x, y, prefix) { this.unfollow(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_animate = function (data, x, y, prefix) { @@ -1085,7 +1085,7 @@ events.prototype._action_setViewport = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, x, y, prefix); core.setViewport(32 * loc[0], 32 * loc[1]); } - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_moveViewport = function (data, x, y, prefix) { @@ -1125,7 +1125,7 @@ events.prototype._action_changePos = function (data, x, y, prefix) { core.setHeroLoc('y', loc[1]); if (data.direction) core.setHeroLoc('direction', data.direction); core.drawHero(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_showImage = function (data, x, y, prefix) { @@ -1149,7 +1149,7 @@ events.prototype._action_hideImage = function (data, x, y, prefix) { events.prototype._action_showGif = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, 0, 0, prefix); this.showGif(data.name, loc[0], loc[1]); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_moveImage = function (data, x, y, prefix) { @@ -1165,12 +1165,12 @@ events.prototype._action_setCurtain = function (data, x, y, prefix) { if (data.async) { core.setCurtain(data.color, data.time); core.setFlag('__color__', data.color || null); - core.doAction(); + setTimeout(core.doAction); } else { core.setCurtain(data.color, data.time, function () { core.setFlag('__color__', data.color || null); - core.doAction(); + setTimeout(core.doAction); }); } } @@ -1184,7 +1184,7 @@ events.prototype._action_setWeather = function (data, x, y, prefix) { if (data.name == 'rain' || data.name == 'snow' || data.name == 'fog') core.setFlag('__weather__', [data.name, data.level]); else core.removeFlag('__weather__'); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_openDoor = function (data, x, y, prefix) { @@ -1195,7 +1195,7 @@ events.prototype._action_openDoor = function (data, x, y, prefix) { } else { core.removeBlock(loc[0], loc[1], floorId); - core.doAction(); + setTimeout(core.doAction); } } @@ -1211,7 +1211,7 @@ events.prototype._action_useItem = function (data, x, y, prefix) { } else { core.drawTip("当前无法使用" + ((core.material.items[data.id] || {}).name || "未知道具")); - core.doAction(); + setTimeout(core.doAction); } } @@ -1221,12 +1221,12 @@ events.prototype._action_openShop = function (data, x, y, prefix) { if (!core.isReplaying()) this.openShop(data.id); if (core.status.event.id == 'action') - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_disableShop = function (data, x, y, prefix) { this.disableQuickShop(data.id); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_battle = function (data, x, y, prefix) { @@ -1252,7 +1252,7 @@ events.prototype._action_trigger = function (data, x, y, prefix) { return; } } - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_insert = function (data, x, y, prefix) { @@ -1277,44 +1277,44 @@ events.prototype._action_insert = function (data, x, y, prefix) { var event = (core.floors[floorId][which]||[])[loc[0] + "," + loc[1]]; if (event) this.insertAction(event.data || event); } - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_playBgm = function (data, x, y, prefix) { core.playBgm(data.name); core.setFlag("__bgm__", data.keep ? data.name : null); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_pauseBgm = function (data, x, y, prefix) { core.pauseBgm(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_resumeBgm = function (data, x, y, prefix) { core.resumeBgm(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_loadBgm = function (data, x, y, prefix) { core.loadBgm(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_freeBgm = function (data, x, y, prefix) { core.freeBgm(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_playSound = function (data, x, y, prefix) { if (data.stop) core.stopSound(); core.playSound(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_stopSound = function (data, x, y, prefix) { core.stopSound(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setVolume = function (data, x, y, prefix) { @@ -1325,7 +1325,7 @@ events.prototype._action_setVolume = function (data, x, y, prefix) { events.prototype._action_setValue = function (data, x, y, prefix) { this.setValue(data.name, data.value, prefix); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setValue2 = function (data, x, y, prefix) { @@ -1334,32 +1334,32 @@ events.prototype._action_setValue2 = function (data, x, y, prefix) { events.prototype._action_addValue = function (data, x, y, prefix) { this.addValue(data.name, data.value, prefix); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setFloor = function (data, x, y, prefix) { this.setFloorInfo(data.name, data.value, data.floorId, prefix); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setGlobalAttribute = function (data, x, y, prefix) { this.setGlobalAttribute(data.name, data.value); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setGlobalValue = function (data, x, y, prefix) { core.values[data.name] = data.value; - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setGlobalFlag = function (data, x, y, prefix) { this.setGlobalFlag(data.name, data.value); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setHeroIcon = function (data, x, y, prefix) { this.setHeroIcon(data.name); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_input = function (data, x, y, prefix) { @@ -1367,7 +1367,7 @@ events.prototype._action_input = function (data, x, y, prefix) { value = Math.abs(parseInt(value) || 0); core.status.route.push("input:" + value); core.setFlag("input", value); - core.doAction(); + setTimeout(core.doAction); }); } @@ -1376,7 +1376,7 @@ events.prototype._action_input2 = function (data, x, y, prefix) { value = value || ""; core.status.route.push("input2:" + core.encodeBase64(value)); core.setFlag("input", value); - core.doAction(); + setTimeout(core.doAction); }); } @@ -1406,7 +1406,7 @@ events.prototype._action_if = function (data, x, y, prefix) { core.events.insertAction(data["true"]) else core.events.insertAction(data["false"]) - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_switch = function (data, x, y, prefix) { @@ -1421,7 +1421,7 @@ events.prototype._action_switch = function (data, x, y, prefix) { } } core.insertAction(list); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_choices = function (data, x, y, prefix) { @@ -1439,7 +1439,7 @@ events.prototype._action_choices = function (data, x, y, prefix) { setTimeout(function () { core.status.route.push("choices:" + index); core.insertAction(data.choices[index].action); - core.doAction(); + setTimeout(core.doAction); }, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed)) } else { @@ -1462,7 +1462,7 @@ events.prototype._action_confirm = function (data, x, y, prefix) { core.status.route.push("choices:" + index); if (index == 0) core.insertAction(data.yes); else core.insertAction(data.no); - core.doAction(); + setTimeout(core.doAction); }, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed)) } else { @@ -1482,19 +1482,19 @@ events.prototype._action_while = function (data, x, y, prefix) { {"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition} ); } - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_dowhile = function (data, x, y, prefix) { core.unshift(core.status.event.data.list, {"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition} ); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_break = function (data, x, y, prefix) { core.status.event.data.list.shift(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_continue = function (data, x, y, prefix) { @@ -1504,7 +1504,7 @@ events.prototype._action_continue = function (data, x, y, prefix) { else { core.status.event.data.list.shift(); } - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_win = function (data, x, y, prefix) { @@ -1529,28 +1529,40 @@ events.prototype._action_function = function (data, x, y, prefix) { main.log(e); } if (!data.async) - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_update = function (data, x, y, prefix) { core.updateStatusBar(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_showStatusBar = function (data, x, y, prefix) { core.showStatusBar(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_hideStatusBar = function (data, x, y, prefix) { core.hideStatusBar(data.toolbox); - core.doAction(); + setTimeout(core.doAction); +} + +events.prototype._action_showHero = function (data, x, y, prefix) { + core.removeFlag('hideHero'); + core.drawHero(); + setTimeout(core.doAction); +} + +events.prototype._action_hideHero = function (data, x, y, prefix) { + core.setFlag('hideHero', true); + core.drawHero(); + setTimeout(core.doAction); } events.prototype._action_updateEnemys = function (data, x, y, prefix) { core.enemys.updateEnemys(); core.updateStatusBar(); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_vibrate = function (data, x, y, prefix) { @@ -1560,7 +1572,7 @@ events.prototype._action_vibrate = function (data, x, y, prefix) { events.prototype._action_sleep = function (data, x, y, prefix) { core.timeout.sleepTimeout = setTimeout(function () { core.timeout.sleepTimeout = null; - core.doAction(); + setTimeout(core.doAction); }, core.isReplaying() ? Math.min(data.time, 20) : data.time); } @@ -1577,7 +1589,7 @@ events.prototype._action_wait = function (data, x, y, prefix) { core.stopReplay(); core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]); } - core.doAction(); + setTimeout(core.doAction); return; } } @@ -1609,7 +1621,7 @@ events.prototype._action_waitAsync = function (data, x, y, prefix) { var test = window.setInterval(function () { if (!core.hasAsync()) { clearInterval(test); - core.doAction(); + setTimeout(core.doAction); } }, 50); } @@ -1618,12 +1630,12 @@ events.prototype._action_revisit = function (data, x, y, prefix) { var block = core.getBlock(x, y); if (block != null && block.block.event.trigger == 'action') this.setEvents(block.block.event.data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_callBook = function (data, x, y, prefix) { if (core.isReplaying() || !core.hasItem('book')) { - core.doAction(); + setTimeout(core.doAction); } else { var e = core.clone(core.status.event.data); @@ -1636,7 +1648,7 @@ events.prototype._action_callBook = function (data, x, y, prefix) { events.prototype._action_callSave = function (data, x, y, prefix) { if (core.isReplaying() || core.hasFlag("__events__")) { core.removeFlag("__events__"); - core.doAction(); + setTimeout(core.doAction); } else { var e = core.clone(core.status.event.data); @@ -1649,7 +1661,7 @@ events.prototype._action_callSave = function (data, x, y, prefix) { events.prototype._action_autoSave = function (data, x, y, prefix) { core.autosave(); if (!data.nohint) core.drawTip("已自动存档"); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_callLoad = function (data, x, y, prefix) { @@ -1662,97 +1674,97 @@ events.prototype._action_callLoad = function (data, x, y, prefix) { events.prototype._action_exit = function (data, x, y, prefix) { this.setEvents([]); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_previewUI = function (data, x, y, prefix) { this.insertAction(data.action); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_clearMap = function (data, x, y, prefix) { core.ui._uievent_clearMap(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_fillText = function (data, x, y, prefix) { core.ui._uievent_fillText(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_fillBoldText = function (data, x, y, prefix) { core.ui._uievent_fillBoldText(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_fillRect = function (data, x, y, prefix) { core.ui._uievent_fillRect(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_fillPolygon = function (data, x, y, prefix) { core.ui._uievent_fillPolygon(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_strokeRect = function (data, x, y, prefix) { core.ui._uievent_strokeRect(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_strokePolygon = function (data, x, y, prefix) { core.ui._uievent_strokePolygon(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_fillCircle = function (data, x, y, prefix) { core.ui._uievent_fillCircle(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_strokeCircle = function (data, x, y, prefix) { core.ui._uievent_strokeCircle(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawLine = function (data, x, y, prefix) { core.ui._uievent_drawLine(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawArrow = function (data, x, y, prefix) { core.ui._uievent_drawArrow(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_setAttribute = function (data, x, y, prefix) { core.ui._uievent_setAttribute(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawImage = function (data, x, y, prefix) { core.ui._uievent_drawImage(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawIcon = function (data, x, y, prefix) { core.ui._uievent_drawIcon(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawSelector = function (data, x, y, prefix) { core.ui._uievent_drawSelector(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawBackground = function (data, x, y, prefix) { core.ui._uievent_drawBackground(data); - core.doAction(); + setTimeout(core.doAction); } events.prototype._action_drawTextContent = function (data, x, y, prefix) { core.ui._uievent_drawTextContent(data); - core.doAction(); + setTimeout(core.doAction); } // ------ 点击状态栏图标所进行的一些操作 ------ // @@ -2036,6 +2048,8 @@ events.prototype.setGlobalFlag = function (name, value) { core.flags[name] = value; core.setFlag("globalFlags", flags); core.resize(); + if (name == 'blurFg') + core.drawMap(); } events.prototype.closeDoor = function (x, y, id, callback) { @@ -2352,6 +2366,7 @@ events.prototype.openShop = function (shopId, needVisited) { if (!core.flags.enableDisabledShop || shop.commonEvent) { if (shop.times == 0) core.drawTip("该项尚未开启"); else core.drawTip("该项已失效"); + core.ui.closePanel(); return; } else { diff --git a/libs/items.js b/libs/items.js index d55066c5..b4770490 100644 --- a/libs/items.js +++ b/libs/items.js @@ -125,10 +125,8 @@ items.prototype._afterUseItem = function (itemId) { if (core.status.hero.items[itemCls][itemId] <= 0) delete core.status.hero.items[itemCls][itemId]; - if (!core.status.event.id) { - core.status.event.data = null; + if (!core.status.event.id) core.status.event.ui = null; - } core.updateStatusBar(); } diff --git a/libs/maps.js b/libs/maps.js index 71f8cf36..e700f469 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -82,6 +82,12 @@ maps.prototype._getNumberById = function (id) { return 0; } +maps.prototype.getBlockByNumber = function (number) { + core.status.number2Block = core.status.number2Block || {}; + if (core.status.number2Block[number] != null) return core.status.number2Block[number]; + return core.status.number2Block[number] = this.initBlock(null, null, number, true); +} + ////// 数字和ID的对应关系 ////// maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { var disable = null; @@ -481,7 +487,7 @@ maps.prototype._canMoveHero_checkCannotInOut = function (number, name, direction } return false; } - return core.inArray((this.initBlock(0, 0, number).event || {})[name], direction); + return core.inArray((this.getBlockByNumber(number).event || {})[name], direction); } ////// 能否瞬间移动 ////// @@ -835,7 +841,7 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) { var arr = this._getBgFgMapArray(name, floorId, true); var eventArr = null; - if (main.mode == 'editor' && name == 'fg' && onMap) { + if (name == 'fg' && onMap && this._drawBgFgMap_shouldBlurFg()) { eventArr = this.getMapArray(floorId); } @@ -860,6 +866,11 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) { core.status.autotileAnimateObjs[name + "map"] = core.clone(arr); } +////// 是否应当存在事件时虚化前景层 ////// +maps.prototype._drawBgFgMap_shouldBlurFg = function () { + return main.mode == 'editor' || core.flags.blurFg; +} + ////// 绘制楼层贴图 ////// maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStatus) { floorId = floorId || core.status.floorId; @@ -938,56 +949,118 @@ maps.prototype._drawFloorImage = function (ctx, name, type, image, offsetX, widt } ////// 绘制Autotile ////// + + maps.prototype._drawAutotile = function (ctx, mapArr, block, size, left, top, status) { - var indexArrs = [ //16种组合的图块索引数组; - // 将autotile分割成48块16*16的小块; 数组索引即对应各个小块 - // +----+----+----+----+----+----+ - [10, 9, 4, 3], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 | - [10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+ - [10, 9, 18, 3], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 | - [10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+ - [10, 43, 4, 3], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 | - [10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+ - [10, 43, 18, 3], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 | - [10, 31, 16, 5], //7 bin:0111 +----+----+----+----+----+----+ - [48, 9, 4, 3], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 | - [48, 9, 4, 13], //9 bin:1001 +----+----+----+----+----+----+ - [36, 9, 30, 3], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 | - [36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+ - [46, 45, 4, 3], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 | - [46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+ - [12, 45, 30, 3], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 | - [20, 23, 38, 41] //15 bin:1111 +----+----+----+----+----+----+ + var xx = block.x, yy = block.y; + var autotile = core.material.images['autotile'][block.event.id]; + status = status || 0; + status %= parseInt(autotile.width / 96); + var done = {}; + var isGrass = function(x,y){ + if(core.maps._drawAutotile_getAutotileAroundId(mapArr[yy][xx],x,y,mapArr)){ + return 1; + }else{ + return 0; + } + } + var iG = []; + [-1,0,1].forEach(function(_x){ + iG[_x] = []; + [-1,0,1].forEach(function(_y){ + iG[_x][_y] = isGrass(xx + _x, yy + _y); + })}); + if(iG[-1][-1] + iG[0][-1] + iG[0][0] + iG[-1][0] == 3 && !iG[-1][-1]){ + this._drawAutotile_render(ctx, xx * size + left, yy * size + top, size, autotile, status, 16); + done[0] = true; + } + if(iG[0][-1] + iG[1][-1] + iG[1][0] + iG[0][0] == 3 && !iG[1][-1]){ + this._drawAutotile_render(ctx, xx * size + left + size/2, yy * size + top, size, autotile, status, 17); + done[1] = true; + } + if(iG[0][0] + iG[1][0] + iG[1][1] + iG[0][1] == 3 && !iG[1][1]){ + this._drawAutotile_render(ctx, xx * size + left+size/2, yy * size + top + size/2, size, autotile, status, 18); + done[3] = true; + } + if(iG[0-1][0] + iG[0][0] + iG[0][1] + iG[-1][1] == 3 && !iG[-1][1]){ + this._drawAutotile_render(ctx, xx * size + left, yy * size + top + size/2, size, autotile, status, 19); + done[2] = true; + } + var _id = iG[0][-1] + 2 * iG[-1][0] + 4 * iG[0][1] + 8 * iG[1][0]; + this._drawAutotile_render(ctx, xx * size, yy * size, size, autotile, status, _id, done); +} + + +maps.prototype._drawAutotile_render = function(canvas, x, y, size, autotile, status, index, done) { + var indexData = [[[96 * status, 0, 32, 32, x, y, size, size],], + [[96 * status, 3 * 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 3 * 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status + 2 * 32, 32, 32, 16, x, y, size, size / 2],[96 * status + 2 * 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status + 2 * 32, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status, 2 * 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 2 * 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status + 2 * 32, 32, 32, 32, x, y, size, size],], + [[96 * status + 2 * 32, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 32, 16, x, y, size, size / 2],[96 * status, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 32, 32, 16, x, y, size, size / 2],[96 * status + 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status + 32, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 32, 32, x, y, size, size],], + [[96 * status, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status + 2 * 32, 0, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32, 16, 16, 16, x, y, size / 2, size / 2],], ]; - - // 开始绘制autotile - var x = block.x, y = block.y; - var pieceIndexs = this._drawAutotile_getAutotileIndexs(x, y, mapArr, indexArrs); - - //修正四个边角的固定搭配 - if (pieceIndexs[0] == 13) { - if (pieceIndexs[1] == 16) pieceIndexs[1] = 14; - if (pieceIndexs[2] == 31) pieceIndexs[2] = 19; - } - if (pieceIndexs[1] == 18) { - if (pieceIndexs[0] == 15) pieceIndexs[0] = 17; - if (pieceIndexs[3] == 36) pieceIndexs[3] = 24; - } - if (pieceIndexs[2] == 43) { - if (pieceIndexs[0] == 25) pieceIndexs[0] = 37; - if (pieceIndexs[3] == 46) pieceIndexs[3] = 44; - } - if (pieceIndexs[3] == 48) { - if (pieceIndexs[1] == 30) pieceIndexs[1] = 42; - if (pieceIndexs[2] == 45) pieceIndexs[2] = 47; - } - for (var i = 0; i < 4; i++) { - var index = pieceIndexs[i]; - var dx = x * size + size / 2 * (i % 2), dy = y * size + size / 2 * (~~(i / 2)); - this._drawAutotile_drawBlockByIndex(ctx, dx + left, dy + top, core.material.images['autotile'][block.event.id], index, size, status); + var data = indexData[index]; + if(index>=16){ // 拐角直接绘制 + canvas.drawImage(autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size/2, size/2); + }else{ // 非拐角要根据是否已经绘制进行切分后绘制 + this._drawAutotile_renderCut(canvas, autotile, x, y, size, data, done); } } +maps.prototype._drawAutotile_renderCut = function(canvas, autotile, x, y, size, data, done){ + var drawData = []; + done = done || {}; + if(data.length == 2){ + var idx = 0; + var cut = 0; + for(var i in data){ + if(data[i][2] % 32){ // 是否纵切 + cut = 0; + } + else if(data[i][3] % 32){ // 是否横切 + cut = 1; + } + if(data[i][0] % 32 || data[i][1] % 32){ // right down + idx = 1; + }else{ // left top + idx = 0; + } + if(cut){ + idx *= 2; + if(!done[idx])drawData[idx] = [data[i][0], data[i][1]]; + if(!done[idx + 1])drawData[idx + 1] = [parseInt(data[i][0]) + 16, data[i][1]]; + }else{ + if(!done[idx])drawData[idx] = [data[i][0], data[i][1]]; + if(!done[idx + 2])drawData[idx + 2] = [data[i][0], parseInt(data[i][1]) + 16]; + } + } + }else{ + if(!done[0])drawData[0] = [data[0][0], data[0][1]]; + if(!done[1])drawData[1] = [data[0][0] + 16, data[0][1]]; + if(!done[2])drawData[2] = [data[0][0], data[0][1] + 16]; + if(!done[3])drawData[3] = [data[0][0] + 16, data[0][1] + 16]; + } + for(var i = 0; i<4; i++){ + var dt = drawData[i];if(!dt)continue; + canvas.drawImage(autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size/2, size/2); + }; +} + + maps.prototype._drawAutotile_drawBlockByIndex = function (ctx, dx, dy, autotileImg, index, size, status) { //index为autotile的图块索引1-48 var sx = 16 * ((index - 1) % 6), sy = 16 * (~~((index - 1) / 6)); @@ -1264,7 +1337,7 @@ maps.prototype.getBlockInfo = function (block) { } if (typeof block == 'number') { // 参数是数字 if (block == 0) return null; - block = this.initBlock(0, 0, block, true); + block = this.getBlockByNumber(block); } var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name, image = null, posX = 0, posY = 0, animate = block.event.animate, @@ -1300,7 +1373,7 @@ maps.prototype.getBlockInfo = function (block) { ////// 搜索某个图块出现的所有位置 ////// maps.prototype.searchBlock = function (id, floorId, showDisable) { - if (typeof id == 'number') id = this.initBlock(0, 0, id).event.id; + if (typeof id == 'number') id = this.getBlockByNumber(id).event.id; floorId = floorId || core.status.floorId; var result = []; if (floorId instanceof Array) { @@ -1543,7 +1616,7 @@ maps.prototype.replaceBlock = function (fromNumber, toNumber, floorId) { }); return; } - var toBlock = this.initBlock(0, 0, toNumber, true); + var toBlock = this.getBlockByNumber(toNumber, true); core.status.maps[floorId].blocks.forEach(function (block) { if (block.id == fromNumber) { block.id = toNumber; diff --git a/libs/utils.js b/libs/utils.js index 6c99e3bb..9fa75957 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -941,7 +941,7 @@ utils.prototype.myprompt = function (hint, value, callback) { ////// 动画显示某对象 ////// utils.prototype.showWithAnimate = function (obj, speed, callback) { obj.style.display = 'block'; - if (!speed && main.mode != 'play') { + if (!speed || main.mode != 'play') { obj.style.opacity = 1; if (callback) callback(); return; @@ -1093,7 +1093,7 @@ utils.prototype._export = function (floorIds) { content += arr.map(function (x) { // check monster x.forEach(function (t) { - var block = core.maps.initBlock(null, null, t); + var block = core.maps.getBlockByNumber(t); if (block.event.cls.indexOf("enemy") == 0) { monsterMap[t] = block.event.id; } diff --git a/project/data.js b/project/data.js index f8ec9780..247584ff 100644 --- a/project/data.js +++ b/project/data.js @@ -420,6 +420,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "enableMoveDirectly": true, "enableDisabledShop": true, "disableShopOnDamage": false, + "blurFg": false, "checkConsole": false } } \ No newline at end of file diff --git a/project/functions.js b/project/functions.js index 774e6b9e..f09b5bda 100644 --- a/project/functions.js +++ b/project/functions.js @@ -188,7 +188,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var fromId = core.status.floorId; // 检查能否飞行 - if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo) { + if (!core.status.maps[fromId].canFlyTo || !core.status.maps[toId].canFlyTo || !core.hasVisitedFloor(toId)) { core.drawTip("无法飞往" + core.status.maps[toId].title + "!"); return false; }