From da771dae91250e92b08d4909ee895bf3214c5d25 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 14 Nov 2022 17:11:23 +0800 Subject: [PATCH] =?UTF-8?q?ui=E6=8E=A7=E5=88=B6=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 1 - components.d.ts | 14 + idea.md | 46 + package.json | 1 + pnpm-lock.yaml | 6 + public/main.js | 803 ++-- public/project/functions.js | 1997 ++++++--- public/project/plugins.js | 6273 ++++++++++++++++++---------- public/想法.md | 46 - src/App.vue | 35 +- src/components/bookOne.vue | 0 src/components/boxAnimate.vue | 0 src/components/scroll.vue | 154 + src/initPlugin.ts | 5 +- src/main.ts | 1 + src/plugin/{template.ts => pop.ts} | 0 src/plugin/uiController.ts | 46 + src/plugin/use.ts | 57 + src/styles.less | 10 + src/types/core.d.ts | 14 +- src/types/plugin.d.ts | 37 + src/ui/book.vue | 20 + src/ui/bookDetail.vue | 7 + 23 files changed, 6559 insertions(+), 3014 deletions(-) create mode 100644 components.d.ts create mode 100644 idea.md delete mode 100644 public/想法.md create mode 100644 src/components/bookOne.vue create mode 100644 src/components/boxAnimate.vue create mode 100644 src/components/scroll.vue rename src/plugin/{template.ts => pop.ts} (100%) create mode 100644 src/plugin/uiController.ts create mode 100644 src/plugin/use.ts create mode 100644 src/styles.less create mode 100644 src/ui/book.vue create mode 100644 src/ui/bookDetail.vue diff --git a/.prettierignore b/.prettierignore index e5def26..fc61e63 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1 @@ vite.config.ts -*.js \ No newline at end of file diff --git a/components.d.ts b/components.d.ts new file mode 100644 index 0000000..a43197b --- /dev/null +++ b/components.d.ts @@ -0,0 +1,14 @@ +// generated by unplugin-vue-components +// We suggest you to commit this file into source control +// Read more: https://github.com/vuejs/core/pull/3399 +import '@vue/runtime-core' + +export {} + +declare module '@vue/runtime-core' { + export interface GlobalComponents { + BookOne: typeof import('./src/components/bookOne.vue')['default'] + BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default'] + Scroll: typeof import('./src/components/scroll.vue')['default'] + } +} diff --git a/idea.md b/idea.md new file mode 100644 index 0000000..c144200 --- /dev/null +++ b/idea.md @@ -0,0 +1,46 @@ +## 怪物 + +### 第二章 智慧 + +- 怪物拥有火、水等属性,在不同天气下属性不同 + +- 同化 +- 同化+阻击 +- 电摇嘲讽:到同行或同列直接怼过去,门和墙撞碎,不消耗钥匙,攻击怪物,捡道具,改变 bgm,可吃补给用 +- 抢夺:抢夺你的装备并使用(简单难度中,怪物使用时属性降低) +- 抢夺 2.0:抢夺你的道具(怪物手册和楼传除外),并按照左上、右上、右下、左下的顺序依次放到地图的四角(简单无效) +- 抢夺 3.0:抢夺装备,但每过 10 回合便按照 2.0 方法扔至地图四角(因为怪物觉得装备不好使),然后重新抢夺你的装备(简单无效) +- 天气之子:控制天气,包括下雨、下雪、晴天、阴天等, + +#### Boss + +音游,音乐为一个被遗忘的夜晚,可选简单与困难,困难可获得成就冰与火之舞 + +玩法:一个会转动的圆盘,带有一个伸出去的把手,boss 从四面八方射子弹,当子弹恰好落到把手前端时,点击按键或屏幕,可以抵挡子弹,简单难度 3 条命,困难 1 条。简单难度音符密度低。困难难度为冰与火之舞的节奏。简单难度判定时间为前后各 150ms,困难为 75ms + +## 主角 + +- 反抢夺:1 级反 1.0,2 级反 2.0,3 级反 3.0,用智慧点点 +- 学习:学习选定怪物的选定技能(不能学光环),消耗智慧点,初始 400,但每次消耗点数+100,持续 3 场战斗 +- 铸剑为盾:主动技能,减少攻击,增加防御 +- 血之代偿:消耗一定血量,战前对怪物造成同等数值的伤害 + +## 机制 + +### 通用 + +- 实时天气 +- 成就系统 +- 装备合成、装备(孔)强化 + +### 第二章 智慧 + +- 按下一个开关,所有红门变黄门,黄门变蓝门,蓝门变红门 + +## 成就 + +- 学坏了:学习电摇嘲讽 +- 我就是傻子:不学习反抢夺通过第二章 +- 真能刷:勇气之路的刷血怪刷到 15w 以上的血 +- 满腹经纶:把所有怪物技能都学一遍 +- 冰与火之舞:通过第二章特殊战的困难难度 diff --git a/package.json b/package.json index 15e6e15..5e6c3a8 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "axios": "^1.1.3", "lodash": "^4.17.21", "lz-string": "^1.4.4", + "mutate-animate": "^0.1.0", "vue": "^3.2.41" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d922c44..0eea5c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,7 @@ specifiers: less: ^4.1.3 lodash: ^4.17.21 lz-string: ^1.4.4 + mutate-animate: ^0.1.0 terser: ^5.15.1 ts-node: ^10.9.1 typescript: ^4.6.4 @@ -32,6 +33,7 @@ dependencies: axios: 1.1.3 lodash: 4.17.21 lz-string: 1.4.4 + mutate-animate: 0.1.0 vue: 3.2.45 devDependencies: @@ -2112,6 +2114,10 @@ packages: resolution: {integrity: sha512-Tr1knR3d2mKvvWthlk7202rywKbiOm4rVFLsfAaSIhJ6dt9o47W4S+JMtWhd/PW9Wrdew2/S2fSvhz3E2gkfEg==} dev: true + /mutate-animate/0.1.0: + resolution: {integrity: sha512-XOdyX/PDFYZDpUpaqPeLOfdeDYXQcThWsuLUQpp3z6FbReDV23jIN0Vzv5QLUy+6CDMHEBZHfsumODrlKJva+g==} + dev: false + /nan/2.17.0: resolution: {integrity: sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==} dev: true diff --git a/public/main.js b/public/main.js index ff6da6a..80be0b1 100644 --- a/public/main.js +++ b/public/main.js @@ -1,9 +1,7 @@ -/// -function main () { - +function main() { //------------------------ 用户修改内容 ------------------------// - this.version = "2.10.0"; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。 + this.version = '2.10.0'; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。 this.useCompress = false; // 是否使用压缩文件 // 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。 @@ -11,7 +9,7 @@ function main () { // 如果要进行剧本的修改请务必将其改成false。 this.bgmRemote = false; // 是否采用远程BGM - this.bgmRemoteRoot = "https://h5mota.com/music/"; // 远程BGM的根目录 + this.bgmRemoteRoot = 'https://h5mota.com/music/'; // 远程BGM的根目录 this.isCompetition = false; // 是否是比赛模式 @@ -21,181 +19,210 @@ function main () { //------------------------ 用户修改内容 END ------------------------// this.dom = { - 'body': document.body, - 'gameGroup': document.getElementById('gameGroup'), - 'mainTips': document.getElementById('mainTips'), - 'musicBtn': document.getElementById('musicBtn'), - 'enlargeBtn': document.createElement('img'), - 'startPanel': document.getElementById('startPanel'), - 'startTop': document.getElementById('startTop'), - 'startTopProgressBar': document.getElementById('startTopProgressBar'), - 'startTopProgress': document.getElementById('startTopProgress'), - 'startTopLoadTips': document.getElementById('startTopLoadTips'), - 'startBackground': document.getElementById('startBackground'), - 'startLogo': document.getElementById('startLogo'), - 'startButtonGroup': document.getElementById('startButtonGroup'), - 'floorMsgGroup': document.getElementById('floorMsgGroup'), - 'logoLabel': document.getElementById('logoLabel'), - 'versionLabel': document.getElementById('versionLabel'), - 'floorNameLabel': document.getElementById('floorNameLabel'), - 'statusBar': document.getElementById('statusBar'), - 'status': document.getElementsByClassName('status'), - 'toolBar': document.getElementById('toolBar'), - 'tools': document.getElementsByClassName('tools'), - 'gameCanvas': document.getElementsByClassName('gameCanvas'), - 'gif': document.getElementById('gif'), - 'gif2': document.getElementById('gif2'), - 'gameDraw': document.getElementById('gameDraw'), - 'startButtons': document.getElementById('startButtons'), - 'playGame': document.getElementById('playGame'), - 'loadGame': document.getElementById('loadGame'), - 'replayGame': document.getElementById('replayGame'), - 'levelChooseButtons': document.getElementById('levelChooseButtons'), - 'data': document.getElementById('data'), - 'statusLabels': document.getElementsByClassName('statusLabel'), - 'statusTexts': document.getElementsByClassName('statusText'), - 'floorCol': document.getElementById('floorCol'), - 'nameCol': document.getElementById('nameCol'), - 'lvCol': document.getElementById('lvCol'), - 'hpmaxCol': document.getElementById('hpmaxCol'), - 'hpCol': document.getElementById('hpCol'), - 'manaCol': document.getElementById('manaCol'), - 'atkCol': document.getElementById('atkCol'), - 'defCol': document.getElementById('defCol'), - 'mdefCol': document.getElementById('mdefCol'), - 'moneyCol': document.getElementById('moneyCol'), - 'expCol': document.getElementById('expCol'), - 'upCol': document.getElementById('upCol'), - 'keyCol': document.getElementById('keyCol'), - 'pzfCol': document.getElementById('pzfCol'), - 'debuffCol': document.getElementById('debuffCol'), - 'skillCol': document.getElementById('skillCol'), - 'hard': document.getElementById('hard'), - 'statusCanvas': document.getElementById('statusCanvas'), - 'statusCanvasCtx': document.getElementById('statusCanvas').getContext('2d'), - 'inputDiv': document.getElementById('inputDiv'), - 'inputMessage': document.getElementById('inputMessage'), - 'inputBox': document.getElementById('inputBox'), - 'inputYes': document.getElementById('inputYes'), - 'inputNo': document.getElementById('inputNo'), - 'next': document.getElementById('next') + body: document.body, + gameGroup: document.getElementById('gameGroup'), + mainTips: document.getElementById('mainTips'), + musicBtn: document.getElementById('musicBtn'), + enlargeBtn: document.createElement('img'), + startPanel: document.getElementById('startPanel'), + startTop: document.getElementById('startTop'), + startTopProgressBar: document.getElementById('startTopProgressBar'), + startTopProgress: document.getElementById('startTopProgress'), + startTopLoadTips: document.getElementById('startTopLoadTips'), + startBackground: document.getElementById('startBackground'), + startLogo: document.getElementById('startLogo'), + startButtonGroup: document.getElementById('startButtonGroup'), + floorMsgGroup: document.getElementById('floorMsgGroup'), + logoLabel: document.getElementById('logoLabel'), + versionLabel: document.getElementById('versionLabel'), + floorNameLabel: document.getElementById('floorNameLabel'), + statusBar: document.getElementById('statusBar'), + status: document.getElementsByClassName('status'), + toolBar: document.getElementById('toolBar'), + tools: document.getElementsByClassName('tools'), + gameCanvas: document.getElementsByClassName('gameCanvas'), + gif: document.getElementById('gif'), + gif2: document.getElementById('gif2'), + gameDraw: document.getElementById('gameDraw'), + startButtons: document.getElementById('startButtons'), + playGame: document.getElementById('playGame'), + loadGame: document.getElementById('loadGame'), + replayGame: document.getElementById('replayGame'), + levelChooseButtons: document.getElementById('levelChooseButtons'), + data: document.getElementById('data'), + statusLabels: document.getElementsByClassName('statusLabel'), + statusTexts: document.getElementsByClassName('statusText'), + floorCol: document.getElementById('floorCol'), + nameCol: document.getElementById('nameCol'), + lvCol: document.getElementById('lvCol'), + hpmaxCol: document.getElementById('hpmaxCol'), + hpCol: document.getElementById('hpCol'), + manaCol: document.getElementById('manaCol'), + atkCol: document.getElementById('atkCol'), + defCol: document.getElementById('defCol'), + mdefCol: document.getElementById('mdefCol'), + moneyCol: document.getElementById('moneyCol'), + expCol: document.getElementById('expCol'), + upCol: document.getElementById('upCol'), + keyCol: document.getElementById('keyCol'), + pzfCol: document.getElementById('pzfCol'), + debuffCol: document.getElementById('debuffCol'), + skillCol: document.getElementById('skillCol'), + hard: document.getElementById('hard'), + statusCanvas: document.getElementById('statusCanvas'), + statusCanvasCtx: document + .getElementById('statusCanvas') + .getContext('2d'), + inputDiv: document.getElementById('inputDiv'), + inputMessage: document.getElementById('inputMessage'), + inputBox: document.getElementById('inputBox'), + inputYes: document.getElementById('inputYes'), + inputNo: document.getElementById('inputNo'), + next: document.getElementById('next') }; this.mode = 'play'; this.loadList = [ - 'loader', 'control', 'utils', 'items', 'icons', 'maps', 'enemys', 'events', 'actions', 'data', 'ui', 'extensions', 'core' + 'loader', + 'control', + 'utils', + 'items', + 'icons', + 'maps', + 'enemys', + 'events', + 'actions', + 'data', + 'ui', + 'extensions', + 'core' ]; this.pureData = [ - 'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events', 'plugins' + 'data', + 'enemys', + 'icons', + 'maps', + 'items', + 'functions', + 'events', + 'plugins' ]; this.materials = [ - 'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48', 'icons' + 'animates', + 'enemys', + 'items', + 'npcs', + 'terrains', + 'enemy48', + 'npc48', + 'icons' ]; this.statusBar = { - 'image': { - 'floor': document.getElementById('img-floor'), - 'name': document.getElementById('img-name'), - 'lv': document.getElementById('img-lv'), - 'hpmax': document.getElementById('img-hpmax'), - 'hp': document.getElementById("img-hp"), - 'mana': document.getElementById("img-mana"), - 'atk': document.getElementById("img-atk"), - 'def': document.getElementById("img-def"), - 'mdef': document.getElementById("img-mdef"), - 'money': document.getElementById("img-money"), - 'exp': document.getElementById("img-exp"), - 'up': document.getElementById("img-up"), - 'skill': document.getElementById('img-skill'), - 'book': document.getElementById("img-book"), - 'fly': document.getElementById("img-fly"), - 'toolbox': document.getElementById("img-toolbox"), - 'keyboard': document.getElementById("img-keyboard"), - 'shop': document.getElementById('img-shop'), - 'save': document.getElementById("img-save"), - 'load': document.getElementById("img-load"), - 'settings': document.getElementById("img-settings"), - 'btn1': document.getElementById("img-btn1"), - 'btn2': document.getElementById("img-btn2"), - 'btn3': document.getElementById("img-btn3"), - 'btn4': document.getElementById("img-btn4"), - 'btn5': document.getElementById("img-btn5"), - 'btn6': document.getElementById("img-btn6"), - 'btn7': document.getElementById("img-btn7"), - 'btn8': document.getElementById("img-btn8"), + image: { + floor: document.getElementById('img-floor'), + name: document.getElementById('img-name'), + lv: document.getElementById('img-lv'), + hpmax: document.getElementById('img-hpmax'), + hp: document.getElementById('img-hp'), + mana: document.getElementById('img-mana'), + atk: document.getElementById('img-atk'), + def: document.getElementById('img-def'), + mdef: document.getElementById('img-mdef'), + money: document.getElementById('img-money'), + exp: document.getElementById('img-exp'), + up: document.getElementById('img-up'), + skill: document.getElementById('img-skill'), + book: document.getElementById('img-book'), + fly: document.getElementById('img-fly'), + toolbox: document.getElementById('img-toolbox'), + keyboard: document.getElementById('img-keyboard'), + shop: document.getElementById('img-shop'), + save: document.getElementById('img-save'), + load: document.getElementById('img-load'), + settings: document.getElementById('img-settings'), + btn1: document.getElementById('img-btn1'), + btn2: document.getElementById('img-btn2'), + btn3: document.getElementById('img-btn3'), + btn4: document.getElementById('img-btn4'), + btn5: document.getElementById('img-btn5'), + btn6: document.getElementById('img-btn6'), + btn7: document.getElementById('img-btn7'), + btn8: document.getElementById('img-btn8') }, - 'icons': { - 'floor': 0, - 'name': null, - 'lv': 1, - 'hpmax': 2, - 'hp': 3, - 'atk': 4, - 'def': 5, - 'mdef': 6, - 'money': 7, - 'exp': 8, - 'up': 9, - 'book': 10, - 'fly': 11, - 'toolbox': 12, - 'keyboard': 13, - 'shop': 14, - 'save': 15, - 'load': 16, - 'settings': 17, - 'play': 18, - 'pause': 19, - 'stop': 20, - 'speedDown': 21, - 'speedUp': 22, - 'rewind': 23, - 'equipbox': 24, - 'mana': 25, - 'skill': 26, - 'btn1': 27, - 'btn2': 28, - 'btn3': 29, - 'btn4': 30, - 'btn5': 31, - 'btn6': 32, - 'btn7': 33, - 'btn8': 34 + icons: { + floor: 0, + name: null, + lv: 1, + hpmax: 2, + hp: 3, + atk: 4, + def: 5, + mdef: 6, + money: 7, + exp: 8, + up: 9, + book: 10, + fly: 11, + toolbox: 12, + keyboard: 13, + shop: 14, + save: 15, + load: 16, + settings: 17, + play: 18, + pause: 19, + stop: 20, + speedDown: 21, + speedUp: 22, + rewind: 23, + equipbox: 24, + mana: 25, + skill: 26, + btn1: 27, + btn2: 28, + btn3: 29, + btn4: 30, + btn5: 31, + btn6: 32, + btn7: 33, + btn8: 34 }, - 'floor': document.getElementById('floor'), - 'name': document.getElementById('name'), - 'lv': document.getElementById('lv'), - 'hpmax': document.getElementById('hpmax'), - 'hp': document.getElementById('hp'), - 'mana': document.getElementById('mana'), - 'atk': document.getElementById('atk'), - 'def': document.getElementById("def"), - 'mdef': document.getElementById('mdef'), - 'money': document.getElementById("money"), - 'exp': document.getElementById("exp"), - 'up': document.getElementById('up'), - 'skill': document.getElementById('skill'), - 'yellowKey': document.getElementById("yellowKey"), - 'blueKey': document.getElementById("blueKey"), - 'redKey': document.getElementById("redKey"), - 'greenKey': document.getElementById("greenKey"), - 'poison': document.getElementById('poison'), - 'weak': document.getElementById('weak'), - 'curse': document.getElementById('curse'), - 'pickaxe': document.getElementById('pickaxe'), - 'bomb': document.getElementById('bomb'), - 'fly': document.getElementById('fly'), - 'hard': document.getElementById("hard") - } - this.floors = {} + floor: document.getElementById('floor'), + name: document.getElementById('name'), + lv: document.getElementById('lv'), + hpmax: document.getElementById('hpmax'), + hp: document.getElementById('hp'), + mana: document.getElementById('mana'), + atk: document.getElementById('atk'), + def: document.getElementById('def'), + mdef: document.getElementById('mdef'), + money: document.getElementById('money'), + exp: document.getElementById('exp'), + up: document.getElementById('up'), + skill: document.getElementById('skill'), + yellowKey: document.getElementById('yellowKey'), + blueKey: document.getElementById('blueKey'), + redKey: document.getElementById('redKey'), + greenKey: document.getElementById('greenKey'), + poison: document.getElementById('poison'), + weak: document.getElementById('weak'), + curse: document.getElementById('curse'), + pickaxe: document.getElementById('pickaxe'), + bomb: document.getElementById('bomb'), + fly: document.getElementById('fly'), + hard: document.getElementById('hard') + }; + this.floors = {}; this.canvas = {}; - this.__VERSION__ = "2.10.0"; + this.__VERSION__ = '2.10.0'; this.__VERSION_CODE__ = 510; } main.prototype.init = function (mode, callback) { for (var i = 0; i < main.dom.gameCanvas.length; i++) { - main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d'); + main.canvas[main.dom.gameCanvas[i].id] = + main.dom.gameCanvas[i].getContext('2d'); } main.mode = mode; @@ -213,7 +240,7 @@ main.prototype.init = function (mode, callback) { (function (span, str_) { span.onclick = function () { core.events.startGame(str_); - } + }; })(span, value.name || ''); main.dom.levelChooseButtons.appendChild(span); }); @@ -231,44 +258,73 @@ main.prototype.init = function (mode, callback) { main.loadFloors(function () { var coreData = {}; - ["dom", "statusBar", "canvas", "images", "tilesets", "materials", - "animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) { - coreData[t] = main[t]; - }) + [ + 'dom', + 'statusBar', + 'canvas', + 'images', + 'tilesets', + 'materials', + 'animates', + 'bgms', + 'sounds', + 'floorIds', + 'floors', + 'floorPartitions' + ].forEach(function (t) { + coreData[t] = main[t]; + }); main.core.init(coreData, callback); main.core.resize(); // 自动放缩最大化 - if (!data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.flags.autoScale) core.setLocalStorage('autoScale', false) + if (!data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.flags.autoScale) + core.setLocalStorage('autoScale', false); else core.setLocalStorage('autoScale', true); - if (core.getLocalStorage('autoScale') && !core.domStyle.isVertical) { + if ( + core.getLocalStorage('autoScale') && + !core.domStyle.isVertical + ) { try { if (main.core) { - var index = main.core.domStyle.availableScale.indexOf(core.domStyle.scale); - main.core.control.setDisplayScale(main.core.domStyle.availableScale.length - 1 - index); - if (!main.core.isPlaying() && main.core.flags.enableHDCanvas) { - main.core.domStyle.ratio = Math.max(window.devicePixelRatio || 1, main.core.domStyle.scale); + var index = + main.core.domStyle.availableScale.indexOf( + core.domStyle.scale + ); + main.core.control.setDisplayScale( + main.core.domStyle.availableScale.length - + 1 - + index + ); + if ( + !main.core.isPlaying() && + main.core.flags.enableHDCanvas + ) { + main.core.domStyle.ratio = Math.max( + window.devicePixelRatio || 1, + main.core.domStyle.scale + ); main.core.resize(); } } - } catch (e) { console.error(e) }; + } catch (e) { + console.error(e); + } } }); }); }); -} +}; ////// 动态加载所有核心JS文件 ////// main.prototype.loadJs = function (dir, loadList, callback) { - // 加载js - main.setMainTipsText('正在加载核心js文件...') + main.setMainTipsText('正在加载核心js文件...'); if (this.useCompress) { main.loadMod(dir, dir, function () { callback(); - }) - } - else { + }); + } else { var instanceNum = 0; for (var i = 0; i < loadList.length; i++) { main.loadMod(dir, loadList[i], function (modName) { @@ -280,57 +336,75 @@ main.prototype.loadJs = function (dir, loadList, callback) { }); } } -} +}; ////// 加载某一个JS文件 ////// main.prototype.loadMod = function (dir, modName, callback, onerror) { var script = document.createElement('script'); var name = modName; - script.src = dir + '/' + modName + (this.useCompress ? ".min" : "") + '.js?v=' + this.version; + script.src = + dir + + '/' + + modName + + (this.useCompress ? '.min' : '') + + '.js?v=' + + this.version; script.onload = function () { callback(name); - } + }; main.dom.body.appendChild(script); -} +}; ////// 动态加载所有楼层(剧本) ////// main.prototype.loadFloors = function (callback) { - // 加载js - main.setMainTipsText('正在加载楼层文件...') - if (this.useCompress) { // 读取压缩文件 + main.setMainTipsText('正在加载楼层文件...'); + if (this.useCompress) { + // 读取压缩文件 var script = document.createElement('script'); script.src = 'project/floors.min.js?v=' + this.version; main.dom.body.appendChild(script); script.onload = function () { main.dom.mainTips.style.display = 'none'; callback(); - } + }; return; } // 高层塔优化 var script = document.createElement('script'); - script.src = '__all_floors__.js?v=' + this.version + '&id=' + main.floorIds.join(','); + script.src = + '__all_floors__.js?v=' + + this.version + + '&id=' + + main.floorIds.join(','); script.onload = function () { main.dom.mainTips.style.display = 'none'; main.supportBunch = true; callback(); - } - script.onerror = script.onabort = script.ontimeout = function (e) { - // console.clear(); - for (var i = 0; i < main.floorIds.length; i++) { - main.loadFloor(main.floorIds[i], function (modName) { - main.setMainTipsText("楼层 " + modName + '.js 加载完毕'); - if (Object.keys(main.floors).length === main.floorIds.length) { - main.dom.mainTips.style.display = 'none'; - callback(); + }; + script.onerror = + script.onabort = + script.ontimeout = + function (e) { + // console.clear(); + for (var i = 0; i < main.floorIds.length; i++) { + main.loadFloor(main.floorIds[i], function (modName) { + main.setMainTipsText( + '楼层 ' + modName + '.js 加载完毕' + ); + if ( + Object.keys(main.floors).length === + main.floorIds.length + ) { + main.dom.mainTips.style.display = 'none'; + callback(); + } + }); } - }); - } - } + }; main.dom.body.appendChild(script); -} +}; ////// 加载某一个楼层 ////// main.prototype.loadFloor = function (floorId, callback) { @@ -339,69 +413,78 @@ main.prototype.loadFloor = function (floorId, callback) { main.dom.body.appendChild(script); script.onload = function () { callback(floorId); - } -} + }; +}; ////// 加载过程提示 ////// main.prototype.setMainTipsText = function (text) { main.dom.mainTips.innerHTML = text; -} +}; main.prototype.log = function (e, error) { if (e) { if (error) return console.error(e); if (main.core && main.core.platform && !main.core.platform.isPC) { - console.log((e.stack || e.toString())); - } - else { + console.log(e.stack || e.toString()); + } else { console.log(e); } } -} +}; main.prototype.createOnChoiceAnimation = function () { - var borderColor = main.dom.startButtonGroup.style.caretColor || "rgb(255, 215, 0)"; + var borderColor = + main.dom.startButtonGroup.style.caretColor || 'rgb(255, 215, 0)'; // get rgb value - var rgb = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+\s*)?\)$/.exec(borderColor); + var rgb = + /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+\s*)?\)$/.exec( + borderColor + ); if (rgb != null) { - var value = rgb[1] + ", " + rgb[2] + ", " + rgb[3]; - var style = document.createElement("style"); + var value = rgb[1] + ', ' + rgb[2] + ', ' + rgb[3]; + var style = document.createElement('style'); style.type = 'text/css'; - var keyFrames = "onChoice { " + - "0% { border-color: rgba(" + value + ", 0.9); } " + - "50% { border-color: rgba(" + value + ", 0.3); } " + - "100% { border-color: rgba(" + value + ", 0.9); } " + - "}"; - style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames; + var keyFrames = + 'onChoice { ' + + '0% { border-color: rgba(' + + value + + ', 0.9); } ' + + '50% { border-color: rgba(' + + value + + ', 0.3); } ' + + '100% { border-color: rgba(' + + value + + ', 0.9); } ' + + '}'; + style.innerHTML = + '@-webkit-keyframes ' + keyFrames + ' @keyframes ' + keyFrames; document.body.appendChild(style); } -} +}; ////// 选项 ////// main.prototype.selectButton = function (index) { var select = function (children) { index = (index + children.length) % children.length; for (var i = 0; i < children.length; ++i) { - children[i].classList.remove("onChoiceAnimate"); + children[i].classList.remove('onChoiceAnimate'); } - children[index].classList.add("onChoiceAnimate"); + children[index].classList.add('onChoiceAnimate'); if (main.selectedButton == index) { children[index].click(); - } - else { + } else { main.selectedButton = index; } - } + }; if (core.dom.startPanel.style.display != 'block') return; if (main.dom.startButtons.style.display == 'block') { select(main.dom.startButtons.children); - } - else if (main.dom.levelChooseButtons.style.display == 'block') { + } else if (main.dom.levelChooseButtons.style.display == 'block') { select(main.dom.levelChooseButtons.children); } -} +}; ////// 创建字体 ////// main.prototype.importFonts = function (fonts) { @@ -410,44 +493,65 @@ main.prototype.importFonts = function (fonts) { style.type = 'text/css'; var html = ''; fonts.forEach(function (font) { - html += '@font-face { font-family: "' + font + '"; src: url("project/fonts/' + font + '.ttf") format("truetype"); }'; + html += + '@font-face { font-family: "' + + font + + '"; src: url("project/fonts/' + + font + + '.ttf") format("truetype"); }'; }); style.innerHTML = html; document.body.appendChild(style); -} +}; main.prototype.listen = function () { - ////// 窗口大小变化时 ////// window.onresize = function () { try { main.core.resize(); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 在界面上按下某按键时 ////// main.dom.body.onkeydown = function (e) { if (main.editorOpened) return; try { if (main.dom.inputDiv.style.display == 'block') return; - if (main.core && (main.core.isPlaying() || main.core.status.lockControl)) + if ( + main.core && + (main.core.isPlaying() || main.core.status.lockControl) + ) main.core.onkeyDown(e); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 在界面上放开某按键时 ////// main.dom.body.onkeyup = function (e) { if (main.editorOpened) return; try { - if (main.dom.startPanel.style.display == 'block' && - (main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) { - if (e.keyCode == 38 || e.keyCode == 33) // up/pgup + if ( + main.dom.startPanel.style.display == 'block' && + (main.dom.startButtons.style.display == 'block' || + main.dom.levelChooseButtons.style.display == 'block') + ) { + if (e.keyCode == 38 || e.keyCode == 33) + // up/pgup main.selectButton((main.selectedButton || 0) - 1); - else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn + else if (e.keyCode == 40 || e.keyCode == 34) + // down/pgdn main.selectButton((main.selectedButton || 0) + 1); - else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space + else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) + // C/Enter/Space main.selectButton(main.selectedButton); - else if (e.keyCode == 27 && main.dom.levelChooseButtons.style.display == 'block') { // ESC + else if ( + e.keyCode == 27 && + main.dom.levelChooseButtons.style.display == 'block' + ) { + // ESC main.core.showStartAnimate(true); } e.stopPropagation(); @@ -458,34 +562,44 @@ main.prototype.listen = function () { setTimeout(function () { main.dom.inputYes.click(); }, 50); - } - else if (e.keyCode == 27) { + } else if (e.keyCode == 27) { setTimeout(function () { main.dom.inputNo.click(); }, 50); } return; } - if (main.core && main.core.isPlaying && main.core.status && - (main.core.isPlaying() || main.core.status.lockControl)) + if ( + main.core && + main.core.isPlaying && + main.core.status && + (main.core.isPlaying() || main.core.status.lockControl) + ) main.core.onkeyUp(e); - } catch (ee) { console.error(ee) } + } catch (ee) { + console.error(ee); + } }; - [main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) { + [main.dom.startButtons, main.dom.levelChooseButtons].forEach(function ( + dom + ) { dom.onmousemove = function (e) { for (var i = 0; i < dom.children.length; ++i) { - if (dom.children[i] == e.target && i != (main.selectedButton || 0)) { + if ( + dom.children[i] == e.target && + i != (main.selectedButton || 0) + ) { main.selectButton(i); } } - } + }; }); ////// 开始选择时 ////// main.dom.body.onselectstart = function () { return false; - } + }; ////// 鼠标按下时 ////// main.dom.data.onmousedown = function (e) { @@ -494,8 +608,10 @@ main.prototype.listen = function () { var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); if (loc == null) return; main.core.ondown(loc); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 鼠标移动时 ////// main.dom.data.onmousemove = function (e) { @@ -504,8 +620,10 @@ main.prototype.listen = function () { var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); if (loc == null) return; main.core.onmove(loc); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 鼠标放开时 ////// main.dom.data.onmouseup = function (e) { @@ -514,40 +632,52 @@ main.prototype.listen = function () { var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); if (loc == null) return; main.core.onup(loc); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 鼠标滑轮滚动时 ////// main.dom.data.onmousewheel = function (e) { try { - if (e.wheelDelta) - main.core.onmousewheel(Math.sign(e.wheelDelta)) - else if (e.detail) - main.core.onmousewheel(Math.sign(e.detail)); - } catch (ee) { console.error(ee) } - } + if (e.wheelDelta) main.core.onmousewheel(Math.sign(e.wheelDelta)); + else if (e.detail) main.core.onmousewheel(Math.sign(e.detail)); + } catch (ee) { + console.error(ee); + } + }; ////// 手指在触摸屏开始触摸时 ////// main.dom.data.ontouchstart = function (e) { try { e.preventDefault(); - var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var loc = main.core.actions._getClickLoc( + e.targetTouches[0].clientX, + e.targetTouches[0].clientY + ); if (loc == null) return; main.lastTouchLoc = loc; main.core.ondown(loc); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 手指在触摸屏上移动时 ////// main.dom.data.ontouchmove = function (e) { try { e.preventDefault(); - var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var loc = main.core.actions._getClickLoc( + e.targetTouches[0].clientX, + e.targetTouches[0].clientY + ); if (loc == null) return; main.lastTouchLoc = loc; main.core.onmove(loc); - } catch (ee) { console.error(ee) } - } + } catch (ee) { + console.error(ee); + } + }; ////// 手指离开触摸屏时 ////// main.dom.data.ontouchend = function (e) { @@ -560,7 +690,7 @@ main.prototype.listen = function () { } catch (e) { console.error(e); } - } + }; main.dom.statusCanvas.onclick = function (e) { try { @@ -569,7 +699,7 @@ main.prototype.listen = function () { } catch (e) { console.error(e); } - } + }; ////// 点击状态栏中的怪物手册时 ////// main.statusBar.image.book.onclick = function (e) { @@ -580,9 +710,8 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.openBook(true); - } + if (main.core.isPlaying()) main.core.openBook(true); + }; ////// 点击状态栏中的楼层传送器/装备栏时 ////// main.statusBar.image.fly.onclick = function (e) { @@ -597,12 +726,11 @@ main.prototype.listen = function () { if (main.core.isPlaying()) { if (!main.core.flags.equipboxButton) { main.core.useFly(true); - } - else { - main.core.openEquipbox(true) + } else { + main.core.openEquipbox(true); } } - } + }; ////// 点击状态栏中的工具箱时 ////// main.statusBar.image.toolbox.onclick = function (e) { @@ -616,7 +744,7 @@ main.prototype.listen = function () { if (main.core.isPlaying()) { main.core.openToolbox(core.status.event.id != 'equipbox'); } - } + }; ////// 双击状态栏中的工具箱时 ////// main.statusBar.image.toolbox.ondblclick = function (e) { @@ -626,10 +754,8 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.openEquipbox(true); - - } + if (main.core.isPlaying()) main.core.openEquipbox(true); + }; ////// 点击状态栏中的虚拟键盘时 ////// main.statusBar.image.keyboard.onclick = function (e) { @@ -640,9 +766,8 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.openKeyBoard(true); - } + if (main.core.isPlaying()) main.core.openKeyBoard(true); + }; ////// 点击状态栏中的快捷商店时 ////// main.statusBar.image.shop.onclick = function (e) { @@ -653,26 +778,29 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.openQuickShop(true); - } + if (main.core.isPlaying()) main.core.openQuickShop(true); + }; ////// 点击金币时也可以开启快捷商店 ////// main.statusBar.image.money.onclick = function (e) { e.stopPropagation(); - if (main.core.isPlaying()) - main.core.openQuickShop(true); - } + if (main.core.isPlaying()) main.core.openQuickShop(true); + }; ////// 点击楼梯图标也可以浏览地图 ////// main.statusBar.image.floor.onclick = function (e) { e.stopPropagation(); - if (main.core && main.core.isPlaying() && !core.isMoving() && !core.status.lockControl) { + if ( + main.core && + main.core.isPlaying() && + !core.isMoving() && + !core.status.lockControl + ) { core.ui._drawViewMaps(); } - } + }; ////// 点击状态栏中的存档按钮时 ////// main.statusBar.image.save.onclick = function (e) { @@ -683,9 +811,8 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.save(true); - } + if (main.core.isPlaying()) main.core.save(true); + }; ////// 点击状态栏中的读档按钮时 ////// main.statusBar.image.load.onclick = function (e) { @@ -696,9 +823,8 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.load(true); - } + if (main.core.isPlaying()) main.core.load(true); + }; ////// 点击状态栏中的系统菜单时 ////// main.statusBar.image.settings.onclick = function (e) { @@ -709,61 +835,80 @@ main.prototype.listen = function () { return; } - if (main.core.isPlaying()) - main.core.openSettings(true); - } + if (main.core.isPlaying()) main.core.openSettings(true); + }; ////// 点击工具栏时 ////// main.dom.hard.onclick = function () { main.core.control.setToolbarButton(!core.domStyle.toolbarBtn); - } + }; ////// 手机端的按钮1-7 ////// main.statusBar.image.btn1.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 49, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 49, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn2.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 50, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 50, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn3.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 51, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 51, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn4.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 52, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 52, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn5.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 53, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 53, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn6.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 54, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 54, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn7.onclick = function (e) { e.stopPropagation(); - main.core.onkeyUp({ "keyCode": 55, "altKey": core.getLocalStorage('altKey') }); + main.core.onkeyUp({ + keyCode: 55, + altKey: core.getLocalStorage('altKey') + }); }; main.statusBar.image.btn8.onclick = function (e) { e.stopPropagation(); if (core.getLocalStorage('altKey')) { core.removeLocalStorage('altKey'); - core.drawTip("Alt模式已关闭。"); + core.drawTip('Alt模式已关闭。'); main.statusBar.image.btn8.style.filter = ''; - } - else { + } else { core.setLocalStorage('altKey', true); - core.drawTip("Alt模式已开启;此模式下1~7按钮视为Alt+1~7。"); + core.drawTip('Alt模式已开启;此模式下1~7按钮视为Alt+1~7。'); main.statusBar.image.btn8.style.filter = 'sepia(1) contrast(1.5)'; } }; @@ -774,55 +919,55 @@ main.prototype.listen = function () { main.core.control.checkBgm(); if (main.levelChoose.length == 0) { - core.events.startGame(""); + core.events.startGame(''); } else { main.dom.levelChooseButtons.style.display = 'block'; main.selectedButton = null; main.selectButton(0); } - } + }; ////// 点击“载入游戏”时 ////// main.dom.loadGame.onclick = function () { main.core.control.checkBgm(); main.core.load(); - } + }; ////// 点击“录像回放”时 ////// main.dom.replayGame.onclick = function () { main.core.control.checkBgm(); main.core.chooseReplayFile(); - } + }; main.dom.musicBtn.onclick = function () { try { - if (main.core) - main.core.triggerBgm(); - } catch (ee) { console.error(ee) } - } + if (main.core) main.core.triggerBgm(); + } catch (ee) { + console.error(ee); + } + }; window.onblur = function () { if (main.core && main.core.control) { try { main.core.control.checkAutosave(); - } catch (e) { } + } catch (e) {} } - } + }; main.dom.inputYes.onclick = function () { main.dom.inputDiv.style.display = 'none'; var func = core.platform.successCallback; core.platform.successCallback = core.platform.errorCallback = null; if (func) func(main.dom.inputBox.value); - } + }; main.dom.inputNo.onclick = function () { main.dom.inputDiv.style.display = 'none'; var func = core.platform.errorCallback; core.platform.successCallback = core.platform.errorCallback = null; if (func) func(null); - } + }; +}; //listen end -}//listen end - -var main = new main(); \ No newline at end of file +var main = new main(); diff --git a/public/project/functions.js b/public/project/functions.js index 873a7ec..98a5f78 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -1,7 +1,6 @@ -var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = -{ - "events": { - "resetGame": function (hero, hard, floorId, maps, values) { +var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { + events: { + resetGame: function (hero, hard, floorId, maps, values) { // 重置整个游戏;此函数将在游戏开始时,或者每次读档时最先被调用 // hero:勇士信息;hard:难度;floorId:当前楼层ID;maps:地图信息;values:全局数值信息 @@ -20,11 +19,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = window.flags = core.status.hero.flags; core.events.setHeroIcon(core.status.hero.image, true); core.control._initStatistics(core.animateFrame.totalTime); - core.status.hero.statistics.totalTime = core.animateFrame.totalTime = - Math.max(core.status.hero.statistics.totalTime, core.animateFrame.totalTime); + core.status.hero.statistics.totalTime = + core.animateFrame.totalTime = Math.max( + core.status.hero.statistics.totalTime, + core.animateFrame.totalTime + ); core.status.hero.statistics.start = null; // 初始难度 - core.status.hard = hard || ""; + core.status.hard = hard || ''; // 初始化地图 core.status.floorId = floorId; core.status.maps = maps; @@ -34,25 +36,22 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.material.items = core.items.getItems(); // 初始化全局数值和全局开关 core.values = core.clone(core.data.values); - for (var key in values || {}) - core.values[key] = values[key]; + for (var key in values || {}) core.values[key] = values[key]; core.flags = core.clone(core.data.flags); - var globalFlags = core.getFlag("globalFlags", {}); - for (var key in globalFlags) - core.flags[key] = globalFlags[key]; + var globalFlags = core.getFlag('globalFlags', {}); + for (var key in globalFlags) core.flags[key] = globalFlags[key]; core._init_sys_flags(); // 初始化界面,状态栏等 core.resize(); // 状态栏是否显示 if (core.hasFlag('hideStatusBar')) core.hideStatusBar(core.hasFlag('showToolbox')); - else - core.showStatusBar(); + else core.showStatusBar(); // 隐藏右下角的音乐按钮 core.dom.musicBtn.style.display = 'none'; core.dom.enlargeBtn.style.display = 'none'; }, - "win": function (reason, norank, noexit) { + win: function (reason, norank, noexit) { // 游戏获胜事件 // 请注意,成绩统计时是按照hp进行上传并排名 // 可以先在这里对最终分数进行计算,比如将2倍攻击和5倍黄钥匙数量加到分数上 @@ -63,19 +62,22 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.status.extraEvent = core.clone(core.status.event); } flags.cheat = 0; - if (reason != "智慧之始") { + if (reason != '智慧之始') { flags.cheat += 100; } - if (core.status.hero.atk >= 1000 || core.status.hero.def >= 1000) flags.cheat += 50; + if (core.status.hero.atk >= 1000 || core.status.hero.def >= 1000) + flags.cheat += 50; if (flags.cheat >= 30) { while (true) { console.log(Math.pow(Math.random(), Math.random())); } } if (reason == '智慧之始') - core.status.hero.hp += core.itemCount('yellowKey') * 5000 + core.itemCount('blueKey') * 15000; + core.status.hero.hp += + core.itemCount('yellowKey') * 5000 + + core.itemCount('blueKey') * 15000; - // 游戏获胜事件 + // 游戏获胜事件 core.ui.closePanel(); var replaying = core.isReplaying(); if (replaying) core.stopReplay(); @@ -83,30 +85,36 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (!noexit) { core.clearMap('all'); // 清空全地图 core.deleteAllCanvas(); // 删除所有创建的画布 - core.dom.gif2.innerHTML = ""; + core.dom.gif2.innerHTML = ''; } reason = core.replaceText(reason); - core.drawText([ - "\t[" + (reason || "恭喜通关") + "]你的分数是${status:hp}。" - ], function () { - core.events.gameOver(reason || '', replaying, norank); - }) + core.drawText( + [ + '\t[' + + (reason || '恭喜通关') + + ']你的分数是${status:hp}。' + ], + function () { + core.events.gameOver(reason || '', replaying, norank); + } + ); }); }, - "lose": function (reason) { + lose: function (reason) { // 游戏失败事件 core.ui.closePanel(); var replaying = core.isReplaying(); core.stopReplay(); core.waitHeroToStop(function () { - core.drawText([ - "\t[" + (reason || "结局1") + "]你死了。\n如题。" - ], function () { - core.events.gameOver(null, replaying); - }); - }) + core.drawText( + ['\t[' + (reason || '结局1') + ']你死了。\n如题。'], + function () { + core.events.gameOver(null, replaying); + } + ); + }); }, - "changingFloor": function (floorId, heroLoc) { + changingFloor: function (floorId, heroLoc) { // 正在切换楼层过程中执行的操作;此函数的执行时间是“屏幕完全变黑“的那一刻 // floorId为要切换到的楼层ID;heroLoc表示勇士切换到的位置 @@ -115,8 +123,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var fromLoad = core.hasFlag('__fromLoad__'); // 是否是读档造成的切换 var isFlying = core.hasFlag('__isFlying__'); // 是否是楼传造成的切换 if (!fromLoad) { - if (!core.hasFlag("__leaveLoc__")) core.setFlag("__leaveLoc__", {}); - if (currentId != null) core.getFlag("__leaveLoc__")[currentId] = core.clone(core.status.hero.loc); + if (!core.hasFlag('__leaveLoc__')) + core.setFlag('__leaveLoc__', {}); + if (currentId != null) + core.getFlag('__leaveLoc__')[currentId] = core.clone( + core.status.hero.loc + ); } // 根据分区信息自动砍层与恢复 @@ -128,16 +140,24 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = heroLoc.direction = core.turnDirection(heroLoc.direction); core.status.hero.loc = heroLoc; // tower6 - if (floorId == "tower6") { + if (floorId == 'tower6') { core.relocateLoopMap(floorId, heroLoc); } // 检查重生怪并重置 if (!fromLoad) { core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { - if (block.disable && core.enemys.hasSpecial(block.event.id, 23)) { + if ( + block.disable && + core.enemys.hasSpecial(block.event.id, 23) + ) { block.disable = false; - core.setMapBlockDisabled(floorId, block.x, block.y, false); + core.setMapBlockDisabled( + floorId, + block.x, + block.y, + false + ); core.maps._updateMapArray(floorId, block.x, block.y); } }); @@ -146,19 +166,17 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // ---------- 重绘新地图;这一步将会设置core.status.floorId ---------- // core.drawMap(floorId); - if (floorId == "tower6") - core.backgroundImage("tower6.jpeg"); + if (floorId == 'tower6') core.backgroundImage('tower6.jpeg'); else { - core.deleteCanvas("bImage"); - core.deleteCanvas("eImage"); + core.deleteCanvas('bImage'); + core.deleteCanvas('eImage'); } // 切换楼层BGM if (core.status.maps[floorId].bgm) { var bgm = core.status.maps[floorId].bgm; - core.listenBgm(bgm); if (bgm instanceof Array) bgm = bgm[0]; - if (!core.hasFlag("__bgm__")) core.playBgm(bgm); + if (!core.hasFlag('__bgm__')) core.playBgm(bgm); } // if (flags.chase && fromLoad) { // core.startChase(); @@ -169,26 +187,32 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = color = core.status.maps[floorId].color; core.clearMap('curtain'); core.status.curtainColor = color; - if (color) core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(color)); + if (color) + core.fillRect( + 'curtain', + 0, + 0, + core.__PIXELS__, + core.__PIXELS__, + core.arrayToRGBA(color) + ); // 更改天气 var weather = core.getFlag('__weather__', null); if (!weather && core.status.maps[floorId].weather) weather = core.status.maps[floorId].weather; - if (weather) - core.setWeather(weather[0], weather[1]); + if (weather) core.setWeather(weather[0], weather[1]); else core.setWeather(); // ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等 - }, - "afterChangeFloor": function (floorId) { + afterChangeFloor: function (floorId) { // 转换楼层结束的事件;此函数会在整个楼层切换完全结束后再执行 // floorId是切换到的楼层 // 如果是读档,则进行检查(是否需要恢复事件) if (core.hasFlag('__fromLoad__')) { - core.events.recoverEvents(core.getFlag("__events__")); - core.removeFlag("__events__"); + core.events.recoverEvents(core.getFlag('__events__')); + core.removeFlag('__events__'); } else { // 每次抵达楼层执行的事件 core.insertAction(core.floors[floorId].eachArrive); @@ -199,18 +223,22 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.visitFloor(floorId); } } - if (floorId.startsWith("tower")) flags.layer = 0; + if (floorId.startsWith('tower')) flags.layer = 0; }, - "flyTo": function (toId, callback) { + flyTo: function (toId, callback) { // 楼层传送器的使用,从当前楼层飞往toId // 如果不能飞行请返回false var fromId = core.status.floorId; // 检查能否飞行 - if (!core.status.maps[fromId].canFlyFrom || !core.status.maps[toId].canFlyTo || !core.hasVisitedFloor(toId)) { + if ( + !core.status.maps[fromId].canFlyFrom || + !core.status.maps[toId].canFlyTo || + !core.hasVisitedFloor(toId) + ) { core.playSound('操作失败'); - core.drawTip("无法飞往" + core.status.maps[toId].title + "!"); + core.drawTip('无法飞往' + core.status.maps[toId].title + '!'); return false; } @@ -218,50 +246,67 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var stair = null, loc = null; if (core.flags.flyRecordPosition) { - loc = core.getFlag("__leaveLoc__", {})[toId] || null; + loc = core.getFlag('__leaveLoc__', {})[toId] || null; } - 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] }; + 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] + }; } if (loc == null) { // 获得两个楼层的索引,以决定是上楼梯还是下楼梯 var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId); - var stair = fromIndex <= toIndex ? "downFloor" : "upFloor"; + var stair = fromIndex <= toIndex ? 'downFloor' : 'upFloor'; // 地下层:同层传送至上楼梯 - if (fromIndex == toIndex && core.status.maps[fromId].underGround) stair = "upFloor"; + if ( + fromIndex == toIndex && + core.status.maps[fromId].underGround + ) + stair = 'upFloor'; } // 记录录像 - core.status.route.push("fly:" + toId); + core.status.route.push('fly:' + toId); // 传送 core.ui.closePanel(); core.changeFloor(toId, stair, loc, null, callback); return true; }, - "beforeBattle": function (enemyId, x, y) { + beforeBattle: function (enemyId, x, y) { // 战斗前触发的事件,可以加上一些战前特效(详见下面支援的例子) // 此函数在“检测能否战斗和自动存档”【之后】执行。如果需要更早的战前事件,请在插件中覆重写 core.events.doSystemEvent 函数。 // 返回true则将继续战斗,返回false将不再战斗。 // ------ 支援技能 ------ // if (x != null && y != null) { - var index = x + "," + y, + var index = x + ',' + y, cache = core.status.checkBlock.cache[index] || {}, guards = cache.guards || []; // 如果存在支援怪 if (guards.length > 0) { // 记录flag,当前要参与支援的怪物 - core.setFlag("__guards__" + x + "_" + y, guards); - var actions = [{ "type": "playSound", "name": "jump.mp3" }]; + core.setFlag('__guards__' + x + '_' + y, guards); + var actions = [{ type: 'playSound', name: 'jump.mp3' }]; // 增加支援的特效动画(图块跳跃) guards.forEach(function (g) { - core.push(actions, { "type": "jump", "from": [g[0], g[1]], "to": [x, y], "time": 300, "keep": false, "async": true }); + core.push(actions, { + type: 'jump', + from: [g[0], g[1]], + to: [x, y], + time: 300, + keep: false, + async: true + }); }); core.push(actions, [ - { "type": "waitAsync" }, // 等待所有异步事件执行完毕 - { "type": "trigger", "loc": [x, y] } // 重要!重新触发本点事件(即重新触发战斗) + { type: 'waitAsync' }, // 等待所有异步事件执行完毕 + { type: 'trigger', loc: [x, y] } // 重要!重新触发本点事件(即重新触发战斗) ]); core.insertAction(actions); return false; @@ -270,7 +315,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return true; }, - "afterBattle": function (enemyId, x, y) { + afterBattle: function (enemyId, x, y) { // 战斗结束后触发的事件 var enemy = core.material.enemys[enemyId]; @@ -291,10 +336,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.playSound('attack.mp3'); // 播放动画;如果不存在坐标(强制战斗)则播放到勇士自身 - if (x != null && y != null) - core.drawAnimate(animate, x, y); - else - core.drawHeroAnimate(animate); + if (x != null && y != null) core.drawAnimate(animate, x, y); + else core.drawHeroAnimate(animate); // 获得战斗伤害信息 var damageInfo = core.getDamageInfo(enemyId, null, x, y) || {}; @@ -318,15 +361,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 智慧之源 if (core.hasSpecial(special, 14) && flags.hard == 2) { var floorId = core.status.floorId; - core.addFlag("inte_" + floorId, Math.ceil(core.status.hero.mdef / 10 * 0.3) * 10); - core.status.hero.mdef -= Math.ceil(core.status.hero.mdef / 10 * 0.3) * 10; + core.addFlag( + 'inte_' + floorId, + Math.ceil((core.status.hero.mdef / 10) * 0.3) * 10 + ); + core.status.hero.mdef -= + Math.ceil((core.status.hero.mdef / 10) * 0.3) * 10; } // 计算当前怪物的支援怪物 var guards = []; if (x != null && y != null) { - guards = core.getFlag("__guards__" + x + "_" + y, []); - core.removeFlag("__guards__" + x + "_" + y); + guards = core.getFlag('__guards__' + x + '_' + y, []); + core.removeFlag('__guards__' + x + '_' + y); } // 获得金币 @@ -346,44 +393,56 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.status.hero.exp += exp; core.status.hero.statistics.exp += exp; - var hint = "打败 " + enemy.name; - if (core.flags.statusBarItems.indexOf('enableMoney') >= 0) hint += ",金币+" + money; - if (core.flags.statusBarItems.indexOf('enableExp') >= 0) hint += ",经验+" + exp; + var hint = '打败 ' + enemy.name; + if (core.flags.statusBarItems.indexOf('enableMoney') >= 0) + hint += ',金币+' + money; + if (core.flags.statusBarItems.indexOf('enableExp') >= 0) + hint += ',经验+' + exp; core.drawTip(hint, enemy.id); // 战后的技能处理,比如扣除魔力值 if (core.flags.statusBarItems.indexOf('enableSkill') >= 0) { // 检测当前开启的技能类型 var skill = core.getFlag('skill', 0); - if (skill == 1) { // 技能1:二倍斩 + if (skill == 1) { + // 技能1:二倍斩 core.status.hero.mana -= 5; // 扣除5点魔力值 } // 关闭技能 core.setFlag('skill', 0); core.setFlag('skillName', '无'); } - if (core.getFlag("bladeOn") && core.getFlag("blade")) { - core.setFlag("blade", false); + if (core.getFlag('bladeOn') && core.getFlag('blade')) { + core.setFlag('blade', false); } // 事件的处理 var todo = []; // 加点事件 - var point = guards.reduce(function (curr, g) { - return curr + core.material.enemys[g[2]].point; - }, enemy.point) || 0; + var point = + guards.reduce(function (curr, g) { + return curr + core.material.enemys[g[2]].point; + }, enemy.point) || 0; if (core.flags.enableAddPoint && point > 0) { - core.push(todo, [{ "type": "insert", "name": "加点事件", "args": [point] }]); + core.push(todo, [ + { type: 'insert', name: '加点事件', args: [point] } + ]); } // 战后事件 if (core.status.floorId != null) { - core.push(todo, core.floors[core.status.floorId].afterBattle[x + "," + y]); + core.push( + todo, + core.floors[core.status.floorId].afterBattle[x + ',' + y] + ); } core.push(todo, enemy.afterBattle); - if (core.status.hero.loc.direction == 'up' || core.status.hero.loc.direction == 'down') - core.insertAction([{ "type": "moveAction" },]); + if ( + core.status.hero.loc.direction == 'up' || + core.status.hero.loc.direction == 'down' + ) + core.insertAction([{ type: 'moveAction' }]); // 在这里增加其他的自定义事件需求 /* if (enemyId=='xxx') { @@ -409,52 +468,66 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 如果已有事件正在处理中 - if (core.status.event.id == null) - core.continueAutomaticRoute(); - else - core.clearContinueAutomaticRoute(); - + if (core.status.event.id == null) core.continueAutomaticRoute(); + else core.clearContinueAutomaticRoute(); }, - "afterOpenDoor": function (doorId, x, y) { + afterOpenDoor: function (doorId, x, y) { // 开一个门后触发的事件 var todo = []; // 检查该点的获得开门后事件。 if (core.status.floorId == null) return; - var event = core.floors[core.status.floorId].afterOpenDoor[x + "," + y]; + var event = + core.floors[core.status.floorId].afterOpenDoor[x + ',' + y]; if (event) core.unshift(todo, event); if (todo.length > 0) core.insertAction(todo, x, y); - if (core.status.event.id == null) - core.continueAutomaticRoute(); - else - core.clearContinueAutomaticRoute(); + if (core.status.event.id == null) core.continueAutomaticRoute(); + else core.clearContinueAutomaticRoute(); }, - "afterGetItem": function (itemId, x, y, isGentleClick) { + afterGetItem: function (itemId, x, y, isGentleClick) { // 获得一个道具后触发的事件 // itemId:获得的道具ID;x和y是该道具所在的坐标 // isGentleClick:是否是轻按触发的 - if ((itemId.endsWith('Potion') || itemId == "I482" || itemId == "I484" || - itemId == "I487" || itemId == "I491") && core.material.items[itemId].cls == 'items') + if ( + (itemId.endsWith('Potion') || + itemId == 'I482' || + itemId == 'I484' || + itemId == 'I487' || + itemId == 'I491') && + core.material.items[itemId].cls == 'items' + ) core.playSound('回血'); - else - core.playSound('获得道具'); + else core.playSound('获得道具'); var todo = []; // 检查该点的获得道具后事件。 if (core.status.floorId == null) return; - var event = core.floors[core.status.floorId].afterGetItem[x + "," + y]; - if (event && (event instanceof Array || !isGentleClick || !event.disableOnGentleClick)) { + var event = + core.floors[core.status.floorId].afterGetItem[x + ',' + y]; + if ( + event && + (event instanceof Array || + !isGentleClick || + !event.disableOnGentleClick) + ) { core.unshift(todo, event); } - 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); + 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); } - if (core.getFlag("springCount", 0) == 50) { - core.setFlag("springCount", 0); + if (core.getFlag('springCount', 0) == 50) { + core.setFlag('springCount', 0); core.status.hero.hpmax *= 1.1; } core.updateStatusBar(); @@ -462,7 +535,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (todo.length > 0) core.insertAction(todo, x, y); }, - "afterPushBox": function () { + afterPushBox: function () { // 推箱子后的事件 if (core.searchBlock('box').length == 0) { // 可以通过if语句来进行开门操作 @@ -476,50 +549,235 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } } }, - "enemys": { - "getSpecials": function () { + enemys: { + getSpecials: function () { // 获得怪物的特殊属性,每一行定义一个特殊属性。 // 分为五项,第一项为该特殊属性的数字,第二项为特殊属性的名字,第三项为特殊属性的描述 // 第四项为该特殊属性的颜色,可以写十六进制 #RRGGBB 或者 [r,g,b,a] 四元数组 // 第五项为该特殊属性的标记;目前 1 代表是地图类技能(需要进行遍历全图) // 名字和描述可以直接写字符串,也可以写个function将怪物传进去 return [ - [1, "致命一击", function (enemy) { return "怪物每5回合触发一次强力攻击,造成" + (enemy.crit || 100) + "%的伤害" }, "#ffcc33"], - [2, "恶毒", "怪物攻击无视勇士的防御", "#bbb0ff"], - [3, "坚固", "怪物防御不小于勇士攻击-1", "#c0b088"], - [4, "2连击", "怪物每回合攻击2次", "#ffee77"], - [5, "3连击", "怪物每回合攻击3次", "#ffee77"], - [6, function (enemy) { return (enemy.n || '') + "连击"; }, function (enemy) { return "怪物每回合攻击" + (enemy.n || 4) + "次"; }, "#ffee77"], - [7, "饥渴", function (enemy) { return "战斗前,怪物偷取勇士" + (enemy.hungry || 0) + "%加在自己身上(勇士攻击也会降低)"; }, "#b30000"], - [8, "抱团", function (enemy) { return "怪物周围5×5范围内每有一个拥有该属性的怪物,该怪物攻防就增加" + (enemy.together || 0) + "%(线性叠加)"; }, "#ffaa44", 1], - [9, "绝对防御", function () { return "怪物的奇特护甲可以让勇士的额外攻击变为正常攻击(相当于勇士的攻击变为基础攻击+额外攻击)"; }, "#80eed6"], - [10, "勇气之刃", function (enemy) { return "第一回合造成" + (enemy.courage || 100) + "%的伤害,之后正常"; }, "#b0c0dd"], - [11, "勇气冲锋", function (enemy) { return "怪物首先发动冲锋,造成" + (enemy.charge || 100) + "%的伤害,并眩晕勇士5回合"; }, "#ff00d2"], - [12, "追猎", "当勇士移动到该怪物的水平或竖直方向上时,怪物向勇士移动一格", "#99ee88", 2], - [13, "魔攻", "怪物攻击无视勇士防御", "#bbb0ff"], - [14, "智慧之源", "困难难度下(简单难度没有效果),战斗后,怪物会吸取勇士30%的智慧(勇士智慧向下取整至整十)加在本层的拥有该属性的怪物攻击上", "#bbeef0"], - [15, "突刺", function (enemy) { - return "经过怪物周围" + (enemy.zoneSquare ? "九宫格" : "十字") + "范围内" + (enemy.range || 1) + "格时怪物会攻击勇士,造成" + - core.formatBigNumber(Math.max(((enemy.value || 0) - core.getRealStatusOrDefault(null, 'def')), 0)) + "点伤害"; - }, "#c677dd"], - [16, "夹击", "经过两只相同的怪物中间,勇士生命值变成一半", "#bb99ee"], - [17, "仇恨", "战斗前,怪物附加之前积累的仇恨值作为伤害;战斗后,释放一半的仇恨值。(每杀死一个怪物获得" + (core.values.hatred || 0) + "点仇恨值)", "#b0b666"], - [18, "阻击", function (enemy) { return "经过怪物的十字领域时自动减生命" + (enemy.value || 0) + "点,同时怪物后退一格"; }, "#8888e6"], - [19, "自爆", "战斗后勇士的生命值变成1", "#ff6666"], - [20, "无敌", "勇士无法打败怪物,除非拥有十字架", "#aaaaaa"], - [21, "退化", function (enemy) { return "战斗后勇士永久下降" + (enemy.atkValue || 0) + "点攻击和" + (enemy.defValue || 0) + "点防御"; }], - [22, "固伤", function (enemy) { return "战斗前,怪物对勇士造成" + (enemy.damage || 0) + "点固定伤害,未开启负伤时无视勇士护盾。"; }, "#ff9977"], - [23, "重生", "怪物被击败后,角色转换楼层则怪物将再次出现", "#a0e0ff"], - [24, "射击", function () { return "经过怪物同行或同列的可视范围内时受到一次普通攻击的伤害"; }, "#dda0dd"], - [25, "光环", function (enemy) { return "同楼层所有怪物生命提升" + (enemy.value || 0) + "%,攻击提升" + (enemy.atkValue || 0) + "%,防御提升" + (enemy.defValue || 0) + "%," + (enemy.add ? "可叠加" : "不可叠加"); }, "#e6e099", 1], - [26, "支援", "当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。", "#77c0b6", 1], - [27, "捕捉", "当走到怪物周围十字时会强制进行战斗。", "#c0ddbb"] + [ + 1, + '致命一击', + function (enemy) { + return ( + '怪物每5回合触发一次强力攻击,造成' + + (enemy.crit || 100) + + '%的伤害' + ); + }, + '#ffcc33' + ], + [2, '恶毒', '怪物攻击无视勇士的防御', '#bbb0ff'], + [3, '坚固', '怪物防御不小于勇士攻击-1', '#c0b088'], + [4, '2连击', '怪物每回合攻击2次', '#ffee77'], + [5, '3连击', '怪物每回合攻击3次', '#ffee77'], + [ + 6, + function (enemy) { + return (enemy.n || '') + '连击'; + }, + function (enemy) { + return '怪物每回合攻击' + (enemy.n || 4) + '次'; + }, + '#ffee77' + ], + [ + 7, + '饥渴', + function (enemy) { + return ( + '战斗前,怪物偷取勇士' + + (enemy.hungry || 0) + + '%加在自己身上(勇士攻击也会降低)' + ); + }, + '#b30000' + ], + [ + 8, + '抱团', + function (enemy) { + return ( + '怪物周围5×5范围内每有一个拥有该属性的怪物,该怪物攻防就增加' + + (enemy.together || 0) + + '%(线性叠加)' + ); + }, + '#ffaa44', + 1 + ], + [ + 9, + '绝对防御', + function () { + return '怪物的奇特护甲可以让勇士的额外攻击变为正常攻击(相当于勇士的攻击变为基础攻击+额外攻击)'; + }, + '#80eed6' + ], + [ + 10, + '勇气之刃', + function (enemy) { + return ( + '第一回合造成' + + (enemy.courage || 100) + + '%的伤害,之后正常' + ); + }, + '#b0c0dd' + ], + [ + 11, + '勇气冲锋', + function (enemy) { + return ( + '怪物首先发动冲锋,造成' + + (enemy.charge || 100) + + '%的伤害,并眩晕勇士5回合' + ); + }, + '#ff00d2' + ], + [ + 12, + '追猎', + '当勇士移动到该怪物的水平或竖直方向上时,怪物向勇士移动一格', + '#99ee88', + 2 + ], + [13, '魔攻', '怪物攻击无视勇士防御', '#bbb0ff'], + [ + 14, + '智慧之源', + '困难难度下(简单难度没有效果),战斗后,怪物会吸取勇士30%的智慧(勇士智慧向下取整至整十)加在本层的拥有该属性的怪物攻击上', + '#bbeef0' + ], + [ + 15, + '突刺', + function (enemy) { + return ( + '经过怪物周围' + + (enemy.zoneSquare ? '九宫格' : '十字') + + '范围内' + + (enemy.range || 1) + + '格时怪物会攻击勇士,造成' + + core.formatBigNumber( + Math.max( + (enemy.value || 0) - + core.getRealStatusOrDefault( + null, + 'def' + ), + 0 + ) + ) + + '点伤害' + ); + }, + '#c677dd' + ], + [ + 16, + '夹击', + '经过两只相同的怪物中间,勇士生命值变成一半', + '#bb99ee' + ], + [ + 17, + '仇恨', + '战斗前,怪物附加之前积累的仇恨值作为伤害;战斗后,释放一半的仇恨值。(每杀死一个怪物获得' + + (core.values.hatred || 0) + + '点仇恨值)', + '#b0b666' + ], + [ + 18, + '阻击', + function (enemy) { + return ( + '经过怪物的十字领域时自动减生命' + + (enemy.value || 0) + + '点,同时怪物后退一格' + ); + }, + '#8888e6' + ], + [19, '自爆', '战斗后勇士的生命值变成1', '#ff6666'], + [20, '无敌', '勇士无法打败怪物,除非拥有十字架', '#aaaaaa'], + [ + 21, + '退化', + function (enemy) { + return ( + '战斗后勇士永久下降' + + (enemy.atkValue || 0) + + '点攻击和' + + (enemy.defValue || 0) + + '点防御' + ); + } + ], + [ + 22, + '固伤', + function (enemy) { + return ( + '战斗前,怪物对勇士造成' + + (enemy.damage || 0) + + '点固定伤害,未开启负伤时无视勇士护盾。' + ); + }, + '#ff9977' + ], + [ + 23, + '重生', + '怪物被击败后,角色转换楼层则怪物将再次出现', + '#a0e0ff' + ], + [ + 24, + '射击', + function () { + return '经过怪物同行或同列的可视范围内时受到一次普通攻击的伤害'; + }, + '#dda0dd' + ], + [ + 25, + '光环', + function (enemy) { + return ( + '同楼层所有怪物生命提升' + + (enemy.value || 0) + + '%,攻击提升' + + (enemy.atkValue || 0) + + '%,防御提升' + + (enemy.defValue || 0) + + '%,' + + (enemy.add ? '可叠加' : '不可叠加') + ); + }, + '#e6e099', + 1 + ], + [ + 26, + '支援', + '当周围一圈的怪物受到攻击时将上前支援,并组成小队战斗。', + '#77c0b6', + 1 + ], + [27, '捕捉', '当走到怪物周围十字时会强制进行战斗。', '#c0ddbb'] ]; }, - "getEnemyInfo": function (enemy, hero, x, y, floorId) { + getEnemyInfo: function (enemy, hero, x, y, floorId) { // 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用 // 例如:坚固、模仿、仿攻等等 - // + // // 参数说明: // enemy:该怪物信息 // hero_hp,hero_atk,hero_def,hero_mdef:勇士的生命攻防护盾数据 @@ -535,7 +793,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var mon_hp = core.getEnemyValue(enemy, 'hp', x, y, floorId), mon_atk = core.getEnemyValue(enemy, 'atk', x, y, floorId), mon_def = core.getEnemyValue(enemy, 'def', x, y, floorId), - mon_special = core.getEnemyValue(enemy, 'special', x, y, floorId); + mon_special = core.getEnemyValue( + enemy, + 'special', + x, + y, + floorId + ); var mon_money = core.getEnemyValue(enemy, 'money', x, y, floorId), mon_exp = core.getEnemyValue(enemy, 'exp', x, y, floorId), mon_point = core.getEnemyValue(enemy, 'point', x, y, floorId); @@ -545,11 +809,11 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 饥渴 if (core.hasSpecial(mon_special, 7)) - mon_atk += hero_atk * (enemy.hungry || 0) / 100; + mon_atk += (hero_atk * (enemy.hungry || 0)) / 100; // 智慧之源 if (core.hasSpecial(mon_special, 14) && flags.hard == 2) { - mon_atk += core.getFlag("inte_" + floorId, 0); + mon_atk += core.getFlag('inte_' + floorId, 0); } var guards = []; @@ -565,8 +829,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 已经计算过的光环怪ID列表,用于判定叠加 var usedEnemyIds = {}; // 检查光环和支援的缓存 - var index = x != null && y != null ? (x + "," + y) : ("floor" + enemy.id); - if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {}; + var index = + x != null && y != null ? x + ',' + y : 'floor' + enemy.id; + if (!core.status.checkBlock.cache) + core.status.checkBlock.cache = {}; var cache = core.status.checkBlock.cache[index]; if (!cache) { // 没有该点的缓存,则遍历每个图块 @@ -582,13 +848,25 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (enemy && core.hasSpecial(enemy.special, 25)) { // 检查是否是范围光环 var inRange = enemy.range == null; - if (enemy.range != null && x != null && y != null) { + if ( + enemy.range != null && + x != null && + y != null + ) { // 检查十字和九宫格光环 if (dx + dy <= enemy.range) inRange = true; - if (enemy.zoneSquare && dx <= enemy.range && dy <= enemy.range) inRange = true; + if ( + enemy.zoneSquare && + dx <= enemy.range && + dy <= enemy.range + ) + inRange = true; } // 检查是否可叠加 - if (inRange && (enemy.add || !usedEnemyIds[enemy.id])) { + if ( + inRange && + (enemy.add || !usedEnemyIds[enemy.id]) + ) { hp_buff += enemy.value || 0; atk_buff += enemy.atkValue || 0; def_buff += enemy.defValue || 0; @@ -596,15 +874,29 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } } // 检查【支援】技能,数字26 - if (enemy && core.hasSpecial(enemy.special, 26) && + if ( + enemy && + core.hasSpecial(enemy.special, 26) && // 检查支援条件,坐标存在,距离为1,且不能是自己 // 其他类型的支援怪,比如十字之类的话.... 看着做是一样的 - x != null && y != null && Math.abs(block.x - x) <= 1 && Math.abs(block.y - y) <= 1 && !(x == block.x && y == block.y)) { + x != null && + y != null && + Math.abs(block.x - x) <= 1 && + Math.abs(block.y - y) <= 1 && + !(x == block.x && y == block.y) + ) { // 记录怪物的x,y,ID guards.push([block.x, block.y, id]); } // 抱团 - if (enemy && core.hasSpecial(mon_special, 8) && core.hasSpecial(enemy.special, 8) && !(dx == 0 && dy == 0) && dx < 3 && dy < 3) { + if ( + enemy && + core.hasSpecial(mon_special, 8) && + core.hasSpecial(enemy.special, 8) && + !(dx == 0 && dy == 0) && + dx < 3 && + dy < 3 + ) { atk_buff += enemy.together || 0; def_buff += enemy.together || 0; } @@ -613,7 +905,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 注:新增新的类光环属性(需要遍历全图的)需要在特殊属性定义那里的第五项写1,参见光环和支援的特殊属性定义。 } }); - core.status.checkBlock.cache[index] = { "hp_buff": hp_buff, "atk_buff": atk_buff, "def_buff": def_buff, "guards": guards }; + core.status.checkBlock.cache[index] = { + hp_buff: hp_buff, + atk_buff: atk_buff, + def_buff: def_buff, + guards: guards + }; } else { // 直接使用缓存数据 hp_buff = cache.hp_buff; @@ -623,9 +920,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 增加比例;如果要增加数值可以直接在这里修改 - mon_hp *= (1 + hp_buff / 100); - mon_atk *= (1 + atk_buff / 100); - mon_def *= (1 + def_buff / 100); + mon_hp *= 1 + hp_buff / 100; + mon_atk *= 1 + atk_buff / 100; + mon_def *= 1 + def_buff / 100; } // TODO:可以在这里新增其他的怪物数据变化 @@ -636,19 +933,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 也可以按需增加各种自定义内容 return { - "hp": Math.floor(mon_hp), - "atk": Math.floor(mon_atk), - "def": Math.floor(mon_def), - "money": Math.floor(mon_money), - "exp": Math.floor(mon_exp), - "point": Math.floor(mon_point), - "special": mon_special, - "guards": guards, // 返回支援情况 + hp: Math.floor(mon_hp), + atk: Math.floor(mon_atk), + def: Math.floor(mon_def), + money: Math.floor(mon_money), + exp: Math.floor(mon_exp), + point: Math.floor(mon_point), + special: mon_special, + guards: guards // 返回支援情况 }; }, - "getDamageInfo": function (enemy, hero, x, y, floorId) { + getDamageInfo: function (enemy, hero, x, y, floorId) { // 获得战斗伤害信息(实际伤害计算函数) - // + // // 参数说明: // enemy:该怪物信息 // hero:勇士的当前数据;如果对应项不存在则会从core.status.hero中取 @@ -674,7 +971,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 怪物的各项数据 // 对坚固模仿等处理扔到了脚本编辑-getEnemyInfo之中 - var enemyInfo = core.enemys.getEnemyInfo(enemy, hero, x, y, floorId); + var enemyInfo = core.enemys.getEnemyInfo( + enemy, + hero, + x, + y, + floorId + ); var mon_hp = enemyInfo.hp, mon_atk = enemyInfo.atk, mon_def = enemyInfo.def, @@ -682,7 +985,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var damage = 0; // 断灭之刃技能 - if (core.getFlag("bladeOn") && core.getFlag("blade")) { + if (core.getFlag('bladeOn') && core.getFlag('blade')) { var level = core.getSkillLevel()[2]; hero_atk *= 1 + 0.1 * level; hero_def *= 1 - 0.1 * level; @@ -693,7 +996,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 如果是无敌属性,且勇士未持有十字架 - if (core.hasSpecial(mon_special, 20) && !core.hasItem("cross")) + if (core.hasSpecial(mon_special, 20) && !core.hasItem('cross')) return null; // 不可战斗 // 战前造成的额外伤害(可被护盾抵消) @@ -702,22 +1005,28 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 每回合怪物对勇士造成的战斗伤害 var per_damage = mon_atk - hero_def; // 魔攻:战斗伤害就是怪物攻击力 - if (core.hasSpecial(mon_special, 2) || core.hasSpecial(mon_special, 13)) per_damage = mon_atk; + if ( + core.hasSpecial(mon_special, 2) || + core.hasSpecial(mon_special, 13) + ) + per_damage = mon_atk; // 战斗伤害不能为负值 if (per_damage < 0) per_damage = 0; // 2连击 & 3连击 & N连击 if (core.hasSpecial(mon_special, 4)) per_damage *= 2; if (core.hasSpecial(mon_special, 5)) per_damage *= 3; - if (core.hasSpecial(mon_special, 6)) per_damage *= (enemy.n || 4); + if (core.hasSpecial(mon_special, 6)) per_damage *= enemy.n || 4; // 勇士每回合对怪物造成的伤害 if (!core.hasSpecial(mon_special, 9)) { var hero_per_damage = Math.max(hero_atk - mon_def, 0); - if (hero_per_damage > 0) - hero_per_damage += hero_extraAtk; + if (hero_per_damage > 0) hero_per_damage += hero_extraAtk; } if (core.hasSpecial(mon_special, 9)) { - var hero_per_damage = Math.max(hero_atk + hero_extraAtk - mon_def, 0); + var hero_per_damage = Math.max( + hero_atk + hero_extraAtk - mon_def, + 0 + ); } // 如果没有破防,则不可战斗 @@ -729,7 +1038,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 致命一击 if (core.hasSpecial(mon_special, 1)) { var times = Math.floor(turn / 5); - damage += times * ((enemy.crit || 100) - 100) / 100 * per_damage; + damage += + ((times * ((enemy.crit || 100) - 100)) / 100) * per_damage; } // 勇气之刃 if (turn > 1 && core.hasSpecial(mon_special, 10)) { @@ -743,12 +1053,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // ------ 支援 ----- // // 这个递归最好想明白为什么,flag:__extraTurn__是怎么用的 - var guards = core.getFlag("__guards__" + x + "_" + y, enemyInfo.guards); + var guards = core.getFlag( + '__guards__' + x + '_' + y, + enemyInfo.guards + ); var guard_before_current_enemy = true; // ------ 支援怪是先打(true)还是后打(false)? - turn += core.getFlag("__extraTurn__", 0); + turn += core.getFlag('__extraTurn__', 0); if (guards.length > 0) { - if (!guard_before_current_enemy) { // --- 先打当前怪物,记录当前回合数 - core.setFlag("__extraTurn__", turn); + if (!guard_before_current_enemy) { + // --- 先打当前怪物,记录当前回合数 + core.setFlag('__extraTurn__', turn); } // 获得那些怪物组成小队战斗 for (var i = 0; i < guards.length; i++) { @@ -757,54 +1071,63 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = gid = guards[i][2]; // 递归计算支援怪伤害信息,这里不传x,y保证不会重复调用 // 这里的mdef传0,因为护盾应该只会被计算一次 - var info = core.enemys.getDamageInfo(core.material.enemys[gid], { hp: origin_hero_hp, atk: origin_hero_atk, def: origin_hero_def, mdef: 0 }); - if (info == null) { // 小队中任何一个怪物不可战斗,直接返回null - core.removeFlag("__extraTurn__"); + var info = core.enemys.getDamageInfo( + core.material.enemys[gid], + { + hp: origin_hero_hp, + atk: origin_hero_atk, + def: origin_hero_def, + mdef: 0 + } + ); + if (info == null) { + // 小队中任何一个怪物不可战斗,直接返回null + core.removeFlag('__extraTurn__'); return null; } // 已经进行的回合数 - core.setFlag("__extraTurn__", info.turn); + core.setFlag('__extraTurn__', info.turn); init_damage += info.damage; } - if (guard_before_current_enemy) { // --- 先打支援怪物,增加当前回合数 - turn += core.getFlag("__extraTurn__", 0); + if (guard_before_current_enemy) { + // --- 先打支援怪物,增加当前回合数 + turn += core.getFlag('__extraTurn__', 0); } } - core.removeFlag("__extraTurn__"); + core.removeFlag('__extraTurn__'); // ------ 支援END ------ // // 最终伤害:初始伤害 + 怪物对勇士造成的伤害 + 反击伤害 damage += init_damage + (turn - 1) * per_damage; // 无上之盾 - if (core.hasFlag("superSheild")) { + if (core.hasFlag('superSheild')) { damage -= hero_IQ; } // 生命回复 damage -= hero_recovery * turn; - if (core.getFlag("hard") == 1) damage *= 0.9; + if (core.getFlag('hard') == 1) damage *= 0.9; return { - "mon_hp": Math.floor(mon_hp), - "mon_atk": Math.floor(mon_atk), - "mon_def": Math.floor(mon_def), - "init_damage": Math.floor(init_damage), - "per_damage": Math.floor(per_damage), - "hero_per_damage": Math.floor(hero_per_damage), - "turn": Math.floor(turn), - "damage": Math.floor(damage) + mon_hp: Math.floor(mon_hp), + mon_atk: Math.floor(mon_atk), + mon_def: Math.floor(mon_def), + init_damage: Math.floor(init_damage), + per_damage: Math.floor(per_damage), + hero_per_damage: Math.floor(hero_per_damage), + turn: Math.floor(turn), + damage: Math.floor(damage) }; } }, - "actions": { - "onKeyUp": function (keyCode, altKey) { + actions: { + onKeyUp: function (keyCode, altKey) { // 键盘按键处理,可以在这里自定义快捷键列表 // keyCode:当前按键的keyCode(每个键的keyCode自行百度) // altKey:Alt键是否被按下,为true代表同时按下了Alt键 // 可以在这里任意增加或编辑每个按键的行为 // 如果处于正在行走状态,则不处理 - if (core.isMoving()) - return; + if (core.isMoving()) return; // Alt+0~9,快捷换上套装 if (altKey && keyCode >= 48 && keyCode <= 57) { @@ -818,36 +1141,46 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.useItem('skill1'); break; case 56: // 8 - core.useItem("wand"); + core.useItem('wand'); break; case 27: // ESC:打开菜单栏 core.openSettings(true); break; case 88: // X:使用怪物手册 - if (!core.getFlag("fixToBook")) - core.openBook(true); - else - core.useItem("wand"); + if (!core.getFlag('fixToBook')) core.openBook(true); + else core.useItem('wand'); break; case 71: // G:使用楼传器 core.useFly(true); break; case 65: // A:读取自动存档(回退) if (core.status.floorId != 'tower6') { - core.doSL("autoSave", "load"); + core.doSL('autoSave', 'load'); } else { - core.myconfirm('确定要读取自动存档吗?读取后无法通过按W回退至现在', function () { - core.doSL("autoSave", "load"); - }, function () { return; }); + core.myconfirm( + '确定要读取自动存档吗?读取后无法通过按W回退至现在', + function () { + core.doSL('autoSave', 'load'); + }, + function () { + return; + } + ); } break; case 87: // W:撤销回退 if (core.status.floorId != 'tower6') { - core.doSL("autoSave", "reload"); + core.doSL('autoSave', 'reload'); } else { - core.myconfirm('确定要撤销回退吗?撤销后后无法通过按A回退至现在', function () { - core.doSL("autoSave", "reload"); - }, function () { return; }); + core.myconfirm( + '确定要撤销回退吗?撤销后后无法通过按A回退至现在', + function () { + core.doSL('autoSave', 'reload'); + }, + function () { + return; + } + ); } break; case 83: // S:存档 @@ -901,19 +1234,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break; case 49: // 1: 断灭之刃 if (!flags.bladeOn) break; - core.status.route.push("key:49"); // 将按键记在录像中 - core.playSound("光标移动"); + core.status.route.push('key:49'); // 将按键记在录像中 + core.playSound('光标移动'); if (flags.blade) flags.blade = false; else flags.blade = true; core.updateStatusBar(false, true); break; case 50: // 快捷键2: 跳跃技能 || 破 - if (!flags.chase && !core.status.floorId.startsWith("tower") && flags.skill2) { + if ( + !flags.chase && + !core.status.floorId.startsWith('tower') && + flags.skill2 + ) { core.jumpSkill(); - core.status.route.push("key:50"); // 将按键记在录像中 + core.status.route.push('key:50'); // 将按键记在录像中 } else { if (core.hasItem('pickaxe')) { - core.status.route.push("key:50"); // 将按键记在录像中 + core.status.route.push('key:50'); // 将按键记在录像中 core.useItem('pickaxe', true); // 第二个参数true代表该次使用道具是被按键触发的,使用过程不计入录像 } } @@ -922,11 +1259,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break; case 52: // 快捷键4:破冰/冰冻/地震/上下楼器/... 其他道具依次判断 { - var list = ["icePickaxe", "freezeBadge", "earthquake", "upFly", "downFly", "jumpShoes", "lifeWand", "poisonWine", "weakWine", "curseWine", "superWine"]; + var list = [ + 'icePickaxe', + 'freezeBadge', + 'earthquake', + 'upFly', + 'downFly', + 'jumpShoes', + 'lifeWand', + 'poisonWine', + 'weakWine', + 'curseWine', + 'superWine' + ]; for (var i = 0; i < list.length; i++) { var itemId = list[i]; if (core.canUseItem(itemId)) { - core.status.route.push("key:52"); + core.status.route.push('key:52'); core.useItem(itemId, true); break; } @@ -935,20 +1284,32 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break; case 53: // 5:读取自动存档(回退),方便手机版操作 if (core.status.floorId != 'tower6') { - core.doSL("autoSave", "load"); + core.doSL('autoSave', 'load'); } else { - core.myconfirm('确定要读取自动存档吗?读取后无法通过按6回退至现在', function () { - core.doSL("autoSave", "load"); - }, function () { return; }); + core.myconfirm( + '确定要读取自动存档吗?读取后无法通过按6回退至现在', + function () { + core.doSL('autoSave', 'load'); + }, + function () { + return; + } + ); } break; case 54: // 6:撤销回退,方便手机版操作 if (core.status.floorId != 'tower6') { - core.doSL("autoSave", "reload"); + core.doSL('autoSave', 'reload'); } else { - core.myconfirm('确定要撤销回退吗?撤销后后无法通过按5回退至现在', function () { - core.doSL("autoSave", "reload"); - }, function () { return; }); + core.myconfirm( + '确定要撤销回退吗?撤销后后无法通过按5回退至现在', + function () { + core.doSL('autoSave', 'reload'); + }, + function () { + return; + } + ); } break; case 55: // 快捷键7:绑定为轻按,方便手机版操作 @@ -974,12 +1335,11 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break; */ } - }, - "onStatusBarClick": function (px, py) { + onStatusBarClick: function (px, py) { // 点击状态栏时触发的事件,仅在自绘状态栏开启时生效 // px和py为点击的像素坐标 - // + // // 横屏模式下状态栏的画布大小是 149*480 // 竖屏模式下状态栏的画布大小是 480*(32*rows+9) 其中rows为状态栏行数,即全塔属性中statusCanvasRowsOnMobile值 // 可以使用 core.domStyle.isVertical 来判定当前是否是竖屏模式 @@ -1009,8 +1369,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // console.log("onStatusBarClick:", px, py); } }, - "control": { - "saveData": function () { + control: { + saveData: function () { // 存档操作,此函数应该返回“具体要存档的内容” // 差异化存储values @@ -1022,49 +1382,68 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 要存档的内容 var data = { - 'floorId': core.status.floorId, - 'hero': core.clone(core.status.hero), - 'hard': core.status.hard, - 'maps': core.maps.saveMap(), - 'route': core.encodeRoute(core.status.route), - 'values': values, - 'version': core.firstData.version, - 'guid': core.getGuid(), - "time": new Date().getTime(), - "tower6": core.saveLoopMap("tower6", ['tower1', 'tower2', 'tower4', 'tower5']), + floorId: core.status.floorId, + hero: core.clone(core.status.hero), + hard: core.status.hard, + maps: core.maps.saveMap(), + route: core.encodeRoute(core.status.route), + values: values, + version: core.firstData.version, + guid: core.getGuid(), + time: new Date().getTime(), + tower6: core.saveLoopMap('tower6', [ + 'tower1', + 'tower2', + 'tower4', + 'tower5' + ]) }; return data; }, - "loadData": function (data, callback) { + loadData: function (data, callback) { // 读档操作;从存储中读取了内容后的行为 // tower6 if (core.floors.tower6) { - core.loadLoopMap(data.tower6, "tower6"); - if (core.status.floorId == "tower6") - core.extractBlocks("tower6"); + core.loadLoopMap(data.tower6, 'tower6'); + if (core.status.floorId == 'tower6') + core.extractBlocks('tower6'); } // 重置游戏和路线 - core.resetGame(data.hero, data.hard, data.floorId, core.maps.loadMap(data.maps, null, data.hero.flags), data.values); + core.resetGame( + data.hero, + data.hard, + data.floorId, + core.maps.loadMap(data.maps, null, data.hero.flags), + data.values + ); core.status.route = core.decodeRoute(data.route); core.control._bindRoutePush(); // 文字属性,全局属性 - core.status.textAttribute = core.getFlag('textAttribute', core.status.textAttribute); - var toAttribute = core.getFlag('globalAttribute', core.status.globalAttribute); + core.status.textAttribute = core.getFlag( + 'textAttribute', + core.status.textAttribute + ); + var toAttribute = core.getFlag( + 'globalAttribute', + core.status.globalAttribute + ); if (!core.same(toAttribute, core.status.globalAttribute)) { core.status.globalAttribute = toAttribute; core.resize(); } // 重置音量 - core.events.setVolume(core.getFlag("__volume__", 1), 0); + core.events.setVolume(core.getFlag('__volume__', 1), 0); // 加载勇士图标 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]; - core.material.icons.hero.width = core.material.images.images[icon].width / 4; - core.material.icons.hero.height = core.material.images.images[icon].height / 4; + core.material.icons.hero.width = + core.material.images.images[icon].width / 4; + core.material.icons.hero.height = + core.material.images.images[icon].height / 4; } core.setFlag('__fromLoad__', true); @@ -1073,43 +1452,46 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 切换到对应的楼层 core.changeFloor(data.floorId, null, data.hero.loc, 0, function () { // TODO:可以在这里设置读档后播放BGM - if (core.hasFlag("__bgm__")) { // 持续播放 - core.playBgm(core.getFlag("__bgm__")); + if (core.hasFlag('__bgm__')) { + // 持续播放 + core.playBgm(core.getFlag('__bgm__')); } core.removeFlag('__fromLoad__'); if (callback) callback(); }); }, - "getStatusLabel": function (name) { + getStatusLabel: function (name) { // 返回某个状态英文名的对应中文标签,如atk -> 攻击,def -> 防御等。 // 请注意此项仅影响 libs/ 下的内容(如绘制怪物手册、数据统计等) // 自行定义的(比如获得道具效果)中用到的“攻击+3”等需要自己去对应地方修改 - return { - name: "名称", - lv: "等级", - hpmax: "生命回复", - hp: "生命", - manamax: "魔力上限", - mana: "额外攻击", - atk: "攻击", - def: "防御", - mdef: "智慧", - money: "金币", - exp: "经验", - point: "加点", - steps: "步数", - }[name] || name; + return ( + { + name: '名称', + lv: '等级', + hpmax: '生命回复', + hp: '生命', + manamax: '魔力上限', + mana: '额外攻击', + atk: '攻击', + def: '防御', + mdef: '智慧', + money: '金币', + exp: '经验', + point: '加点', + steps: '步数' + }[name] || name + ); }, - "triggerDebuff": function (action, type) { + triggerDebuff: function (action, type) { // 毒衰咒效果的获得与解除 // action:获得还是解除;'get'表示获得,'remove'表示解除 // type:一个数组表示获得了哪些毒衰咒效果;poison, weak,curse if (!(type instanceof Array)) type = [type]; if (action == 'get') { - if (core.inArray(type, 'poison') && !core.hasFlag("poison")) { + if (core.inArray(type, 'poison') && !core.hasFlag('poison')) { // 获得毒效果 core.setFlag('poison', true); } @@ -1131,13 +1513,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setFlag('curse', true); } } else if (action == 'remove') { - if (core.inArray(type, "poison") && core.hasFlag("poison")) { + if (core.inArray(type, 'poison') && core.hasFlag('poison')) { // 移除毒效果 - core.setFlag("poison", false); + core.setFlag('poison', false); } - if (core.inArray(type, "weak") && core.hasFlag("weak")) { + if (core.inArray(type, 'weak') && core.hasFlag('weak')) { // 移除衰效果 - core.setFlag("weak", false); + core.setFlag('weak', false); if (core.values.weakValue >= 1) { // >=1,直接扣数值 core.addStatus('atk', core.values.weakValue); @@ -1148,13 +1530,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.addBuff('def', core.values.weakValue); } } - if (core.inArray(type, "curse") && core.hasFlag("curse")) { + if (core.inArray(type, 'curse') && core.hasFlag('curse')) { // 移除咒效果 - core.setFlag("curse", false); + core.setFlag('curse', false); } } }, - "updateStatusBar": function () { + updateStatusBar: function () { // 更新状态栏 // 检查等级 @@ -1162,12 +1544,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 检查HP上限 if (core.flags.statusBarItems.indexOf('enableHPMax') >= 0) { - core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp'))); + core.setStatus( + 'hp', + Math.min(core.getStatus('hpmax'), core.getStatus('hp')) + ); } // 设置楼层名 if (core.status.floorId) { - core.setStatusBarInnerHTML('floor', core.status.maps[core.status.floorId].name); + core.setStatusBarInnerHTML( + 'floor', + core.status.maps[core.status.floorId].name + ); } // 设置勇士名字和图标 @@ -1176,7 +1564,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setStatusBarInnerHTML('lv', core.getLvName()); // 设置生命上限、生命值、攻防护盾金币和经验值 - var statusList = ['hpmax', 'hp', 'mana', 'atk', 'def', 'mdef', 'money', 'exp']; + var statusList = [ + 'hpmax', + 'hp', + 'mana', + 'atk', + 'def', + 'mdef', + 'money', + 'exp' + ]; statusList.forEach(function (item) { // 向下取整 core.status.hero[item] = Math.floor(core.status.hero[item]); @@ -1185,15 +1582,27 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }); // 设置魔力值; status:manamax 只有在非负时才生效。 - if (core.status.hero.manamax != null && core.getRealStatus('manamax') >= 0) { - core.status.hero.mana = Math.min(core.status.hero.mana, core.getRealStatus('manamax')); - core.setStatusBarInnerHTML('mana', core.status.hero.mana + "/" + core.getRealStatus('manamax')); + if ( + core.status.hero.manamax != null && + core.getRealStatus('manamax') >= 0 + ) { + core.status.hero.mana = Math.min( + core.status.hero.mana, + core.getRealStatus('manamax') + ); + core.setStatusBarInnerHTML( + 'mana', + core.status.hero.mana + '/' + core.getRealStatus('manamax') + ); } else { - core.setStatusBarInnerHTML("mana", core.status.hero.mana); + core.setStatusBarInnerHTML('mana', core.status.hero.mana); } // 设置技能栏 // 可以用flag:skill表示当前开启的技能类型,flag:skillName显示技能名;详见文档-个性化-技能塔的支持 - core.setStatusBarInnerHTML('skill', core.getFlag('skillName', '无')); + core.setStatusBarInnerHTML( + 'skill', + core.getFlag('skillName', '无') + ); // 可以在这里添加自己额外的状态栏信息,比如想攻击显示 +0.5 可以这么写: // if (core.hasFlag('halfAtk')) core.setStatusBarInnerHTML('atk', core.statusBar.atk.innerText + "+0.5"); @@ -1201,27 +1610,56 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 如果是自定义添加的状态栏,也需要在这里进行设置显示的数值 // 进阶 - if (core.flags.statusBarItems.indexOf('enableLevelUp') >= 0 && core.status.hero.lv < core.firstData.levelUp.length) { - var need = core.calValue(core.firstData.levelUp[core.status.hero.lv].need); + if ( + core.flags.statusBarItems.indexOf('enableLevelUp') >= 0 && + core.status.hero.lv < core.firstData.levelUp.length + ) { + var need = core.calValue( + core.firstData.levelUp[core.status.hero.lv].need + ); if (core.flags.statusBarItems.indexOf('levelUpLeftMode') >= 0) - core.setStatusBarInnerHTML('up', core.formatBigNumber(need - core.getStatus('exp')) || ""); + core.setStatusBarInnerHTML( + 'up', + core.formatBigNumber(need - core.getStatus('exp')) || '' + ); else - core.setStatusBarInnerHTML('up', core.formatBigNumber(need) || ""); - } else core.setStatusBarInnerHTML('up', ""); + core.setStatusBarInnerHTML( + 'up', + core.formatBigNumber(need) || '' + ); + } else core.setStatusBarInnerHTML('up', ''); // 钥匙 var keys = ['yellowKey', 'blueKey', 'redKey', 'greenKey']; keys.forEach(function (key) { - core.setStatusBarInnerHTML(key, core.setTwoDigits(core.itemCount(key))); + core.setStatusBarInnerHTML( + key, + core.setTwoDigits(core.itemCount(key)) + ); }); // 毒衰咒 - core.setStatusBarInnerHTML('poison', core.hasFlag('poison') ? "毒" : ""); - core.setStatusBarInnerHTML('weak', core.hasFlag('weak') ? "衰" : ""); - core.setStatusBarInnerHTML('curse', core.hasFlag('curse') ? "咒" : ""); + core.setStatusBarInnerHTML( + 'poison', + core.hasFlag('poison') ? '毒' : '' + ); + core.setStatusBarInnerHTML( + 'weak', + core.hasFlag('weak') ? '衰' : '' + ); + core.setStatusBarInnerHTML( + 'curse', + core.hasFlag('curse') ? '咒' : '' + ); // 破炸飞 - core.setStatusBarInnerHTML('pickaxe', "破" + core.itemCount('pickaxe')); - core.setStatusBarInnerHTML('bomb', "炸" + core.itemCount('bomb')); - core.setStatusBarInnerHTML('fly', "飞" + core.itemCount('centerFly')); + core.setStatusBarInnerHTML( + 'pickaxe', + '破' + core.itemCount('pickaxe') + ); + core.setStatusBarInnerHTML('bomb', '炸' + core.itemCount('bomb')); + core.setStatusBarInnerHTML( + 'fly', + '飞' + core.itemCount('centerFly') + ); // 难度 if (core.statusBar.hard.innerText != core.status.hard) { @@ -1240,7 +1678,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 更新全地图显伤 core.updateDamage(); }, - "updateCheckBlock": function (floorId) { + updateCheckBlock: function (floorId) { // 领域、夹击、阻击等的伤害值计算 floorId = floorId || core.status.floorId; if (!floorId || !core.status.maps) return; @@ -1274,12 +1712,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 如需调用当前楼层的ratio可使用 core.status.maps[floorId].ratio if (id == 'lavaNet' && !core.hasItem('amulet')) { damage[loc] = (damage[loc] || 0) + core.values.lavaDamage; - type[loc]["血网伤害"] = true; + type[loc]['血网伤害'] = true; } // 领域 // 如果要防止领域伤害,可以直接简单的将 flag:no_zone 设为true - if (enemy && core.hasSpecial(enemy.special, 15) && !core.hasFlag('no_zone')) { + if ( + enemy && + core.hasSpecial(enemy.special, 15) && + !core.hasFlag('no_zone') + ) { // 领域范围,默认为1 var range = enemy.range || 1; // 是否是九宫格领域 @@ -1291,34 +1733,53 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (dx == 0 && dy == 0) continue; var nx = x + dx, ny = y + dy, - currloc = nx + "," + ny; - if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue; + currloc = nx + ',' + ny; + if (nx < 0 || nx >= width || ny < 0 || ny >= height) + continue; // 如果是十字领域,则还需要满足 |dx|+|dy|<=range - if (!zoneSquare && Math.abs(dx) + Math.abs(dy) > range) continue; - damage[currloc] = Math.max((damage[currloc] || 0) + (enemy.value || 0) - core.getRealStatusOrDefault(null, 'def'), 0); + if ( + !zoneSquare && + Math.abs(dx) + Math.abs(dy) > range + ) + continue; + damage[currloc] = Math.max( + (damage[currloc] || 0) + + (enemy.value || 0) - + core.getRealStatusOrDefault(null, 'def'), + 0 + ); type[currloc] = type[currloc] || {}; - type[currloc]["领域伤害"] = true; + type[currloc]['领域伤害'] = true; } } } // 阻击 // 如果要防止阻击伤害,可以直接简单的将 flag:no_repulse 设为true - if (enemy && core.hasSpecial(enemy.special, 18) && !core.hasFlag('no_repulse')) { + if ( + enemy && + core.hasSpecial(enemy.special, 18) && + !core.hasFlag('no_repulse') + ) { for (var dir in core.utils.scan) { var nx = x + core.utils.scan[dir].x, ny = y + core.utils.scan[dir].y, - currloc = nx + "," + ny; - if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue; - damage[currloc] = (damage[currloc] || 0) + (enemy.value || 0); + currloc = nx + ',' + ny; + if (nx < 0 || nx >= width || ny < 0 || ny >= height) + continue; + damage[currloc] = + (damage[currloc] || 0) + (enemy.value || 0); type[currloc] = type[currloc] || {}; - type[currloc]["阻击伤害"] = true; + type[currloc]['阻击伤害'] = true; - var rdir = core.turnDirection(":back", dir); + var rdir = core.turnDirection(':back', dir); // 检查下一个点是否存在事件(从而判定是否移动) var rnx = x + core.utils.scan[rdir].x, rny = y + core.utils.scan[rdir].y; - if (core.canMoveHero(x, y, rdir, floorId) && core.getBlock(rnx, rny, floorId) == null) { + if ( + core.canMoveHero(x, y, rdir, floorId) && + core.getBlock(rnx, rny, floorId) == null + ) { repulse[currloc] = (repulse[currloc] || []).concat([ [x, y, id, rdir] ]); @@ -1330,10 +1791,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (enemy && core.hasSpecial(enemy.special, 24)) { var beyondVisual = false; for (var nx = 0; nx < width; nx++) { - var currloc = nx + "," + y; + var currloc = nx + ',' + y; for (var mx = nx; mx != x; mx > x ? mx-- : mx++) { - if (core.getBlockCls(mx, y, floorId) == "enemys" || core.getBlockCls(mx, y, floorId) == "enemy48") continue; - if (core.noPass(mx, y, floorId) && core.getBlockNumber(mx, y, floorId) != 141 && core.getBlockNumber(mx, y, floorId) != 151) { + if ( + core.getBlockCls(mx, y, floorId) == 'enemys' || + core.getBlockCls(mx, y, floorId) == 'enemy48' + ) + continue; + if ( + core.noPass(mx, y, floorId) && + core.getBlockNumber(mx, y, floorId) != 141 && + core.getBlockNumber(mx, y, floorId) != 151 + ) { beyondVisual = true; break; } @@ -1342,17 +1811,40 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = beyondVisual = false; continue; } - if (nx != x && !(core.getBlockCls(nx, y, floorId) == "enemys" || core.getBlockCls(nx, y, floorId) == "enemy48")) { - damage[currloc] = (damage[currloc] || 0) + Math.max((enemy.atk || 0) - core.getRealStatusOrDefault(null, 'def'), 0); + if ( + nx != x && + !( + core.getBlockCls(nx, y, floorId) == 'enemys' || + core.getBlockCls(nx, y, floorId) == 'enemy48' + ) + ) { + damage[currloc] = + (damage[currloc] || 0) + + Math.max( + (enemy.atk || 0) - + core.getRealStatusOrDefault( + null, + 'def' + ), + 0 + ); type[currloc] = type[currloc] || {}; - type[currloc]["射击伤害"] = true; + type[currloc]['射击伤害'] = true; } } for (var ny = 0; ny < height; ny++) { - var currloc = x + "," + ny; + var currloc = x + ',' + ny; for (var my = ny; my != y; my > y ? my-- : my++) { - if (core.getBlockCls(x, my, floorId) == "enemys" || core.getBlockCls(x, my, floorId) == "enemy48") continue; - if (core.noPass(x, my, floorId) && core.getBlockNumber(x, my, floorId) != 141 && core.getBlockNumber(x, my, floorId) != 151) { + if ( + core.getBlockCls(x, my, floorId) == 'enemys' || + core.getBlockCls(x, my, floorId) == 'enemy48' + ) + continue; + if ( + core.noPass(x, my, floorId) && + core.getBlockNumber(x, my, floorId) != 141 && + core.getBlockNumber(x, my, floorId) != 151 + ) { beyondVisual = true; break; } @@ -1361,24 +1853,50 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = beyondVisual = false; continue; } - if (ny != y && !(core.getBlockCls(x, ny, floorId) == "enemys" || core.getBlockCls(x, ny, floorId) == "enemy48")) { - damage[currloc] = (damage[currloc] || 0) + Math.max((enemy.atk || 0) - core.getRealStatusOrDefault(null, 'def'), 0); + if ( + ny != y && + !( + core.getBlockCls(x, ny, floorId) == 'enemys' || + core.getBlockCls(x, ny, floorId) == 'enemy48' + ) + ) { + damage[currloc] = + (damage[currloc] || 0) + + Math.max( + (enemy.atk || 0) - + core.getRealStatusOrDefault( + null, + 'def' + ), + 0 + ); if (damage < 0) damage = 0; type[currloc] = type[currloc] || {}; - type[currloc]["射击伤害"] = true; + type[currloc]['射击伤害'] = true; } } } // 捕捉 // 如果要防止捕捉效果,可以直接简单的将 flag:no_ambush 设为true - if (enemy && core.enemys.hasSpecial(enemy.special, 27) && !core.hasFlag("no_ambush")) { + if ( + enemy && + core.enemys.hasSpecial(enemy.special, 27) && + !core.hasFlag('no_ambush') + ) { // 给周围格子加上【捕捉】记号 for (var dir in core.utils.scan) { var nx = x + core.utils.scan[dir].x, ny = y + core.utils.scan[dir].y, - currloc = nx + "," + ny; - if (nx < 0 || nx >= width || ny < 0 || ny >= height || !core.canMoveHero(x, y, dir, floorId)) continue; + currloc = nx + ',' + ny; + if ( + nx < 0 || + nx >= width || + ny < 0 || + ny >= height || + !core.canMoveHero(x, y, dir, floorId) + ) + continue; ambush[currloc] = (ambush[currloc] || []).concat([ [x, y, id, dir] ]); @@ -1387,12 +1905,17 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 夹击;在这里提前计算所有可能的夹击点,具体计算逻辑在下面 // 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true - if (enemy && core.enemys.hasSpecial(enemy.special, 16) && !core.hasFlag('no_betweenAttack')) { + if ( + enemy && + core.enemys.hasSpecial(enemy.special, 16) && + !core.hasFlag('no_betweenAttack') + ) { for (var dir in core.utils.scan) { var nx = x + core.utils.scan[dir].x, ny = y + core.utils.scan[dir].y, - currloc = nx + "," + ny; - if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue; + currloc = nx + ',' + ny; + if (nx < 0 || nx >= width || ny < 0 || ny >= height) + continue; betweenAttackLocs[currloc] = true; } } @@ -1401,29 +1924,46 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var specialFlag = core.getSpecialFlag(enemy); if (specialFlag & 1) needCache = true; if (core.status.event.id == 'viewMaps') needCache = true; - if ((core.status.event.id == 'book' || core.status.event.id == 'bool-detail') && core.status.event.ui) needCache = true; + if ( + (core.status.event.id == 'book' || + core.status.event.id == 'bool-detail') && + core.status.event.ui + ) + needCache = true; if (specialFlag & 2) haveHunt = true; } // 对每个可能的夹击点计算夹击伤害 for (var loc in betweenAttackLocs) { - var xy = loc.split(","), + var xy = loc.split(','), x = parseInt(xy[0]), y = parseInt(xy[1]); // 夹击怪物的ID var enemyId1 = null, enemyId2 = null; // 检查左右夹击 - var leftBlock = blocks[(x - 1) + "," + y], - rightBlock = blocks[(x + 1) + "," + y]; - if (leftBlock && !leftBlock.disable && rightBlock && !rightBlock.disable && leftBlock.id == rightBlock.id) { + var leftBlock = blocks[x - 1 + ',' + y], + rightBlock = blocks[x + 1 + ',' + y]; + if ( + leftBlock && + !leftBlock.disable && + rightBlock && + !rightBlock.disable && + leftBlock.id == rightBlock.id + ) { if (core.hasSpecial(leftBlock.event.id, 16)) enemyId1 = leftBlock.event.id; } // 检查上下夹击 - var topBlock = blocks[x + "," + (y - 1)], - bottomBlock = blocks[x + "," + (y + 1)]; - if (topBlock && !topBlock.disable && bottomBlock && !bottomBlock.disable && topBlock.id == bottomBlock.id) { + var topBlock = blocks[x + ',' + (y - 1)], + bottomBlock = blocks[x + ',' + (y + 1)]; + if ( + topBlock && + !topBlock.disable && + bottomBlock && + !bottomBlock.disable && + topBlock.id == bottomBlock.id + ) { if (core.hasSpecial(topBlock.event.id, 16)) enemyId2 = topBlock.event.id; } @@ -1435,17 +1975,27 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var value = Math.floor(leftHp / 2); // 是否不超过怪物伤害值 if (core.flags.betweenAttackMax) { - var enemyDamage1 = core.getDamage(enemyId1, x, y, floorId); + var enemyDamage1 = core.getDamage( + enemyId1, + x, + y, + floorId + ); if (enemyDamage1 != null && enemyDamage1 < value) value = enemyDamage1; - var enemyDamage2 = core.getDamage(enemyId2, x, y, floorId); + var enemyDamage2 = core.getDamage( + enemyId2, + x, + y, + floorId + ); if (enemyDamage2 != null && enemyDamage2 < value) value = enemyDamage2; } if (value > 0) { damage[loc] = (damage[loc] || 0) + value; type[loc] = type[loc] || {}; - type[loc]["夹击伤害"] = true; + type[loc]['夹击伤害'] = true; } } } @@ -1469,7 +2019,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = haveHunt: haveHunt }; }, - "moveOneStep": function (callback) { + moveOneStep: function (callback) { // 勇士每走一步后执行的操作。callback为行走完毕后的回调 // 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。 // 请注意:瞬间移动不会执行该函数。如果要控制能否瞬间移动有三种方法: @@ -1496,8 +2046,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = nowy = core.getHeroLoc('y'); var block = core.getBlock(nowx, nowy); var hasTrigger = false; - if (block != null && block.event.trigger == 'getItem' && - !core.floors[core.status.floorId].afterGetItem[nowx + "," + nowy]) { + if ( + block != null && + block.event.trigger == 'getItem' && + !core.floors[core.status.floorId].afterGetItem[ + nowx + ',' + nowy + ] + ) { hasTrigger = true; core.trigger(nowx, nowy, callback); } @@ -1505,22 +2060,29 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.checkBlock(); // 执行目标点的script和事件 - if (core.status.floorId == "tower6") - core.setMapBlockDisabled("tower6", nowx, nowy, false); - if (!hasTrigger) - core.trigger(nowx, nowy, callback); + if (core.status.floorId == 'tower6') + core.setMapBlockDisabled('tower6', nowx, nowy, false); + if (!hasTrigger) core.trigger(nowx, nowy, callback); // 检查该点是否是滑冰 if (core.onSki()) { // 延迟到事件最后执行,因为这之前可能有阻激夹域动画 - core.insertAction({ "type": "moveAction" }, null, null, null, true); + core.insertAction( + { type: 'moveAction' }, + null, + null, + null, + true + ); } // 追猎 if (core.status.checkBlock.haveHunt) { var x = core.status.hero.loc.x, y = core.status.hero.loc.y; - core.status.maps[core.status.floorId].blocks.forEach(function (block) { + core.status.maps[core.status.floorId].blocks.forEach(function ( + block + ) { if (block.x != x && block.y != y) return; var id = block.event.id, enemy = core.material.enemys[id]; @@ -1530,61 +2092,105 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var dx = Math.abs(x - nx), dy = Math.abs(y - ny); if (x == block.x) { - if (y > block.y && !core.noPass(block.x, block.y + 1) && core.getBlockCls(block.x, block.y + 1) != 'items') { + if ( + y > block.y && + !core.noPass(block.x, block.y + 1) && + core.getBlockCls(block.x, block.y + 1) != + 'items' + ) { dy--; ny++; core.insertAction([ - { "type": "move", "loc": [block.x, block.y], "time": 200, "keep": true, "steps": ["down:1"] }, { - "type": "if", - "condition": dy + "<=1", - "true": [ - { "type": "battle", "loc": [nx, ny] }, - ] + type: 'move', + loc: [block.x, block.y], + time: 200, + keep: true, + steps: ['down:1'] }, + { + type: 'if', + condition: dy + '<=1', + true: [ + { type: 'battle', loc: [nx, ny] } + ] + } ]); } - if (y < block.y && !core.noPass(block.x, block.y - 1) && core.getBlockCls(block.x, block.y - 1) != 'items') { + if ( + y < block.y && + !core.noPass(block.x, block.y - 1) && + core.getBlockCls(block.x, block.y - 1) != + 'items' + ) { dy--; ny--; core.insertAction([ - { "type": "move", "loc": [block.x, block.y], "time": 200, "keep": true, "steps": ["up:1"] }, { - "type": "if", - "condition": dy + "<=1", - "true": [ - { "type": "battle", "loc": [nx, ny] }, - ] + type: 'move', + loc: [block.x, block.y], + time: 200, + keep: true, + steps: ['up:1'] }, + { + type: 'if', + condition: dy + '<=1', + true: [ + { type: 'battle', loc: [nx, ny] } + ] + } ]); } } else { - if (x > block.x && !core.noPass(block.x + 1, block.y) && core.getBlockCls(block.x + 1, block.y) != 'items') { + if ( + x > block.x && + !core.noPass(block.x + 1, block.y) && + core.getBlockCls(block.x + 1, block.y) != + 'items' + ) { dx--; nx++; core.insertAction([ - { "type": "move", "loc": [block.x, block.y], "time": 200, "keep": true, "steps": ["right:1"] }, { - "type": "if", - "condition": dx + "<=1", - "true": [ - { "type": "battle", "loc": [nx, ny] }, - ] + type: 'move', + loc: [block.x, block.y], + time: 200, + keep: true, + steps: ['right:1'] }, + { + type: 'if', + condition: dx + '<=1', + true: [ + { type: 'battle', loc: [nx, ny] } + ] + } ]); } - if (x < block.x && !core.noPass(block.x - 1, block.y) && core.getBlockCls(block.x - 1, block.y) != 'items') { + if ( + x < block.x && + !core.noPass(block.x - 1, block.y) && + core.getBlockCls(block.x - 1, block.y) != + 'items' + ) { dx--; nx--; core.insertAction([ - { "type": "move", "loc": [block.x, block.y], "time": 200, "keep": true, "steps": ["left:1"] }, { - "type": "if", - "condition": dx + "<=1", - "true": [ - { "type": "battle", "loc": [nx, ny] }, - ] + type: 'move', + loc: [block.x, block.y], + time: 200, + keep: true, + steps: ['left:1'] }, + { + type: 'if', + condition: dx + '<=1', + true: [ + { type: 'battle', loc: [nx, ny] } + ] + } ]); } } @@ -1595,7 +2201,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 如需强行终止行走可以在这里条件判定: // core.stopAutomaticRoute(); }, - "moveDirectly": function (x, y, ignoreSteps) { + moveDirectly: function (x, y, ignoreSteps) { // 瞬间移动;x,y为要瞬间移动的点;ignoreSteps为减少的步数,可能之前已经被计算过 // 返回true代表成功瞬移,false代表没有成功瞬移 @@ -1613,7 +2219,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.clearMap('hero'); // 获得勇士最后的朝向 - var lastDirection = core.status.route[core.status.route.length - 1]; + var lastDirection = + core.status.route[core.status.route.length - 1]; if (['left', 'right', 'up', 'down'].indexOf(lastDirection) >= 0) core.setHeroLoc('direction', lastDirection); // 设置坐标,并绘制 @@ -1621,7 +2228,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setHeroLoc('y', y); core.drawHero(); // 记录录像 - core.status.route.push("move:" + x + ":" + y); + core.status.route.push('move:' + x + ':' + y); // 统计信息 core.status.hero.statistics.moveDirectly++; core.status.hero.statistics.ignoreSteps += ignoreSteps; @@ -1633,7 +2240,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } return false; }, - "parallelDo": function (timestamp) { + parallelDo: function (timestamp) { // 并行事件处理,可以在这里写任何需要并行处理的脚本或事件 // 该函数将被系统反复执行,每次执行间隔视浏览器或设备性能而定,一般约为16.6ms一次 // 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差,以毫秒为单位 @@ -1651,18 +2258,20 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } } }, - "ui": { - "getToolboxItems": function (cls) { + ui: { + getToolboxItems: function (cls) { // 获得道具栏中当前某类型道具的显示项和显示顺序 // cls为道具类型,只可能是 tools, constants 和 equips // 返回一个数组,代表当前某类型道具的显示内容和顺序 // 默认按id升序排列,您可以取消下面的注释改为按名称排列 return Object.keys(core.status.hero.items[cls] || {}) - .filter(function (id) { return !core.material.items[id].hideInToolbox; }) - .sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/); + .filter(function (id) { + return !core.material.items[id].hideInToolbox; + }) + .sort(/*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/); }, - "drawStatusBar": function () { + drawStatusBar: function () { // 自定义绘制状态栏,需要开启状态栏canvas化 // 如果是非状态栏canvas化,直接返回 @@ -1680,7 +2289,11 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 竖屏模式下的画布大小是 480*(32*rows+9) 其中rows为状态栏行数,即全塔属性中statusCanvasRowsOnMobile值 // 可以使用 core.domStyle.isVertical 来判定当前是否是竖屏模式 - core.setFillStyle(ctx, core.status.globalAttribute.statusBarColor || core.initStatus.globalAttribute.statusBarColor); + core.setFillStyle( + ctx, + core.status.globalAttribute.statusBarColor || + core.initStatus.globalAttribute.statusBarColor + ); // 属性 var hp = core.getRealStatus('hp'), // 生命 atk = core.getRealStatus('atk'), // 攻击 @@ -1698,7 +2311,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (!core.domStyle.isVertical) { // 横屏模式 // 背景 - ctx.shadowColor = "rgba(0, 0, 0, 0.4)"; + ctx.shadowColor = 'rgba(0, 0, 0, 0.4)'; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; ctx.shadowBlur = 7; @@ -1708,47 +2321,169 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = ctx.shadowOffsetY = 2; ctx.shadowBlur = 3; // 技能名 - core.setTextAlign(ctx, "right"); + core.setTextAlign(ctx, 'right'); if (flags.blade && flags.bladeOn) - core.fillBoldText(ctx, "断灭之刃", 145, 47, "#ffffff", "#cc3333", "16px normal"); - core.setTextAlign(ctx, "left"); + core.fillBoldText( + ctx, + '断灭之刃', + 145, + 47, + '#ffffff', + '#cc3333', + '16px normal' + ); + core.setTextAlign(ctx, 'left'); // 楼层名+等级名 - core.fillBoldText(ctx, (core.status.thisMap || {}).title || "", 10, 22, "#ffffff", "#000000", "20px normal"); - core.drawLine(ctx, 5, 27, 144, 27, "#ffffff", 2); - core.drawLine(ctx, 85, 49, 144, 49, "#ffffff", 1); - ctx.beginPath() + core.fillBoldText( + ctx, + (core.status.thisMap || {}).title || '', + 10, + 22, + '#ffffff', + '#000000', + '20px normal' + ); + core.drawLine(ctx, 5, 27, 144, 27, '#ffffff', 2); + core.drawLine(ctx, 85, 49, 144, 49, '#ffffff', 1); + ctx.beginPath(); ctx.moveTo(55, 27); ctx.bezierCurveTo(75, 27, 70, 49, 85, 49); ctx.stroke(); ctx.beginPath(); - core.fillBoldText(ctx, core.getLvName(), 10, 47, "#ffffff", "#000000", "20px normal"); + core.fillBoldText( + ctx, + core.getLvName(), + 10, + 47, + '#ffffff', + '#000000', + '20px normal' + ); // 各个属性 - core.drawImage(ctx, "hp.png", 5, 55, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(hp), 42, 80, "#ffffff", "#000000", "27px normal"); + core.drawImage(ctx, 'hp.png', 5, 55, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(hp), + 42, + 80, + '#ffffff', + '#000000', + '27px normal' + ); // 生命回复 - core.fillBoldText(ctx, "+" + core.formatBigNumber(recovery) + "/t", 100, 95, "#ffffff", "#00cc00", "16px normal"); + core.fillBoldText( + ctx, + '+' + core.formatBigNumber(recovery) + '/t', + 100, + 95, + '#ffffff', + '#00cc00', + '16px normal' + ); // 治愈之泉 - if (core.hasFlag("spring")) - core.fillBoldText(ctx, "剩余" + (50 - core.getFlag("springCount", 0)), 90, 60, "#ffffff", "#00cc00", "16px normal"); + if (core.hasFlag('spring')) + core.fillBoldText( + ctx, + '剩余' + (50 - core.getFlag('springCount', 0)), + 90, + 60, + '#ffffff', + '#00cc00', + '16px normal' + ); // 额外攻击 - core.fillBoldText(ctx, "+" + core.formatBigNumber(extraAtk), 100, 127, "#ffffff", "#cc6666", "16px normal"); + core.fillBoldText( + ctx, + '+' + core.formatBigNumber(extraAtk), + 100, + 127, + '#ffffff', + '#cc6666', + '16px normal' + ); // 其他 - core.drawImage(ctx, "atk.png", 5, 87, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(atk), 42, 112, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "def.png", 5, 119, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(def), 42, 144, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "IQ.png", 5, 151, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(inte), 42, 176, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "money.png", 5, 183, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(core.getRealStatusOrDefault(null, "money")), 42, 208, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "exp.png", 5, 215, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(core.getNextLvUpNeed() || 0), 42, 240, "#ffffff", "#000000", "27px normal"); + core.drawImage(ctx, 'atk.png', 5, 87, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(atk), + 42, + 112, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'def.png', 5, 119, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(def), + 42, + 144, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'IQ.png', 5, 151, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(inte), + 42, + 176, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'money.png', 5, 183, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber( + core.getRealStatusOrDefault(null, 'money') + ), + 42, + 208, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'exp.png', 5, 215, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(core.getNextLvUpNeed() || 0), + 42, + 240, + '#ffffff', + '#000000', + '27px normal' + ); // 绘制三色钥匙 - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('yellowKey')), 15, 270, "#ffccaa", "#000000", "bold 27px normal"); - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('blueKey')), 55, 270, "#aaaadd", "#000000", "bold 27px normal"); - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('redKey')), 95, 270, "#ff8888", "#000000", "bold 27px normal"); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('yellowKey')), + 15, + 270, + '#ffccaa', + '#000000', + 'bold 27px normal' + ); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('blueKey')), + 55, + 270, + '#aaaadd', + '#000000', + 'bold 27px normal' + ); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('redKey')), + 95, + 270, + '#ff8888', + '#000000', + 'bold 27px normal' + ); // 技能树 和 技能查看 - if (core.getFlag("chapter", 0) > 0) { + if (core.getFlag('chapter', 0) > 0) { // core.fillRect(ctx, 20, 320, 109, 30, "#ffffff"); // core.fillRect(ctx, 20, 280, 109, 30, "#ffffff"); ctx.shadowOffsetX = 0; @@ -1758,18 +2493,34 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.drawImage(ctx, 'botton.png', 20, 280, 109, 30); // core.fillRect(ctx, 21, 321, 107, 28, "#ffffff"); // core.fillRect(ctx, 21, 281, 107, 28, "#ffffff"); - core.setTextAlign(ctx, "center"); + core.setTextAlign(ctx, 'center'); ctx.shadowOffsetX = 3; ctx.shadowOffsetY = 2; ctx.shadowBlur = 3; - core.fillBoldText(ctx, "技能树", 75, 340, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "查看技能", 75, 300, "#ffffff", "#000000", "20px normal"); - core.setTextAlign(ctx, "left"); + core.fillBoldText( + ctx, + '技能树', + 75, + 340, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '查看技能', + 75, + 300, + '#ffffff', + '#000000', + '20px normal' + ); + core.setTextAlign(ctx, 'left'); } } else { // 竖屏模式 // css - ctx.shadowColor = "rgba(0, 0, 0, 0.4)"; + ctx.shadowColor = 'rgba(0, 0, 0, 0.4)'; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; ctx.shadowBlur = 7; @@ -1779,85 +2530,321 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = ctx.shadowOffsetY = 2; ctx.shadowBlur = 3; // 各个属性 - core.setTextAlign(ctx, "left"); - core.drawImage(ctx, "hp.png", 5, 4, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(hp), 42, 29, "#ffffff", "#000000", "27px normal"); + core.setTextAlign(ctx, 'left'); + core.drawImage(ctx, 'hp.png', 5, 4, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(hp), + 42, + 29, + '#ffffff', + '#000000', + '27px normal' + ); // 治愈之泉 - if (core.hasFlag("spring")) - core.fillBoldText(ctx, "剩余" + (50 - core.getFlag("springCount", 0)), 220, 41, "#ffffff", "#00cc00", "16px normal"); + if (core.hasFlag('spring')) + core.fillBoldText( + ctx, + '剩余' + (50 - core.getFlag('springCount', 0)), + 220, + 41, + '#ffffff', + '#00cc00', + '16px normal' + ); // 生命回复 - core.fillBoldText(ctx, "+" + core.formatBigNumber(recovery) + "/t", 100, 41, "#ffffff", "#00cc00", "16px normal"); + core.fillBoldText( + ctx, + '+' + core.formatBigNumber(recovery) + '/t', + 100, + 41, + '#ffffff', + '#00cc00', + '16px normal' + ); // 额外攻击 - core.fillBoldText(ctx, "+" + core.formatBigNumber(extraAtk), 100, 76, "#ffffff", "#cc6666", "16px normal"); - core.drawImage(ctx, "atk.png", 5, 36, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(atk), 42, 61, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "def.png", 5, 68, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(def), 42, 93, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "IQ.png", 145, 4, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(inte), 182, 29, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "money.png", 145, 36, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(core.getRealStatusOrDefault(null, "money")), 182, 61, "#ffffff", "#000000", "27px normal"); - core.drawImage(ctx, "exp.png", 145, 68, 32, 32); - core.fillBoldText(ctx, core.formatBigNumber(core.getNextLvUpNeed() || 0), 182, 93, "#ffffff", "#000000", "27px normal"); + core.fillBoldText( + ctx, + '+' + core.formatBigNumber(extraAtk), + 100, + 76, + '#ffffff', + '#cc6666', + '16px normal' + ); + core.drawImage(ctx, 'atk.png', 5, 36, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(atk), + 42, + 61, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'def.png', 5, 68, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(def), + 42, + 93, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'IQ.png', 145, 4, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(inte), + 182, + 29, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'money.png', 145, 36, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber( + core.getRealStatusOrDefault(null, 'money') + ), + 182, + 61, + '#ffffff', + '#000000', + '27px normal' + ); + core.drawImage(ctx, 'exp.png', 145, 68, 32, 32); + core.fillBoldText( + ctx, + core.formatBigNumber(core.getNextLvUpNeed() || 0), + 182, + 93, + '#ffffff', + '#000000', + '27px normal' + ); // 楼层名 + 等级名 + 技能名 - core.setTextAlign(ctx, "right"); - core.fillBoldText(ctx, (core.status.thisMap || {}).title || "", 385, 52, "#ffffff", "#000000", "20px normal"); - core.drawLine(ctx, 282, 57, 390, 57, "#ffffff", 2); - core.drawLine(ctx, 312, 82, 390, 82, "#ffffff", 1); - core.fillBoldText(ctx, core.getLvName(), 385, 77, "#ffffff", "#000000", "20px normal"); + core.setTextAlign(ctx, 'right'); + core.fillBoldText( + ctx, + (core.status.thisMap || {}).title || '', + 385, + 52, + '#ffffff', + '#000000', + '20px normal' + ); + core.drawLine(ctx, 282, 57, 390, 57, '#ffffff', 2); + core.drawLine(ctx, 312, 82, 390, 82, '#ffffff', 1); + core.fillBoldText( + ctx, + core.getLvName(), + 385, + 77, + '#ffffff', + '#000000', + '20px normal' + ); if (flags.blade && flags.bladeOn) - core.fillBoldText(ctx, "断灭之刃", 385, 97, "#ffffff", "#cc3333", "16px normal"); - core.setTextAlign(ctx, "left"); + core.fillBoldText( + ctx, + '断灭之刃', + 385, + 97, + '#ffffff', + '#cc3333', + '16px normal' + ); + core.setTextAlign(ctx, 'left'); // 技能树 查看技能 - if (core.getFlag("chapter", 0) > 0) { + if (core.getFlag('chapter', 0) > 0) { // core.fillRect(ctx, 400, 10, 30, 85, "#ffffff"); // core.fillRect(ctx, 440, 10, 30, 85, "#ffffff"); ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; ctx.shadowBlur = 5; - core.drawImage(ctx, 'botton.png', 0, 0, 190, 60, 375, 40, 85, 30, -Math.PI / 2); - core.drawImage(ctx, 'botton.png', 0, 0, 190, 60, 415, 40, 85, 30, -Math.PI / 2); + core.drawImage( + ctx, + 'botton.png', + 0, + 0, + 190, + 60, + 375, + 40, + 85, + 30, + -Math.PI / 2 + ); + core.drawImage( + ctx, + 'botton.png', + 0, + 0, + 190, + 60, + 415, + 40, + 85, + 30, + -Math.PI / 2 + ); // core.fillRect(ctx, 401, 11, 28, 83, "#ffffff"); // core.fillRect(ctx, 441, 11, 28, 83, "#ffffff"); - core.setTextAlign(ctx, "center"); + core.setTextAlign(ctx, 'center'); ctx.shadowOffsetX = 3; ctx.shadowOffsetY = 2; ctx.shadowBlur = 3; - core.setTextAlign(ctx, "center"); - core.fillBoldText(ctx, "技", 415, 42, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "能", 415, 62, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "树", 415, 82, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "查", 455, 30, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "看", 455, 50, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "技", 455, 70, "#ffffff", "#000000", "20px normal"); - core.fillBoldText(ctx, "能", 455, 90, "#ffffff", "#000000", "20px normal"); - core.setTextAlign(ctx, "left"); + core.setTextAlign(ctx, 'center'); + core.fillBoldText( + ctx, + '技', + 415, + 42, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '能', + 415, + 62, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '树', + 415, + 82, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '查', + 455, + 30, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '看', + 455, + 50, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '技', + 455, + 70, + '#ffffff', + '#000000', + '20px normal' + ); + core.fillBoldText( + ctx, + '能', + 455, + 90, + '#ffffff', + '#000000', + '20px normal' + ); + core.setTextAlign(ctx, 'left'); } // 绘制三色钥匙 - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('yellowKey')), 282, 29, '#FFCCAA', '#000000', "bold 27px normal"); - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('blueKey')), 317, 29, '#AAAADD', '#000000', "bold 27px normal"); - core.fillBoldText(ctx, core.setTwoDigits(core.itemCount('redKey')), 352, 29, '#FF8888', '#000000', "bold 27px normal"); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('yellowKey')), + 282, + 29, + '#FFCCAA', + '#000000', + 'bold 27px normal' + ); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('blueKey')), + 317, + 29, + '#AAAADD', + '#000000', + 'bold 27px normal' + ); + core.fillBoldText( + ctx, + core.setTwoDigits(core.itemCount('redKey')), + 352, + 29, + '#FF8888', + '#000000', + 'bold 27px normal' + ); } }, - "drawStatistics": function () { + drawStatistics: function () { // 浏览地图时参与的统计项目 return [ - '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', + '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' // 在这里可以增加新的ID来进行统计个数,只能增加道具ID ]; }, - "drawAbout": function () { + drawAbout: function () { // 绘制“关于”界面 core.ui.closePanel(); core.lockControl(); @@ -1871,19 +2858,47 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.setAlpha('ui', 0.85); core.fillRect('ui', left, top, right, bottom, '#000000'); core.setAlpha('ui', 1); - core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); + core.strokeRect( + 'ui', + left - 1, + top - 1, + right + 1, + bottom + 1, + '#FFFFFF', + 2 + ); var text_start = left + 24; // 名称 core.setTextAlign('ui', 'left'); - var globalAttribute = core.status.globalAttribute || core.initStatus.globalAttribute; - core.fillText('ui', "HTML5 魔塔样板", text_start, top + 35, globalAttribute.selectColor, "bold 22px " + globalAttribute.font); - core.fillText('ui', "版本: " + main.__VERSION__, text_start, top + 80, "#FFFFFF", "bold 17px " + globalAttribute.font); - core.fillText('ui', "作者: 艾之葵", text_start, top + 112); - core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top + 112 + 32); + var globalAttribute = + core.status.globalAttribute || core.initStatus.globalAttribute; + core.fillText( + 'ui', + 'HTML5 魔塔样板', + text_start, + top + 35, + globalAttribute.selectColor, + 'bold 22px ' + globalAttribute.font + ); + core.fillText( + 'ui', + '版本: ' + main.__VERSION__, + text_start, + top + 80, + '#FFFFFF', + 'bold 17px ' + globalAttribute.font + ); + core.fillText('ui', '作者: 艾之葵', text_start, top + 112); + core.fillText( + 'ui', + 'HTML5魔塔交流群:539113091', + text_start, + top + 112 + 32 + ); // TODO: 写自己的“关于”页面,每次增加32像素即可 core.playSound('打开界面'); } } -} \ No newline at end of file +}; diff --git a/public/project/plugins.js b/public/project/plugins.js index c1f88ad..5aa1d73 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -1,10 +1,8 @@ -/// var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { - "init": function () { - this._afterLoadResources = function () { } + init: function () { + this._afterLoadResources = function () {}; }, - "sprite": function () { - + sprite: function () { const sprites = {}; // 终于能用es6了(恼 @@ -26,7 +24,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.init(); } - init () { + init() { const name = this.name || `_sprite_${Sprite.count}`; this.name = name; if (this.reference === 'window') { @@ -43,7 +41,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { canvas.style.zIndex = this.zIndex.toString(); document.body.appendChild(canvas); } else { - this.context = core.createCanvas(name, this.x, this.y, this.width, this.height, this.zIndex); + this.context = core.createCanvas( + name, + this.x, + this.y, + this.width, + this.height, + this.zIndex + ); this.canvas = this.context.canvas; this.count = Sprite.count; this.canvas.style.pointerEvents = 'auto'; @@ -52,7 +57,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { sprites[this.name] = this; } - setCss (css) { + setCss(css) { css = css.replace('\n', ';').replace(';;', ';'); const effects = css.split(';'); const canvas = this.canvas; @@ -60,38 +65,35 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const content = v.split(':'); let name = content[0]; let value = content[1]; - name = name.trim().split('-').reduce((pre, curr, i, a) => { - if (i === 0 && curr !== '') - return curr; - if (a[0] === '' && i === 1) - return curr; - return pre + curr.toUpperCase()[0] + curr.slice(1); - }, ''); - if (name in canvas.style) - canvas.style[name] = value; + name = name + .trim() + .split('-') + .reduce((pre, curr, i, a) => { + if (i === 0 && curr !== '') return curr; + if (a[0] === '' && i === 1) return curr; + return pre + curr.toUpperCase()[0] + curr.slice(1); + }, ''); + if (name in canvas.style) canvas.style[name] = value; }); return this; } - move (x, y, isDelta) { - if (x !== undefined && x !== null) - this.x = x; - if (y !== undefined && y !== null) - this.y = y; + move(x, y, isDelta) { + if (x !== undefined && x !== null) this.x = x; + if (y !== undefined && y !== null) this.y = y; if (this.reference === 'window') { var ele = this.canvas; - ele.style.left = x + (isDelta ? parseFloat(ele.style.left) : 0) + 'px'; - ele.style.top = y + (isDelta ? parseFloat(ele.style.top) : 0) + 'px'; - } else - core.relocateCanvas(this.context, x, y, isDelta); + ele.style.left = + x + (isDelta ? parseFloat(ele.style.left) : 0) + 'px'; + ele.style.top = + y + (isDelta ? parseFloat(ele.style.top) : 0) + 'px'; + } else core.relocateCanvas(this.context, x, y, isDelta); return this; } - resize (w, h, styleOnly) { - if (w !== undefined && w !== null) - this.width = w; - if (h !== undefined && h !== null) - this.height = h; + resize(w, h, styleOnly) { + if (w !== undefined && w !== null) this.width = w; + if (h !== undefined && h !== null) this.height = h; if (this.reference === 'window') { const ele = this.canvas; ele.style.width = w + 'px'; @@ -100,16 +102,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { ele.width = w; ele.height = h; } - } else - core.resizeCanvas(this.context, w, h, styleOnly); + } else core.resizeCanvas(this.context, w, h, styleOnly); return this; } - rotate (angle, cx, cy) { + rotate(angle, cx, cy) { if (this.reference === 'window') { const left = this.x; const top = this.y; - this.canvas.style.transformOrigin = (cx - left) + 'px ' + (cy - top) + 'px'; + this.canvas.style.transformOrigin = + cx - left + 'px ' + (cy - top) + 'px'; if (angle === 0) { canvas.style.transform = ''; } else { @@ -121,40 +123,54 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return this; } - destroy () { + destroy() { if (this.reference === 'window') { - if (this.canvas) - document.body.removeChild(this.canvas); + if (this.canvas) document.body.removeChild(this.canvas); } else { core.deleteCanvas(this.name); } - this.key?.forEach(v => document.removeEventListener(v[0], v[1])); + this.key?.forEach(v => + document.removeEventListener(v[0], v[1]) + ); sprites[this.name] = void 0; } /** * 类似样板registerAction接口,但是是以该sprite的左上角为(0,0)计算的 - * @param {keyof HTMLElementEventMap} type - * @param {(...param: any[]) => void} handler + * @param {keyof HTMLElementEventMap} type + * @param {(...param: any[]) => void} handler */ - on (type, handler) { - if (this.reference !== 'game') throw new ReferenceError(`当sprite的reference为window时,不可使用该函数`); + on(type, handler) { + if (this.reference !== 'game') + throw new ReferenceError( + `当sprite的reference为window时,不可使用该函数` + ); const mouse = [ - 'auxclick', 'click', 'contextmenu', 'dblclick', 'mousedown', 'mouseup', - 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover' - ]; - const key = [ - 'keydown', 'keypress', 'keyup' + 'auxclick', + 'click', + 'contextmenu', + 'dblclick', + 'mousedown', + 'mouseup', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover' ]; + const key = ['keydown', 'keypress', 'keyup']; const touch = [ - 'touchstart', 'touchend', 'touchcancel', 'touchmove' - ] + 'touchstart', + 'touchend', + 'touchcancel', + 'touchmove' + ]; if (mouse.includes(type)) { this.addEventListener(type, e => { const px = e.offsetX / core.domStyle.scale, py = e.offsetY / core.domStyle.scale; handler(px, py); - }) + }); } else if (type === 'wheel') { this.addEventListener('wheel', e => { handler(e.deltaY, e.deltaX, e.deltaZ); @@ -162,10 +178,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } else if (key.includes(type)) { // 键盘事件只能加到document上 const listener = e => { - handler(e.key, e.keyCode, e.altKey, e.ctrlKey, e.shiftKey); - } + handler( + e.key, + e.keyCode, + e.altKey, + e.ctrlKey, + e.shiftKey + ); + }; this.key.push([type, listener]); - document.addEventListener(type, listener) + document.addEventListener(type, listener); } else if (touch.includes(type)) { this.addEventListener(type, e => { /** @type {TouchList} */ @@ -173,21 +195,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const locs = []; for (let i = 0; i < touches.length; i++) { const t = touches[i]; - const { x, y } = core.actions._getClickLoc(t.clientX, t.clientY); + const { x, y } = core.actions._getClickLoc( + t.clientX, + t.clientY + ); const px = x / core.domStyle.scale, py = y / core.domStyle.scale; locs.push([px, py]); } handler(...locs); - }) + }); } } - addEventListener () { + addEventListener() { this.canvas.addEventListener.apply(this.canvas, arguments); } - removeEventListener () { + removeEventListener() { this.canvas.removeEventListener.apply(this.canvas, arguments); } } @@ -196,78 +221,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const s = sprites[name]; if (!s) throw new ReferenceError(`不能获得不存在的sprite`); return sprites[name]; - } + }; Sprite.count = 0; window.Sprite = Sprite; }, - "ref": function () { - // vue的ref功能,(魔法,这真的是魔法,有点功底的可以读一下,虽然功能上与vue差了很多 - // 根据鹿神的统计,不兼容proxy的玩家不到0.06%,所以放心使用proxy - - if (!Proxy) return alert('当前浏览器不支持proxy,无法使用响应性插件,请更新浏览器,建议使用edge或chrome'); - - /** - * 用于计算computed - */ - let changed = []; - - function ref (value) { - const target = { value }; - const handler = { - set (target, p, v) { - if (target.watch && p === 'value') { - target.watch(v, target.value); - } - target[p] = v; - if (target.computed && p === 'value') { - target.computed(); - } - }, - get (target, p) { - changed.push(ref); - return target[p]; - } - } - const ref = new Proxy(target, handler); - return ref; - } - - function watch (source, handler) { - source.watch = handler; - } - - function computed (handler) { - changed = []; - const res = ref(handler()); - const all = changed.slice(); - all.forEach(v => { - v.computed = () => res.value = handler(); - }) - return res; - } - - window.ref = ref; - window.watch = watch; - window.computed = computed; - }, - "shop": function () { + shop: function () { // 【全局商店】相关的功能 - // + // // 打开一个全局商店 // shopId:要打开的商店id;noRoute:是否不计入录像 this.openShop = function (shopId, noRoute) { var shop = core.status.shops[shopId]; // Step 1: 检查能否打开此商店 if (!this.canOpenShop(shopId)) { - core.drawTip("该商店尚未开启"); + core.drawTip('该商店尚未开启'); return false; } // Step 2: (如有必要)记录打开商店的脚本事件 if (!noRoute) { - core.status.route.push("shop:" + shopId); + core.status.route.push('shop:' + shopId); } // Step 3: 检查道具商店 or 公共事件 @@ -276,7 +251,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.openItemShop(shopId); } else { core.playSound('操作失败'); - core.insertAction("道具商店插件不存在!请检查是否存在该插件!"); + core.insertAction( + '道具商店插件不存在!请检查是否存在该插件!' + ); } return; } @@ -285,86 +262,134 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return; } - // Step 4: 执行标准公共商店 + // Step 4: 执行标准公共商店 core.insertAction(this._convertShop(shop)); return true; - } + }; ////// 将一个全局商店转变成可预览的公共事件 ////// this._convertShop = function (shop) { return [ - { "type": "function", "function": "() => {core.setFlag('@temp@shop', true);}" }, { - "type": "while", - "condition": "true", - "data": [ + type: 'function', + function: "() => {core.setFlag('@temp@shop', true);}" + }, + { + type: 'while', + condition: 'true', + data: [ // 检测能否访问该商店 { - "type": "if", - "condition": "core.isShopVisited('" + shop.id + "')", - "true": [ + type: 'if', + condition: "core.isShopVisited('" + shop.id + "')", + true: [ // 可以访问,直接插入执行效果 - { "type": "function", "function": "() => { core.plugin._convertShop_replaceChoices('" + shop.id + "', false) }" }, + { + type: 'function', + function: + "() => { core.plugin._convertShop_replaceChoices('" + + shop.id + + "', false) }" + } ], - "false": [ + false: [ // 不能访问的情况下:检测能否预览 { - "type": "if", - "condition": shop.disablePreview, - "true": [ + type: 'if', + condition: shop.disablePreview, + true: [ // 不可预览,提示并退出 - { "type": "playSound", "name": "操作失败" }, - "当前无法访问该商店!", - { "type": "break" }, + { type: 'playSound', name: '操作失败' }, + '当前无法访问该商店!', + { type: 'break' } ], - "false": [ + false: [ // 可以预览:将商店全部内容进行替换 - { "type": "tip", "text": "当前处于预览模式,不可购买" }, - { "type": "function", "function": "() => { core.plugin._convertShop_replaceChoices('" + shop.id + "', true) }" }, + { + type: 'tip', + text: '当前处于预览模式,不可购买' + }, + { + type: 'function', + function: + "() => { core.plugin._convertShop_replaceChoices('" + + shop.id + + "', true) }" + } ] } ] } ] }, - { "type": "function", "function": "() => {core.removeFlag('@temp@shop');}" } + { + type: 'function', + function: "() => {core.removeFlag('@temp@shop');}" + } ]; - } + }; this._convertShop_replaceChoices = function (shopId, previewMode) { var shop = core.status.shops[shopId]; - var choices = (shop.choices || []).filter((choice) => { - if (choice.condition == null || choice.condition == '') return true; - try { return core.calValue(choice.condition); } catch (e) { return true; } - }).map((choice) => { - var ableToBuy = core.calValue(choice.need); - return { - "text": choice.text, - "icon": choice.icon, - "color": ableToBuy && !previewMode ? choice.color : [153, 153, 153, 1], - "action": ableToBuy && !previewMode ? [{ "type": "playSound", "name": "确定" }].concat(choice.action) : [ - { "type": "playSound", "name": "操作失败" }, - { "type": "tip", "text": previewMode ? "预览模式下不可购买" : "购买条件不足" } - ] - }; - }).concat({ "text": "离开", "action": [{ "type": "break" }] }); - core.insertAction({ "type": "choices", "text": shop.text, "choices": choices }); - } + var choices = (shop.choices || []) + .filter(choice => { + if (choice.condition == null || choice.condition == '') + return true; + try { + return core.calValue(choice.condition); + } catch (e) { + return true; + } + }) + .map(choice => { + var ableToBuy = core.calValue(choice.need); + return { + text: choice.text, + icon: choice.icon, + color: + ableToBuy && !previewMode + ? choice.color + : [153, 153, 153, 1], + action: + ableToBuy && !previewMode + ? [{ type: 'playSound', name: '确定' }].concat( + choice.action + ) + : [ + { type: 'playSound', name: '操作失败' }, + { + type: 'tip', + text: previewMode + ? '预览模式下不可购买' + : '购买条件不足' + } + ] + }; + }) + .concat({ text: '离开', action: [{ type: 'break' }] }); + core.insertAction({ + type: 'choices', + text: shop.text, + choices: choices + }); + }; /// 是否访问过某个快捷商店 this.isShopVisited = function (id) { - if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {}); - var shops = core.getFlag("__shops__"); + if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {}); + var shops = core.getFlag('__shops__'); if (!shops[id]) shops[id] = {}; return shops[id].visited; - } + }; /// 当前应当显示的快捷商店列表 this.listShopIds = function () { - return Object.keys(core.status.shops).filter((id) => { - return core.isShopVisited(id) || !core.status.shops[id].mustEnable; + return Object.keys(core.status.shops).filter(id => { + return ( + core.isShopVisited(id) || !core.status.shops[id].mustEnable + ); }); - } + }; /// 是否能够打开某个商店 this.canOpenShop = function (id) { @@ -372,16 +397,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var shop = core.status.shops[id]; if (shop.item || shop.commonEvent || shop.mustEnable) return false; return true; - } + }; /// 启用或禁用某个快捷商店 this.setShopVisited = function (id, visited) { - if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {}); - var shops = core.getFlag("__shops__"); + if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {}); + var shops = core.getFlag('__shops__'); if (!shops[id]) shops[id] = {}; if (visited) shops[id].visited = true; else delete shops[id].visited; - } + }; /// 能否使用快捷商店 this.canUseQuickShop = function (id) { @@ -392,52 +417,104 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (core.status.thisMap.canUseQuickShop === false) return '当前楼层不能使用快捷商店。'; return null; - } + }; /// 允许商店X键退出 - core.registerAction('keyUp', 'shops', (keycode) => { - if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false; - if (core.status.event.data.type != 'choices') return false; - var data = core.status.event.data.current; - var choices = data.choices; - var topIndex = core.actions.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); - if (keycode == 88 || keycode == 27) { // X, ESC - core.actions._clickAction(core.actions.HSIZE, topIndex + choices.length - 1); - return true; - } - if (keycode == 13 || keycode == 32) return true; - return false; - }, 60); + core.registerAction( + 'keyUp', + 'shops', + keycode => { + if ( + !core.status.lockControl || + !core.hasFlag('@temp@shop') || + core.status.event.id != 'action' + ) + return false; + if (core.status.event.data.type != 'choices') return false; + var data = core.status.event.data.current; + var choices = data.choices; + var topIndex = + core.actions.HSIZE - + parseInt((choices.length - 1) / 2) + + (core.status.event.ui.offset || 0); + if (keycode == 88 || keycode == 27) { + // X, ESC + core.actions._clickAction( + core.actions.HSIZE, + topIndex + choices.length - 1 + ); + return true; + } + if (keycode == 13 || keycode == 32) return true; + return false; + }, + 60 + ); /// 允许长按空格或回车连续执行操作 - core.registerAction('keyDown', 'shops', (keycode) => { - if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false; - if (core.status.event.data.type != 'choices') return false; - var data = core.status.event.data.current; - var choices = data.choices; - var topIndex = core.actions.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); - if (keycode == 13 || keycode == 32) { // Space, Enter - core.actions._clickAction(core.actions.HSIZE, topIndex + core.status.event.selection); - return true; - } - return false; - }, 60); + core.registerAction( + 'keyDown', + 'shops', + keycode => { + if ( + !core.status.lockControl || + !core.hasFlag('@temp@shop') || + core.status.event.id != 'action' + ) + return false; + if (core.status.event.data.type != 'choices') return false; + var data = core.status.event.data.current; + var choices = data.choices; + var topIndex = + core.actions.HSIZE - + parseInt((choices.length - 1) / 2) + + (core.status.event.ui.offset || 0); + if (keycode == 13 || keycode == 32) { + // Space, Enter + core.actions._clickAction( + core.actions.HSIZE, + topIndex + core.status.event.selection + ); + return true; + } + return false; + }, + 60 + ); // 允许长按屏幕连续执行操作 - core.registerAction('longClick', 'shops', (x, y, px, py) => { - if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false; - if (core.status.event.data.type != 'choices') return false; - var data = core.status.event.data.current; - var choices = data.choices; - var topIndex = core.actions.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); - if (x >= core.actions.CHOICES_LEFT && x <= core.actions.CHOICES_RIGHT && y >= topIndex && y < topIndex + choices.length) { - core.actions._clickAction(x, y); - return true; - } - return false; - }, 60); + core.registerAction( + 'longClick', + 'shops', + (x, y, px, py) => { + if ( + !core.status.lockControl || + !core.hasFlag('@temp@shop') || + core.status.event.id != 'action' + ) + return false; + if (core.status.event.data.type != 'choices') return false; + var data = core.status.event.data.current; + var choices = data.choices; + var topIndex = + core.actions.HSIZE - + parseInt((choices.length - 1) / 2) + + (core.status.event.ui.offset || 0); + if ( + x >= core.actions.CHOICES_LEFT && + x <= core.actions.CHOICES_RIGHT && + y >= topIndex && + y < topIndex + choices.length + ) { + core.actions._clickAction(x, y); + return true; + } + return false; + }, + 60 + ); }, - "removeMap": function () { + removeMap: function () { // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。 // 推荐用法: // 对于超高层或分区域塔,当在1区时将2区以后的地图删除;1区结束时恢复2区,进二区时删除1区地图,以此类推 @@ -462,7 +539,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { flags.__removed__.push(floorId); delete flags.__disabled__[floorId]; delete flags.__leaveLoc__[floorId]; - (core.status.autoEvents || []).forEach((event) => { + (core.status.autoEvents || []).forEach(event => { if (event.floorId == floorId && event.currentFloor) { core.autoEventExecuting(event.symbol, false); core.autoEventExecuted(event.symbol, false); @@ -473,7 +550,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.status.maps[floorId].canFlyFrom = false; core.status.maps[floorId].cannotViewMap = true; } - } + }; // 恢复楼层 // core.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层 @@ -487,15 +564,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { for (var i = fromIndex; i <= toIndex; ++i) { var floorId = core.floorIds[i]; if (!core.status.maps[floorId].deleted) continue; - flags.__removed__ = flags.__removed__.filter((f) => { return f != floorId; }); + flags.__removed__ = flags.__removed__.filter(f => { + return f != floorId; + }); core.status.maps[floorId] = core.loadFloor(floorId); } - } + }; // 分区砍层相关 - var inAnyPartition = (floorId) => { + var inAnyPartition = floorId => { var inPartition = false; - (core.floorPartitions || []).forEach((floor) => { + (core.floorPartitions || []).forEach(floor => { var fromIndex = core.floorIds.indexOf(floor[0]); var toIndex = core.floorIds.indexOf(floor[1]); var index = core.floorIds.indexOf(floorId); @@ -504,27 +583,33 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (index >= fromIndex && index <= toIndex) inPartition = true; }); return inPartition; - } + }; // 分区砍层 this.autoRemoveMaps = function (floorId) { if (main.mode != 'play' || !inAnyPartition(floorId)) return; // 根据分区信息自动砍层与恢复 - (core.floorPartitions || []).forEach((floor) => { + (core.floorPartitions || []).forEach(floor => { var fromIndex = core.floorIds.indexOf(floor[0]); var toIndex = core.floorIds.indexOf(floor[1]); var index = core.floorIds.indexOf(floorId); if (fromIndex < 0 || index < 0) return; if (toIndex < 0) toIndex = core.floorIds.length - 1; if (index >= fromIndex && index <= toIndex) { - core.resumeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]); + core.resumeMaps( + core.floorIds[fromIndex], + core.floorIds[toIndex] + ); } else { - core.removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]); + core.removeMaps( + core.floorIds[fromIndex], + core.floorIds[toIndex] + ); } }); - } + }; }, - "fiveLayers": function () { + fiveLayers: function () { // 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器 // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层 // 另外 请注意加入两个新图层 会让大地图的性能降低一些 @@ -533,19 +618,23 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (!__enable) return; // 创建新图层 - function createCanvas (name, zIndex) { + function createCanvas(name, zIndex) { if (!name) return; var canvas = document.createElement('canvas'); canvas.id = name; canvas.className = 'gameCanvas'; // 编辑器模式下设置zIndex会导致加入的图层覆盖优先级过高 - if (main.mode != "editor") canvas.style.zIndex = zIndex || 0; + if (main.mode != 'editor') canvas.style.zIndex = zIndex || 0; // 将图层插入进游戏内容 document.getElementById('gameDraw').appendChild(canvas); var ctx = canvas.getContext('2d'); core.canvas[name] = ctx; if (core.domStyle.hdCanvas.indexOf('name') >= 0) - core.maps._setHDCanvasSize(ctx, core.__PIXELS__, core.__PIXELS__); + core.maps._setHDCanvasSize( + ctx, + core.__PIXELS__, + core.__PIXELS__ + ); else { canvas.width = core.__PIXELS__; canvas.height = core.__PIXELS__; @@ -556,7 +645,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var bg2Canvas = createCanvas('bg2', 20); var fg2Canvas = createCanvas('fg2', 63); // 大地图适配 - core.bigmap.canvas = ["bg2", "fg2", "bg", "event", "event2", "fg", "damage"]; + core.bigmap.canvas = [ + 'bg2', + 'fg2', + 'bg', + 'event', + 'event2', + 'fg', + 'damage' + ]; core.initStatus.bg2maps = {}; core.initStatus.fg2maps = {}; @@ -564,9 +661,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/ // 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层) // 背景层2(bg2) 插入事件层(event)之前(即bg与event之间) - document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event')); + document + .getElementById('mapEdit') + .insertBefore(bg2Canvas, document.getElementById('event')); // 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后) - document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm')); + document + .getElementById('mapEdit') + .insertBefore(fg2Canvas, document.getElementById('ebm')); // 原本有三个图层 从4开始添加 var num = 4; // 新增图层存入editor.dom中 @@ -578,7 +679,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { editor.dom.canvas.push('bg2', 'fg2'); // 创建编辑器上的按钮 - var createCanvasBtn = (name) => { + var createCanvasBtn = name => { // 电脑端创建按钮 var input = document.createElement('input'); // layerMod4/layerMod5 @@ -592,11 +693,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { editor.dom[id] = input; input.onchange = () => { editor.uifunctions.setLayerMod(value); - } + }; return input; }; - var createCanvasBtn_mobile = (name) => { + var createCanvasBtn_mobile = name => { // 手机端往选择列表中添加子选项 var input = document.createElement('option'); var id = 'layerMod' + num++; @@ -635,40 +736,99 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } core.maps._loadFloor_doNotCopy = function () { return [ - "firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", "bg2map", "fg2map", - "events", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove" + 'firstArrive', + 'eachArrive', + 'blocks', + 'parallelDo', + 'map', + 'bgmap', + 'fgmap', + 'bg2map', + 'fg2map', + 'events', + 'changeFloor', + 'afterBattle', + 'afterGetItem', + 'afterOpenDoor', + 'cannotMove' ]; - } + }; ////// 绘制背景和前景层 ////// - core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) { + core.maps._drawBg_draw = function ( + floorId, + toDrawCtx, + cacheCtx, + config + ) { config.ctx = cacheCtx; core.maps._drawBg_drawBackground(floorId, config); // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。 - core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap); + core.maps._drawFloorImages( + floorId, + config.ctx, + 'bg', + null, + null, + config.onMap + ); core.maps._drawBgFgMap(floorId, 'bg', config); if (config.onMap) { - core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + core.drawImage( + toDrawCtx, + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); core.clearMap('bg2'); core.clearMap(cacheCtx); } core.maps._drawBgFgMap(floorId, 'bg2', config); - if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + if (config.onMap) + core.drawImage( + 'bg2', + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); config.ctx = toDrawCtx; - } - core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) { + }; + core.maps._drawFg_draw = function ( + floorId, + toDrawCtx, + cacheCtx, + config + ) { config.ctx = cacheCtx; // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。 - core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap); + core.maps._drawFloorImages( + floorId, + config.ctx, + 'fg', + null, + null, + config.onMap + ); core.maps._drawBgFgMap(floorId, 'fg', config); if (config.onMap) { - core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + core.drawImage( + toDrawCtx, + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); core.clearMap('fg2'); core.clearMap(cacheCtx); } core.maps._drawBgFgMap(floorId, 'fg2', config); - if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + if (config.onMap) + core.drawImage( + 'fg2', + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); config.ctx = toDrawCtx; - } + }; ////// 移动判定 ////// core.maps._generateMovableArray_arrays = function (floorId) { return { @@ -678,9 +838,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { bg2Array: this._getBgFgMapArray('bg2', floorId), fg2Array: this._getBgFgMapArray('fg2', floorId) }; - } + }; }, - "itemShop": function () { + itemShop: function () { // 道具商店相关的插件 // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找) @@ -717,27 +877,63 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.drawWindowSkin('winskin.png', 'uievent', 360, 128, 120, 352); core.setFillStyle('uievent', 'white'); core.setStrokeStyle('uievent', 'white'); - core.fillText("uievent", "购买", 32, 84, 'white', bigFont); - core.fillText("uievent", "卖出", 152, 84); - core.fillText("uievent", "离开", 272, 84); - core.fillText("uievent", "当前" + useText, 374, 75, null, middleFont); - core.setTextAlign("uievent", "right"); - core.fillText("uievent", core.formatBigNumber(core.status.hero.money), 466, 100); - core.setTextAlign("uievent", "left"); - core.ui.drawUIEventSelector(1, "winskin.png", 22 + 120 * type, 76, 60, 33); + core.fillText('uievent', '购买', 32, 84, 'white', bigFont); + core.fillText('uievent', '卖出', 152, 84); + core.fillText('uievent', '离开', 272, 84); + core.fillText( + 'uievent', + '当前' + useText, + 374, + 75, + null, + middleFont + ); + core.setTextAlign('uievent', 'right'); + core.fillText( + 'uievent', + core.formatBigNumber(core.status.hero.money), + 466, + 100 + ); + core.setTextAlign('uievent', 'left'); + core.ui.drawUIEventSelector( + 1, + 'winskin.png', + 22 + 120 * type, + 76, + 60, + 33 + ); if (selectItem != null) { core.setTextAlign('uievent', 'center'); - core.fillText("uievent", type == 0 ? "买入个数" : "卖出个数", 420, 360, null, bigFont); - core.fillText("uievent", "< " + selectCount + " >", 420, 390); - core.fillText("uievent", "确定", 420, 420); + core.fillText( + 'uievent', + type == 0 ? '买入个数' : '卖出个数', + 420, + 360, + null, + bigFont + ); + core.fillText( + 'uievent', + '< ' + selectCount + ' >', + 420, + 390 + ); + core.fillText('uievent', '确定', 420, 420); } // Step 2:获得列表并展示 - list = choices.filter((one) => { + list = choices.filter(one => { if (one.condition != null && one.condition != '') { - try { if (!core.calValue(one.condition)) return false; } catch (e) { } + try { + if (!core.calValue(one.condition)) return false; + } catch (e) {} } - return (type == 0 && one.money != null) || (type == 1 && one.sell != null); + return ( + (type == 0 && one.money != null) || + (type == 1 && one.sell != null) + ); }); var per_page = 7; totalPage = Math.ceil(list.length / per_page); @@ -747,9 +943,18 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (totalPage > 1) { var half = 180; core.setTextAlign('uievent', 'center'); - core.fillText('uievent', page + " / " + totalPage, half, 450, null, middleFont); - if (page > 1) core.fillText('uievent', '上一页', half - 80, 450); - if (page < totalPage) core.fillText('uievent', '下一页', half + 80, 450); + core.fillText( + 'uievent', + page + ' / ' + totalPage, + half, + 450, + null, + middleFont + ); + if (page > 1) + core.fillText('uievent', '上一页', half - 80, 450); + if (page < totalPage) + core.fillText('uievent', '下一页', half + 80, 450); } core.setTextAlign('uievent', 'left'); @@ -761,60 +966,150 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var item = list[curr]; core.drawIcon('uievent', item.id, 10, 141 + i * 40); core.setTextAlign('uievent', 'left'); - core.fillText('uievent', core.material.items[item.id].name, 50, 148 + i * 40, null, bigFont); + core.fillText( + 'uievent', + core.material.items[item.id].name, + 50, + 148 + i * 40, + null, + bigFont + ); core.setTextAlign('uievent', 'right'); - core.fillText('uievent', (type == 0 ? core.calValue(item.money) : core.calValue(item.sell)) + useText + "/个", 340, 149 + i * 40, null, middleFont); - core.setTextAlign("uievent", "left"); + core.fillText( + 'uievent', + (type == 0 + ? core.calValue(item.money) + : core.calValue(item.sell)) + + useText + + '/个', + 340, + 149 + i * 40, + null, + middleFont + ); + core.setTextAlign('uievent', 'left'); if (curr == selectItem) { // 绘制描述,文字自动放缩 - var text = core.material.items[item.id].text || "该道具暂无描述"; - try { text = core.replaceText(text); } catch (e) { } + var text = + core.material.items[item.id].text || '该道具暂无描述'; + try { + text = core.replaceText(text); + } catch (e) {} for (var fontSize = 20; fontSize >= 8; fontSize -= 2) { - var config = { left: 10, fontSize: fontSize, maxWidth: 467 }; + var config = { + left: 10, + fontSize: fontSize, + maxWidth: 467 + }; var height = core.getTextContentHeight(text, config); if (height <= 60) { config.top = (64 - height) / 2; - core.drawTextContent("uievent", text, config); + core.drawTextContent('uievent', text, config); break; } } - core.ui.drawUIEventSelector(2, "winskin.png", 8, 137 + i * 40, 343, 40); + core.ui.drawUIEventSelector( + 2, + 'winskin.png', + 8, + 137 + i * 40, + 343, + 40 + ); if (type == 0 && item.number != null) { - core.fillText("uievent", "存货", 370, 152, null, bigFont); - core.setTextAlign("uievent", "right"); - core.fillText("uievent", item.number, 470, 152, null, null, 60); + core.fillText( + 'uievent', + '存货', + 370, + 152, + null, + bigFont + ); + core.setTextAlign('uievent', 'right'); + core.fillText( + 'uievent', + item.number, + 470, + 152, + null, + null, + 60 + ); } else if (type == 1) { - core.fillText("uievent", "数量", 370, 152, null, bigFont); - core.setTextAlign("uievent", "right"); - core.fillText("uievent", core.itemCount(item.id), 470, 152, null, null, 40); + core.fillText( + 'uievent', + '数量', + 370, + 152, + null, + bigFont + ); + core.setTextAlign('uievent', 'right'); + core.fillText( + 'uievent', + core.itemCount(item.id), + 470, + 152, + null, + null, + 40 + ); } - core.setTextAlign("uievent", "left"); - core.fillText("uievent", "预计" + useText, 370, 280); - core.setTextAlign("uievent", "right"); - totalMoney = selectCount * (type == 0 ? core.calValue(item.money) : core.calValue(item.sell)); - core.fillText("uievent", core.formatBigNumber(totalMoney), 470, 310); + core.setTextAlign('uievent', 'left'); + core.fillText('uievent', '预计' + useText, 370, 280); + core.setTextAlign('uievent', 'right'); + totalMoney = + selectCount * + (type == 0 + ? core.calValue(item.money) + : core.calValue(item.sell)); + core.fillText( + 'uievent', + core.formatBigNumber(totalMoney), + 470, + 310 + ); - core.setTextAlign("uievent", "left"); - core.fillText("uievent", type == 0 ? "已购次数" : "已卖次数", 370, 190); - core.setTextAlign("uievent", "right"); - core.fillText("uievent", (type == 0 ? item.money_count : item.sell_count) || 0, 470, 220); + core.setTextAlign('uievent', 'left'); + core.fillText( + 'uievent', + type == 0 ? '已购次数' : '已卖次数', + 370, + 190 + ); + core.setTextAlign('uievent', 'right'); + core.fillText( + 'uievent', + (type == 0 ? item.money_count : item.sell_count) || 0, + 470, + 220 + ); } } core.setTextAlign('uievent', 'left'); core.setTextBaseline('uievent', 'alphabetic'); - } + }; var _add = (item, delta) => { if (item == null) return; selectCount = core.clamp( - selectCount + delta, 0, - Math.min(type == 0 ? Math.floor(core.status.hero[use] / core.calValue(item.money)) : core.itemCount(item.id), - type == 0 && item.number != null ? item.number : Number.MAX_SAFE_INTEGER) + selectCount + delta, + 0, + Math.min( + type == 0 + ? Math.floor( + core.status.hero[use] / core.calValue(item.money) + ) + : core.itemCount(item.id), + type == 0 && item.number != null + ? item.number + : Number.MAX_SAFE_INTEGER + ) ); - } + }; - var _confirm = (item) => { + var _confirm = item => { if (item == null || selectCount == 0) return; if (type == 0) { core.status.hero[use] -= totalMoney; @@ -824,12 +1119,18 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } else { core.status.hero[use] += totalMoney; core.removeItem(item.id, selectCount); - core.drawTip("成功卖出" + selectCount + "个" + core.material.items[item.id].name, item.id); + core.drawTip( + '成功卖出' + + selectCount + + '个' + + core.material.items[item.id].name, + item.id + ); if (item.number != null) item.number += selectCount; item.sell_count = (item.sell_count || 0) + selectCount; } selectCount = 0; - } + }; this._performItemShopKeyBoard = function (keycode) { var item = list[selectItem] || null; @@ -867,23 +1168,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { case 13: case 32: // Enter/Space if (selectItem == null) { - if (type == 2) - core.insertAction({ "type": "break" }); - else if (list.length > 0) - selectItem = 0; + if (type == 2) core.insertAction({ type: 'break' }); + else if (list.length > 0) selectItem = 0; break; } _confirm(item); break; case 27: // ESC if (selectItem == null) { - core.insertAction({ "type": "break" }); + core.insertAction({ type: 'break' }); break; } selectItem = null; break; } - } + }; this._performItemShopClick = function (px, py) { var item = list[selectItem] || null; @@ -906,8 +1205,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } return; } - if (px >= 262 && px <= 322 && py >= 81 && py <= 112) // 离开 - return core.insertAction({ "type": "break" }); + if (px >= 262 && px <= 322 && py >= 81 && py <= 112) + // 离开 + return core.insertAction({ type: 'break' }); // <,> if (px >= 370 && px <= 395 && py >= 392 && py <= 415) return _add(item, -1); @@ -945,12 +1245,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } return; } - } + }; this._performItemShopAction = function () { - if (flags.type == 0) return this._performItemShopKeyBoard(flags.keycode); + if (flags.type == 0) + return this._performItemShopKeyBoard(flags.keycode); else return this._performItemShopClick(flags.px, flags.py); - } + }; this.openItemShop = function (itemShopId) { shopId = itemShopId; @@ -960,137 +1261,68 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { selectCount = 0; core.isShopVisited(itemShopId); shopInfo = flags.__shops__[shopId]; - if (shopInfo.choices == null) shopInfo.choices = core.clone(core.status.shops[shopId].choices); + if (shopInfo.choices == null) + shopInfo.choices = core.clone( + core.status.shops[shopId].choices + ); choices = shopInfo.choices; use = core.status.shops[shopId].use; if (use != 'exp') use = 'money'; useText = use == 'money' ? '金币' : '经验'; - core.insertAction([{ - "type": "while", - "condition": "true", - "data": [ - { "type": "function", "function": "() => { core.plugin._drawItemShop(); }" }, - { "type": "wait" }, - { "type": "function", "function": "() => { core.plugin._performItemShopAction(); }" } - ] - }, - { - "type": "function", - "function": "() => { core.deleteCanvas('uievent'); core.ui.clearUIEventSelector(); }" - } - ]); - } - - }, - "enemyLevel": function () { - // 此插件将提供怪物手册中的怪物境界显示 - // 使用此插件需要先给每个怪物定义境界,方法如下: - // 点击怪物的【配置表格】,找到“【怪物】相关的表格配置”,然后在【名称】仿照增加境界定义: - /* - "level": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_data": "境界" - }, - */ - // 然后保存刷新,可以看到怪物的属性定义中出现了【境界】。再开启本插件即可。 - - // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。 - var __enable = false; - if (!__enable) return; - - // 这里定义每个境界的显示颜色;可以写'red', '#RRGGBB' 或者[r,g,b,a]四元数组 - var levelToColors = { - "野蛮人": "white", - "智人": "#FF0000", - "": [255, 0, 0, 1], - }; - - // 复写 _drawBook_drawName - var originDrawBook = core.ui._drawBook_drawName; - core.ui._drawBook_drawName = function (index, enemy, top, left, width) { - // 如果没有境界,则直接调用原始代码绘制 - if (!enemy.level) return originDrawBook.call(core.ui, index, enemy, top, left, width); - // 存在境界,则额外进行绘制 - core.setTextAlign('ui', 'center'); - if (enemy.specialText.length == 0) { - core.fillText('ui', enemy.name, left + width / 2, - top + 27, '#DDDDDD', this._buildFont(17, true)); - core.fillText('ui', enemy.level, left + width / 2, - top + 51, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true)); - } else { - core.fillText('ui', enemy.name, left + width / 2, - top + 20, '#DDDDDD', this._buildFont(17, true), width); - switch (enemy.specialText.length) { - case 1: - core.fillText('ui', enemy.specialText[0], left + width / 2, - top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A'), - this._buildFont(14, true), width); - break; - case 2: - // Step 1: 计算字体 - var text = enemy.specialText[0] + " " + enemy.specialText[1]; - core.setFontForMaxWidth('ui', text, width, this._buildFont(14, true)); - // Step 2: 计算总宽度 - var totalWidth = core.calWidth('ui', text); - var leftWidth = core.calWidth('ui', enemy.specialText[0]); - var rightWidth = core.calWidth('ui', enemy.specialText[1]); - // Step 3: 绘制 - core.fillText('ui', enemy.specialText[0], left + (width + leftWidth - totalWidth) / 2, - top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A')); - core.fillText('ui', enemy.specialText[1], left + (width + totalWidth - rightWidth) / 2, - top + 38, core.arrayToRGBA((enemy.specialColor || [])[1] || '#FF6A6A')); - break; - default: - core.fillText('ui', '多属性...', left + width / 2, - top + 38, '#FF6A6A', this._buildFont(14, true), width); + core.insertAction([ + { + type: 'while', + condition: 'true', + data: [ + { + type: 'function', + function: '() => { core.plugin._drawItemShop(); }' + }, + { type: 'wait' }, + { + type: 'function', + function: + '() => { core.plugin._performItemShopAction(); }' + } + ] + }, + { + type: 'function', + function: + "() => { core.deleteCanvas('uievent'); core.ui.clearUIEventSelector(); }" } - core.fillText('ui', enemy.level, left + width / 2, - top + 56, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true)); - } - } - - // 也可以复写其他的属性颜色如怪物攻防等,具体参见下面的例子的注释部分 - core.ui._drawBook_drawRow1 = function (index, enemy, top, left, width, position) { - // 绘制第一行 - core.setTextAlign('ui', 'left'); - var b13 = this._buildFont(13, true), - f13 = this._buildFont(13, false); - var col1 = left, - col2 = left + width * 9 / 25, - col3 = left + width * 17 / 25; - core.fillText('ui', '生命', col1, position, '#DDDDDD', f13); - core.fillText('ui', core.formatBigNumber(enemy.hp || 0), col1 + 30, position, /*'red' */ null, b13); - core.fillText('ui', '攻击', col2, position, null, f13); - core.fillText('ui', core.formatBigNumber(enemy.atk || 0), col2 + 30, position, /* '#FF0000' */ null, b13); - core.fillText('ui', '防御', col3, position, null, f13); - core.fillText('ui', core.formatBigNumber(enemy.def || 0), col3 + 30, position, /* [255, 0, 0, 1] */ null, b13); - } - - + ]); + }; }, - "heroFourFrames": function () { + heroFourFrames: function () { // 样板的勇士/跟随者移动时只使用2、4两帧,观感较差。本插件可以将四帧全用上。 // 是否启用本插件 var __enable = true; if (!__enable) return; - ["up", "down", "left", "right"].forEach((one) => { + ['up', 'down', 'left', 'right'].forEach(one => { // 指定中间帧动画 core.material.icons.hero[one].midFoot = 2; }); - var heroMoving = (timestamp) => { + var heroMoving = timestamp => { if (core.status.heroMoving <= 0) return; - if (timestamp - core.animateFrame.moveTime > core.values.moveSpeed) { + if ( + timestamp - core.animateFrame.moveTime > + core.values.moveSpeed + ) { core.animateFrame.leftLeg++; core.animateFrame.moveTime = timestamp; } - core.drawHero(['stop', 'leftFoot', 'midFoot', 'rightFoot'][core.animateFrame.leftLeg % 4], 4 * core.status.heroMoving); - } + core.drawHero( + ['stop', 'leftFoot', 'midFoot', 'rightFoot'][ + core.animateFrame.leftLeg % 4 + ], + 4 * core.status.heroMoving + ); + }; core.registerAnimationFrame('heroMoving', true, heroMoving); core.events._eventMoveHero_moving = function (step, moveSteps) { @@ -1100,10 +1332,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { y = core.getHeroLoc('y'); // ------ 前进/后退 var o = direction == 'backward' ? -1 : 1; - if (direction == 'forward' || direction == 'backward') direction = core.getHeroLoc('direction'); + if (direction == 'forward' || direction == 'backward') + direction = core.getHeroLoc('direction'); var faceDirection = direction; - if (direction == 'leftup' || direction == 'leftdown') faceDirection = 'left'; - if (direction == 'rightup' || direction == 'rightdown') faceDirection = 'right'; + if (direction == 'leftup' || direction == 'leftdown') + faceDirection = 'left'; + if (direction == 'rightup' || direction == 'rightdown') + faceDirection = 'right'; core.setHeroLoc('direction', direction); if (curr[1] <= 0) { core.setHeroLoc('direction', faceDirection); @@ -1115,8 +1350,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { else if (step <= 12) core.drawHero('midFoot', 4 * o * (step - 8)); else if (step <= 16) core.drawHero('rightFoot', 4 * o * (step - 8)); // if (step == 8) { if (step == 8 || step == 16) { - core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true); - core.setHeroLoc('y', y + o * core.utils.scan2[direction].y, true); + core.setHeroLoc( + 'x', + x + o * core.utils.scan2[direction].x, + true + ); + core.setHeroLoc( + 'y', + y + o * core.utils.scan2[direction].y, + true + ); core.updateFollowers(); curr[1]--; if (curr[1] <= 0) moveSteps.shift(); @@ -1124,10 +1367,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return step == 16; } return false; - } + }; }, - "fixed": function () { - + fixed: function () { + return; // 该插件可自定义空间很大,可自定义内容请看注释 // -------------------- 安装说明 -------------------- // @@ -1192,7 +1435,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { setTimeout(() => this.setCss(`opacity: 1;`), 50); } - destroy () { + destroy() { this.setCss(`opacity: 0;`); setTimeout(() => super.destroy(), 600); delete sprites[this.name]; @@ -1222,7 +1465,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 播放动画 */ - animate (big) { + animate(big) { const ctx = this.context; this.interval = setInterval(() => { const size = big ? 32 : void 0; @@ -1234,21 +1477,23 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }, core.values.animateSpeed); } - destroy () { + destroy() { clearInterval(this.interval); - delete enemyBoxes[this.name] + delete enemyBoxes[this.name]; super.destroy(); } /** 监听 */ - listen () { + listen() { this.addEventListener('mouseenter', () => { this.setCss(`transform: scale(1.1);`); drawRough(this.enemy); }); this.addEventListener('mouseleave', () => { this.setCss(`transform: none;`); - textBoxes[`_text_${this.enemy.loc.x}_${this.enemy.loc.y}_`].destroy(); + textBoxes[ + `_text_${this.enemy.loc.x}_${this.enemy.loc.y}_` + ].destroy(); }); } } @@ -1256,7 +1501,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** 文字框 */ class TextBox extends Sprite { constructor(x, y, w, h, text, fontSize, ex, ey) { - const id = `_text_${ex}_${ey}_` + const id = `_text_${ex}_${ey}_`; super(x, y, w, h, 310, 'game', id); this.setCss(` opacity: 0; @@ -1275,19 +1520,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.ey = ey; } - render (text, fontSize) { + render(text, fontSize) { /** @type {TextContentConfig} */ const config = { left: 10, top: 10, maxWidth: this.width - 20, time: 10, - fontSize, font - } + fontSize, + font + }; core.drawTextContent(this.context, text, config); } - destroy () { + destroy() { this.setCss(`opacity: 0;`); setTimeout(() => super.destroy(), 200); delete textBoxes[`_text_${this.ex}_${this.ey}_`]; @@ -1301,26 +1547,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { enemies = info; drawFixed(info); core.lockControl(); - } + }; // 监听 & 复写 main.dom.data.addEventListener('mousemove', moveOnPlaying); main.dom.data.addEventListener('dblclick', dblClick); - main.dom.data.onmouseup = (e) => { + main.dom.data.onmouseup = e => { if (allowDbl) { clearTimeout(dblTimeout); - dblTimeout = setTimeout(() => { originClick.call(main.dom.data, e) }, 200); + dblTimeout = setTimeout(() => { + originClick.call(main.dom.data, e); + }, 200); } else { originClick.call(main.dom.data, e); } - } + }; - /** - * 获取怪物位置和其属性 + /** + * 获取怪物位置和其属性 * @param {string} floorId 地图id * @returns {EnemyCollection[]} 怪物信息数组 */ - function getEnemies (floorId = core.status.floorId) { + function getEnemies(floorId = core.status.floorId) { const res = []; // 遍历所有图块,然后找出在显示范围内的怪物,异步执行, core.extractBlocks(floorId); @@ -1337,7 +1585,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return res; } - function generateCollection (id, x, y, floorId) { + function generateCollection(id, x, y, floorId) { const enemy = core.material.enemys[id]; const info = core.getEnemyInfo(id, void 0, x, y, floorId); const data = Object.assign({}, enemy); @@ -1347,47 +1595,56 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 根据属性名获得颜色 - * @param {string} status + * @param {string} status */ - function color (status) { + function color(status) { return colorDict[status] ?? 'white'; } /** * 根据伤害获得伤害颜色 - * @param {number} damage + * @param {number} damage */ - function colorDamage (damage) { + function colorDamage(damage) { if (typeof damage === 'string' || !damage) return '#f00'; const hp = core.status.hero.hp; - const n = ~~(damage / hp * 255); + const n = ~~((damage / hp) * 255); return `rgb(${n}, ${255 - n}, 0)`; } /** * 获取怪物的粗略信息 - * @param {Enemy} info + * @param {Enemy} info */ - function getRough (info, x, y) { + function getRough(info, x, y) { // 先获得常量中明确指定的 const text = showStatus.map(v => { - return `\\r[${color(v)}]${core.getStatusLabel(v)}\\r[]:${info[v]}`; + return `\\r[${color(v)}]${core.getStatusLabel(v)}\\r[]:${ + info[v] + }`; }); // 特殊属性 if (info.special?.length > 0) { const names = core.getSpecialText(info); const color = core.getSpecialColor(info); - const all = names.map((v, i) => `\\r[${color[i]}]${v}\\r[]`) + const all = names.map((v, i) => `\\r[${color[i]}]${v}\\r[]`); text.push(`\\r[#f8f]特殊属性\\r[]:${all.join` `}`); } // 伤害 const damage = core.getDamageInfo(info, void 0, x, y)?.damage; const d = core.formatBigNumber(damage); - text.push(`\\r[#f44]伤害\\r[]:\\r[${colorDamage(damage)}]${d === '???' ? '无法战胜' : d}\\r[]`); + text.push( + `\\r[#f44]伤害\\r[]:\\r[${colorDamage(damage)}]${ + d === '???' ? '无法战胜' : d + }\\r[]` + ); // 支援 if (info.guards?.length > 0) { const guards = getGuards(info, x, y); - text.push(`\\r[#3cf]支援\\r[]:${guards.map(v => `\\i[${v.id}]`).join` `}`); + text.push( + `\\r[#3cf]支援\\r[]:${guards.map(v => `\\i[${v.id}]`) + .join` `}` + ); text.push(`支援怪攻击顺序 -->`); } if (allowDbl) text.push('双击怪物查看详细信息'); @@ -1396,10 +1653,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 获得特殊属性说明、名称、颜色 - * @param {SpecialCollection} data + * @param {SpecialCollection} data * @param {Enemy} enemy */ - function executeSpecial (data, enemy) { + function executeSpecial(data, enemy) { let name = ''; if (typeof data[1] === 'string') name = data[1]; else name = data[1](enemy); @@ -1409,11 +1666,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return { name, text, color: data[3] }; } - /** + /** * 获得某个怪物的详细信息,包括特殊属性说明、支援怪攻击顺序 * @param {EnemyCollection} info getEnemies获取的怪物信息 */ - function getDetail (info) { + function getDetail(info) { // ----- status const status = {}; showStatus.forEach(v => { @@ -1421,7 +1678,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { id: v, name: core.getStatusLabel(v), value: info.data[v] - } + }; }); // ----- special const text = []; @@ -1429,22 +1686,45 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (special?.length > 0) { for (const n of special) { const data = specials.find(v => v[0] === n); - if (!data) throw new ReferenceError(`'${info.data.name}'拥有不存在的特殊属性'${n}'`); - const { name, text: desc, color } = executeSpecial(data, info.data); + if (!data) + throw new ReferenceError( + `'${info.data.name}'拥有不存在的特殊属性'${n}'` + ); + const { + name, + text: desc, + color + } = executeSpecial(data, info.data); text.push(`\\r[${color}]${name}\\r[]:${desc}`); } } // ---- damage & turn - const damageInfo = core.getDamageInfo(info.data, void 0, info.loc.x, info.loc.y); + const damageInfo = core.getDamageInfo( + info.data, + void 0, + info.loc.x, + info.loc.y + ); let damage = core.formatBigNumber(damageInfo?.damage); if (damage === '???') damage = '无法战胜'; const color = colorDamage(damageInfo?.damage); const turn = damageInfo?.turn ?? 0; // ----- 4 criticals & n def - const criticals = core.nextCriticals(info.data, 4, info.loc.x, info.loc.y); + const criticals = core.nextCriticals( + info.data, + 4, + info.loc.x, + info.loc.y + ); const n = nDefDamage ? core.status.thisMap.ratio : 1; const def = core.getDefDamage(info.data, n, info.loc.x, info.loc.y); - return { status, text, damage: { damage, color, turn }, criticals, def }; + return { + status, + text, + damage: { damage, color, turn }, + criticals, + def + }; } /** @@ -1453,7 +1733,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * @param {EnemyCollection[]} all 所有的怪物信息 * @returns {GuardCollection[]} 支援怪的顺序信息 */ - function getGuards (info, all) { + function getGuards(info, all) { /** @type {[number, number, string][]} */ const guards = info.guards; if (!guards) return; @@ -1461,19 +1741,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const res = { loc: { x, y }, id - } + }; // 寻找符合条件的怪物 const enemy = all.find(v => v.loc.x === x && v.loc.y === y); res.enemy = enemy; return res; - }) + }); } /** * 获取每个支援怪造成的伤害、回合数等 - * @param {EnemyCollection} info + * @param {EnemyCollection} info */ - function getGuardsDetail (info) { + function getGuardsDetail(info) { // 很神秘的一个功能 const guards = getGuards(info, enemies); // 这时候获得的已经是按顺序排好的了 const col = { enemy: info.data, loc: info.loc }; @@ -1481,18 +1761,29 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { else guards.unshift(col); const turn = ref(0); const res = []; - watch(turn, v => flags.__extraTurn__ = v); // 使用样板的额外回合flag - const status = ['atk', 'def', 'hp'].map(v => ({ [v]: core.getRealStatus(v) })); + watch(turn, v => (flags.__extraTurn__ = v)); // 使用样板的额外回合flag + const status = ['atk', 'def', 'hp'].map(v => ({ + [v]: core.getRealStatus(v) + })); const hero = Object.assign({}, ...status, { mdef: 0 }); for (let i = 0; i < guards.length; i++) { const e = guards[i]; - const data = core.getDamageInfo(e.enemy, i === 0 ? void 0 : hero, e.loc.x, e.loc.y); + const data = core.getDamageInfo( + e.enemy, + i === 0 ? void 0 : hero, + e.loc.x, + e.loc.y + ); if (!data) { res.push({ battlable: false }); continue; } turn.value += data.turn; - res.push({ battlable: true, damage: data.damage, turn: data.turn }); + res.push({ + battlable: true, + damage: data.damage, + turn: data.turn + }); } return res; } @@ -1502,7 +1793,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * @param {number} x 要判断的格子 * @param {number} y */ - function inView (x, y) { + function inView(x, y) { const { x: hx, y: hy } = core.status.hero.loc; const w = core._WIDTH_, h = core._HEIGHT_; @@ -1511,12 +1802,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 计算像素位置 - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h + * @param {number} x + * @param {number} y + * @param {number} w + * @param {number} h */ - function calPixel (x, y, w, h) { + function calPixel(x, y, w, h) { const px = x * 32 + 16 - w / 2, py = (y + 1) * 32 - h; return { px, py, w, h }; @@ -1524,15 +1815,23 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 根据鼠标位置获得矩形的绘制信息 - * @param {number} px - * @param {number} py + * @param {number} px + * @param {number} py */ - function calRect (px, py, text) { + function calRect(px, py, text) { const onRight = px >= core._PX_ / 2; let x = px + 32; - const width = Math.min(core._PX_ / 2 - 32, onRight ? px - 32 : core._PX_ - x); + const width = Math.min( + core._PX_ / 2 - 32, + onRight ? px - 32 : core._PX_ - x + ); if (onRight) x = px - width - 32; - const config = { maxWidth: width - 20, font, fontSize: 19, left: 10 }; + const config = { + maxWidth: width - 20, + font, + fontSize: 19, + left: 10 + }; let height = 500; while (height > core._PY_ - 20) { config.fontSize--; @@ -1546,11 +1845,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * 绘制定点查看界面 * @param {EnemyCollection[]} info 怪物信息 */ - function drawFixed (info) { + function drawFixed(info) { // 绘制,当然还有动画 new Back('_fixed_sback_', 'rgba(0, 0, 0, 0.9)', 200); drawChoice(info); - const exit = new Sprite(core._PX_ - 60, 4, 56, 24, 400, 'game', '_exit_'); + const exit = new Sprite( + core._PX_ - 60, + 4, + 56, + 24, + 400, + 'game', + '_exit_' + ); exit.setCss(` background-color: #aaa; box-shadow: 0px 0px 3px #000; @@ -1571,9 +1878,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 绘制每个怪物 - * @param {EnemyCollection[]} info + * @param {EnemyCollection[]} info */ - function drawChoice (info) { + function drawChoice(info) { for (const e of info) { const { x, y } = e.loc; const data = e.data; @@ -1581,31 +1888,60 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const w = bigImage?.width ?? 32, h = bigImage?.height ?? height; const { px, py } = calPixel(x, y, w, h); - new EnemyBox(`_enemybox_${x}_${y}_`, px, py, w, h, data.id, !!bigImage, e); + new EnemyBox( + `_enemybox_${x}_${y}_`, + px, + py, + w, + h, + data.id, + !!bigImage, + e + ); } } /** * 绘制怪物的粗略信息 - * @param {EnemyCollection} info + * @param {EnemyCollection} info */ - function drawRough (info) { + function drawRough(info) { const { x, y } = info.loc; const text = getRough(info.data, x, y); const rect = calRect(x * 32 + 16, y * 32 + 16, text); - new TextBox(rect.x, rect.y, rect.width, rect.height, text, rect.font, x, y); + new TextBox( + rect.x, + rect.y, + rect.width, + rect.height, + text, + rect.font, + x, + y + ); } /** * 绘制详细信息的主界面 - * @param {EnemyCollection} info + * @param {EnemyCollection} info * @param {EnemyBox} enemyBox */ - function drawMain (info, enemyBox) { + function drawMain(info, enemyBox) { const { bigImage, height } = core.getBlockInfo(info.data.id); const w = bigImage?.width ?? 32, h = bigImage?.height ?? height; - const box = enemyBox ?? new EnemyBox(`_enemy_main_`, 16, 16, w, h, info.data.id, !!bigImage, info); + const box = + enemyBox ?? + new EnemyBox( + `_enemy_main_`, + 16, + 16, + w, + h, + info.data.id, + !!bigImage, + info + ); box.move(16, 16); box.setCss(` border: 0; @@ -1614,12 +1950,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { z-index: 1000; `); const { status, text, damage, criticals, def } = getDetail(info); - const back = new Back(`_detail_back_`, 'linear-gradient(to bottom, #333, #777)', 600, 0.2); + const back = new Back( + `_detail_back_`, + 'linear-gradient(to bottom, #333, #777)', + 600, + 0.2 + ); // draw const sv = Object.values(status); - sv.forEach(e => { - - }) + sv.forEach(e => {}); } /** @@ -1627,7 +1966,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * @param {EnemyCollection} info 怪物的信息 * @param {boolean} animate 是否要有动画 */ - function drawDetail (info, animate) { + function drawDetail(info, animate) { const { x, y } = info.loc; const box = enemyBoxes[`_enemybox_${x}_${y}_`]; if (!animate) box?.destroy(); @@ -1635,15 +1974,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 关闭界面 */ - function close () { + function close() { Object.values(sprites).forEach(v => v.destroy()); setTimeout(core.unlockControl, 600); } - function getEnemy (px, py) { + function getEnemy(px, py) { const evenX = core._WIDTH_ % 2 === 0 ? 0.5 : 0, evenY = core._HEIGHT_ % 2 === 0 ? 0.5 : 0; - const bx = Math.round(~~(px / 32) - core.bigmap.offsetX / 32 + evenX), + const bx = Math.round( + ~~(px / 32) - core.bigmap.offsetX / 32 + evenX + ), by = Math.round(~~(py / 32) - core.bigmap.offsetY / 32 + evenY); const loc = `${bx},${by}`; const blocks = core.getMapBlocksObj(); @@ -1655,9 +1996,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 在游戏时移动鼠标,延迟500ms显示怪物信息 - * @param {MouseEvent} e + * @param {MouseEvent} e */ - function moveOnPlaying (e) { + function moveOnPlaying(e) { if (!allowMap) return; if (!core.isPlaying()) return; const { x, y } = core.actions._getClickLoc(e.clientX, e.clientY); @@ -1676,9 +2017,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /** * 双击鼠标时 - * @param {MouseEvent} e + * @param {MouseEvent} e */ - function dblClick (e) { + function dblClick(e) { if (!allowDbl) return; if (!core.isPlaying()) return; if (e.detail !== 2) return; @@ -1691,7 +2032,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { drawDetail(enemy); } }, - "itemDetail": function () { + itemDetail: function () { core.bigmap.threshold = 256; core.control.updateDamage = function (floorId, ctx) { @@ -1716,27 +2057,37 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 绘制地图显示 control.prototype._drawDamage_draw = function (ctx, onMap) { if (!core.hasItem('book')) return; - core.setFont(ctx, "15px normal"); + core.setFont(ctx, '15px normal'); core.setTextAlign(ctx, 'left'); - core.status.damage.data.forEach((one) => { + core.status.damage.data.forEach(one => { var px = one.px, py = one.py; if (onMap && core.bigmap.v2) { px -= core.bigmap.posX * 32; py -= core.bigmap.posY * 32; - if (px < -32 * 2 || px > core.__PIXELS__ + 32 || py < -32 || py > core.__PIXELS__ + 32) + if ( + px < -32 * 2 || + px > core.__PIXELS__ + 32 || + py < -32 || + py > core.__PIXELS__ + 32 + ) return; } core.fillBoldText(ctx, one.text, px, py, one.color); }); core.setTextAlign(ctx, 'center'); - core.status.damage.extraData.forEach((one) => { + core.status.damage.extraData.forEach(one => { var px = one.px, py = one.py; if (onMap && core.bigmap.v2) { px -= core.bigmap.posX * 32; py -= core.bigmap.posY * 32; - if (px < -32 || px > core.__PIXELS__ + 32 || py < -32 || py > core.__PIXELS__ + 32) + if ( + px < -32 || + px > core.__PIXELS__ + 32 || + py < -32 || + py > core.__PIXELS__ + 32 + ) return; } core.fillBoldText(ctx, one.text, px, py, one.color); @@ -1746,28 +2097,45 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { x = Math.floor(parseFloat(x)); if (!core.isset(x) || !Number.isFinite(x)) return '???'; if (x > 1e24 || x < -1e24) return x.toExponential(2); - var c = x < 0 ? "-" : ""; + var c = x < 0 ? '-' : ''; if (onCritical) c = '-> '; x = Math.abs(x); if (x <= 9999 || (!onMap && x <= 999999)) return c + x; var all = [ - { "val": 1e20, "c": "g" }, - { "val": 1e16, "c": "j" }, - { "val": 1e12, "c": "z" }, - { "val": 1e8, "c": "e" }, - { "val": 1e4, "c": "w" }, - ] + { val: 1e20, c: 'g' }, + { val: 1e16, c: 'j' }, + { val: 1e12, c: 'z' }, + { val: 1e8, c: 'e' }, + { val: 1e4, c: 'w' } + ]; for (var i = 0; i < all.length; i++) { var one = all[i]; if (onMap) { if (x >= one.val) { var v = x / one.val; - return c + v.toFixed(Math.max(0, Math.floor((c == "-" ? 2 : 3) - Math.log10(v + 1)))) + one.c; + return ( + c + + v.toFixed( + Math.max( + 0, + Math.floor( + (c == '-' ? 2 : 3) - Math.log10(v + 1) + ) + ) + ) + + one.c + ); } } else { if (x >= 10 * one.val) { var v = x / one.val; - return c + v.toFixed(Math.max(0, Math.floor(4 - Math.log10(v + 1)))) + one.c; + return ( + c + + v.toFixed( + Math.max(0, Math.floor(4 - Math.log10(v + 1))) + ) + + one.c + ); } } } @@ -1775,16 +2143,26 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }; // 获取宝石信息 并绘制 this.getItemDetail = function (floorId) { - if (!core.getFlag("itemDetail")) return; + if (!core.getFlag('itemDetail')) return; floorId = floorId || core.status.thisMap.floorId; - core.status.maps[floorId].blocks.forEach((block) => { + core.status.maps[floorId].blocks.forEach(block => { if (block.event.cls !== 'items') return; var x = block.x, y = block.y; // v2优化,只绘制范围内的部分 if (core.bigmap.v2) { - if (x < core.bigmap.posX - core.bigmap.extend || x > core.bigmap.posX + core.__SIZE__ + core.bigmap.extend || - y < core.bigmap.posY - core.bigmap.extend || y > core.bigmap.posY + core.__SIZE__ + core.bigmap.extend) { + if ( + x < core.bigmap.posX - core.bigmap.extend || + x > + core.bigmap.posX + + core.__SIZE__ + + core.bigmap.extend || + y < core.bigmap.posY - core.bigmap.extend || + y > + core.bigmap.posY + + core.__SIZE__ + + core.bigmap.extend + ) { return; } } @@ -1802,10 +2180,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } var before = core.clone(core.status.hero); // 跟数据统计原理一样 执行效果 前后比较 - core.setFlag("__statistics__", true); + core.setFlag('__statistics__', true); try { eval(item.itemEffect); - } catch (error) { } + } catch (error) {} var diff = compareObject(before, core.status.hero); core.status.hero = hero = before; flags = core.status.hero.flags; @@ -1813,7 +2191,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }); }; // 比较两个对象之间每一项的数值差异(弱等于) 返回数值差异 - function compareObject (a, b) { + function compareObject(a, b) { a = a || {}; b = b || {}; var diff = {}; // 差异 @@ -1822,95 +2200,100 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (!diff[name]) diff[name] = void 0; } return diff; - }; + } // 绘制 - function drawItemDetail (diff, x, y) { + function drawItemDetail(diff, x, y) { if (core.same(diff, {}) || !diff) return; var px = 32 * x + 2, py = 32 * y + 30; - var content = ""; + var content = ''; // 获得数据和颜色 var i = 0; for (var name in diff) { if (!diff[name]) continue; - var color = "#ffffff"; + var color = '#ffffff'; if (typeof diff[name] === 'number') diff[name] = core.formatBigNumber(diff[name], true); switch (name) { case 'atk': case 'atkper': - color = "#FF7A7A"; + color = '#FF7A7A'; break; case 'def': case 'defper': - color = "#00E6F1"; + color = '#00E6F1'; break; case 'mdef': case 'mdefper': - color = "#6EFF83"; + color = '#6EFF83'; break; case 'hp': - color = "#A4FF00"; + color = '#A4FF00'; break; case 'hpmax': case 'hpmaxper': - color = "#F9FF00"; + color = '#F9FF00'; break; case 'mana': - color = "#cc6666"; + color = '#cc6666'; break; } content = diff[name]; // 绘制 - core.status.damage.data.push({ text: content, px: px, py: py - 10 * i, color: color }); + core.status.damage.data.push({ + text: content, + px: px, + py: py - 10 * i, + color: color + }); i++; } } }, - "chapter": function () { + chapter: function () { // 章节显示 - var chapter = "", - description = ""; + var chapter = '', + description = ''; // 显示章节 this.displayChapter = function (index) { if (core.isReplaying()) return; var number = core.replaceNumberWithChinese(index); // 获取第几章 - chapter = "第" + number + "章"; - if (index == 0) chapter = "序章"; + chapter = '第' + number + '章'; + if (index == 0) chapter = '序章'; // 获取描述 switch (index) { case 0: - description = "起源"; + description = '起源'; break; case 1: - description = "勇气"; + description = '勇气'; break; case 2: - description = "智慧"; + description = '智慧'; break; } core.coreChapterAnimate(chapter, description); }; // 替换数字大小写 this.replaceNumberWithChinese = function (number) { - if (number == 0) return "零"; - if (number == 1) return "一"; - if (number == 2) return "二"; - if (number == 3) return "三"; - if (number == 4) return "四"; - if (number == 5) return "五"; - if (number == 6) return "六"; - if (number == 7) return "七"; - if (number == 8) return "八"; - if (number == 9) return "九"; - if (number == 10) return "十"; + if (number == 0) return '零'; + if (number == 1) return '一'; + if (number == 2) return '二'; + if (number == 3) return '三'; + if (number == 4) return '四'; + if (number == 5) return '五'; + if (number == 6) return '六'; + if (number == 7) return '七'; + if (number == 8) return '八'; + if (number == 9) return '九'; + if (number == 10) return '十'; }; // 核心动画运算 this.coreChapterAnimate = function (chapter, description) { // 先建画布 if (core.isReplaying()) return; - core.createCanvas("chapter", 0, 0, 480, 480, 100); + core.createCanvas('chapter', 0, 0, 480, 480, 100); var frame = 0, speed = 0, left = -480, @@ -1918,71 +2301,186 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 一秒50帧 core.lockControl(); var interval = setInterval(() => { - core.clearMap("chapter"); + core.clearMap('chapter'); speed = core.hyperbolicCosine((frame - 84) * 0.05); left += speed / 2; // 背景 if (frame <= 110) { - core.fillRect("chapter", 0, -240 - left, 480, left + 480, "#000000"); - core.fillRect("chapter", 0, 240, 480, left + 480, "#000000"); + core.fillRect( + 'chapter', + 0, + -240 - left, + 480, + left + 480, + '#000000' + ); + core.fillRect( + 'chapter', + 0, + 240, + 480, + left + 480, + '#000000' + ); } else { - core.fillRect("chapter", 0, 0, 480, down, "#000000"); - core.fillRect("chapter", 0, 480 - down, 480, down, "#000000"); + core.fillRect('chapter', 0, 0, 480, down, '#000000'); + core.fillRect( + 'chapter', + 0, + 480 - down, + 480, + down, + '#000000' + ); down -= speed / 2; } // 中间矩形 if (frame <= 100) { - core.fillRect("chapter", 0, 240 - frame / 5, 480, frame / 2.5, [255, 255, 255, 0.5 + frame / 200]); + core.fillRect( + 'chapter', + 0, + 240 - frame / 5, + 480, + frame / 2.5, + [255, 255, 255, 0.5 + frame / 200] + ); } else { - core.fillRect("chapter", 0, 240 - (2100 / (205 - frame)), 480, 4200 / (205 - frame), [255, 255, 255, (175 - frame) / 75]); + core.fillRect( + 'chapter', + 0, + 240 - 2100 / (205 - frame), + 480, + 4200 / (205 - frame), + [255, 255, 255, (175 - frame) / 75] + ); } // 上下方线 - core.fillRect("chapter", left, 210, 300, 10, "#FF4D00"); - core.fillRect("chapter", 180 - left, 260, 300, 10, "#2DFFFC"); - core.fillRect("chapter", left + 310, 210, 10, 10, "#FF4D00"); - core.fillRect("chapter", 160 - left, 260, 10, 10, "#2DFFFC"); - core.fillPolygon("chapter", [ - [left + 330, 210], - [left + 330, 220], - [left + 340, 220] - ], "#FF4D00"); - core.fillPolygon("chapter", [ - [150 - left, 260], - [140 - left, 260], - [150 - left, 270] - ], "#2DFFFC"); + core.fillRect('chapter', left, 210, 300, 10, '#FF4D00'); + core.fillRect('chapter', 180 - left, 260, 300, 10, '#2DFFFC'); + core.fillRect('chapter', left + 310, 210, 10, 10, '#FF4D00'); + core.fillRect('chapter', 160 - left, 260, 10, 10, '#2DFFFC'); + core.fillPolygon( + 'chapter', + [ + [left + 330, 210], + [left + 330, 220], + [left + 340, 220] + ], + '#FF4D00' + ); + core.fillPolygon( + 'chapter', + [ + [150 - left, 260], + [140 - left, 260], + [150 - left, 270] + ], + '#2DFFFC' + ); // 闪光条 for (var i = 5; i > 0; i--) { if (frame <= 150) { - core.drawLine("chapter", 0, 220, left + 320, 220, [255, 255, 255, 0.4], i); - core.drawLine("chapter", 480, 260, 160 - left, 260, [255, 255, 255, 0.4], i); + core.drawLine( + 'chapter', + 0, + 220, + left + 320, + 220, + [255, 255, 255, 0.4], + i + ); + core.drawLine( + 'chapter', + 480, + 260, + 160 - left, + 260, + [255, 255, 255, 0.4], + i + ); } else { - core.drawLine("chapter", 0, 220, left + 320, 220, [255, 255, 255, 0.4 - (frame - 150) / 125], i); - core.drawLine("chapter", 480, 260, 160 - left, 260, [255, 255, 255, 0.4 - (frame - 150) / 125], i); + core.drawLine( + 'chapter', + 0, + 220, + left + 320, + 220, + [255, 255, 255, 0.4 - (frame - 150) / 125], + i + ); + core.drawLine( + 'chapter', + 480, + 260, + 160 - left, + 260, + [255, 255, 255, 0.4 - (frame - 150) / 125], + i + ); } } - core.fillEllipse("chapter", left + 320, 220, 7, 3, 0, [255, 255, 255, 0.8]); - core.fillEllipse("chapter", left + 320, 220, 2, 10, 0, [255, 255, 255, 0.8]); - core.fillEllipse("chapter", 160 - left, 260, 7, 3, 0, [255, 255, 255, 0.8]); - core.fillEllipse("chapter", 160 - left, 260, 2, 10, 0, [255, 255, 255, 0.8]); + core.fillEllipse( + 'chapter', + left + 320, + 220, + 7, + 3, + 0, + [255, 255, 255, 0.8] + ); + core.fillEllipse( + 'chapter', + left + 320, + 220, + 2, + 10, + 0, + [255, 255, 255, 0.8] + ); + core.fillEllipse( + 'chapter', + 160 - left, + 260, + 7, + 3, + 0, + [255, 255, 255, 0.8] + ); + core.fillEllipse( + 'chapter', + 160 - left, + 260, + 2, + 10, + 0, + [255, 255, 255, 0.8] + ); // 字 - core.setTextAlign("chapter", "center"); - core.fillBoldText("chapter", chapter + " " + description, left + 360, 250, "#ffffff", "#000000", "28px scroll"); + core.setTextAlign('chapter', 'center'); + core.fillBoldText( + 'chapter', + chapter + ' ' + description, + left + 360, + 250, + '#ffffff', + '#000000', + '28px scroll' + ); if (frame >= 200) { clearInterval(interval); - core.deleteCanvas("chapter"); + core.deleteCanvas('chapter'); core.unlockControl(); } - if (frame == 80) core.playSound("chapter.mp3"); + if (frame == 80) core.playSound('chapter.mp3'); frame++; }, 20); }; // 返回双曲余弦值 this.hyperbolicCosine = function (number) { return 0.5 * (Math.pow(Math.E, number) + Math.pow(Math.E, -number)); - } + }; }, - "intelligenceTree": function () { + intelligenceTree: function () { // 智慧加点 var list; var levels; @@ -2002,26 +2500,105 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { levels = core.clone(core.getSkillLevel()); // 技能定义 0索引 1名称 2描述 3等级 4消耗 5前置技能[索引,等级,索引,等级] 6位置(5×5) 7最大等级 8页码数 9效果 list = [ - [0, "力量", "力量就是根本!可以通过智慧增加力量", 0, 10 * levels[0] + 10, null, [1, 2], 10, 1, "攻击+" + (levels[0] * 2)], - [1, "致命一击", "爆发出全部力量攻击敌人", 0, 30 * levels[1] + 30, [0, 5], - [2, 1], 10, 1, "每回合额外伤害+" + (levels[1] * 5) + [ + 0, + '力量', + '力量就是根本!可以通过智慧增加力量', + 0, + 10 * levels[0] + 10, + null, + [1, 2], + 10, + 1, + '攻击+' + levels[0] * 2 ], - [2, "断灭之刃", "\\r[#dddd44]主动技能\\r[],开启后会在战斗时会额外增加一定量的攻击, 但同时减少一定量的防御,快捷键1", 0, 200 * levels[2] + 400, [1, 5], - [4, 1], 5, 1, levels[2] * 10 + "%攻击加成,减少" + levels[2] * 10 + "%的防御" + [ + 1, + '致命一击', + '爆发出全部力量攻击敌人', + 0, + 30 * levels[1] + 30, + [0, 5], + [2, 1], + 10, + 1, + '每回合额外伤害+' + levels[1] * 5 ], - [3, "坚韧", "由智慧转化出坚韧!", 0, 10 * levels[3] + 10, null, [1, 4], 10, 1, "防御+" + levels[3] * 2], - [4, "回春", "让智慧化为治愈之泉水!", 0, 20 + levels[4] * 20, [3, 5], - [2, 5], 25, 1, "每回合回复" + 1 * levels[4] + "生命" + [ + 2, + '断灭之刃', + '\\r[#dddd44]主动技能\\r[],开启后会在战斗时会额外增加一定量的攻击, 但同时减少一定量的防御,快捷键1', + 0, + 200 * levels[2] + 400, + [1, 5], + [4, 1], + 5, + 1, + levels[2] * 10 + + '%攻击加成,减少' + + levels[2] * 10 + + '%的防御' ], - [5, "治愈之泉", "让生命变得更多一些吧!每吃50瓶血瓶就增加当前生命回复10%的生命回复", 0, 1500, [4, 25], - [4, 5], 1, 1, "50瓶血10%生命回复" + [ + 3, + '坚韧', + '由智慧转化出坚韧!', + 0, + 10 * levels[3] + 10, + null, + [1, 4], + 10, + 1, + '防御+' + levels[3] * 2 ], - [6, "坚固之盾", "让护甲更加坚硬一些吧!", 0, 50 + levels[6] * 50, [3, 5], - [2, 3], 10, 1, "防御+" + 10 * levels[6] + [ + 4, + '回春', + '让智慧化为治愈之泉水!', + 0, + 20 + levels[4] * 20, + [3, 5], + [2, 5], + 25, + 1, + '每回合回复' + 1 * levels[4] + '生命' ], - [7, "无上之盾", "\\r[#dddd44]第一章终极技能\\r[],战斗时智慧会充当等量护盾", 0, 2500, [6, 10, 5, 1, 2, 2], - [5, 3], 1, 1, "战斗时智慧会充当护盾" + [ + 5, + '治愈之泉', + '让生命变得更多一些吧!每吃50瓶血瓶就增加当前生命回复10%的生命回复', + 0, + 1500, + [4, 25], + [4, 5], + 1, + 1, + '50瓶血10%生命回复' ], + [ + 6, + '坚固之盾', + '让护甲更加坚硬一些吧!', + 0, + 50 + levels[6] * 50, + [3, 5], + [2, 3], + 10, + 1, + '防御+' + 10 * levels[6] + ], + [ + 7, + '无上之盾', + '\\r[#dddd44]第一章终极技能\\r[],战斗时智慧会充当等量护盾', + 0, + 2500, + [6, 10, 5, 1, 2, 2], + [5, 3], + 1, + 1, + '战斗时智慧会充当护盾' + ] ]; // 深拷贝list list = core.clone(list); @@ -2049,7 +2626,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.status.hero.mana += 5; break; case 2: // 断灭之刃 - core.setFlag("bladeOn", true); + core.setFlag('bladeOn', true); break; case 3: // 坚韧 +2防御 core.status.hero.def += 2; @@ -2058,13 +2635,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.status.hero.hpmax += 1; break; case 5: // 治愈之泉 - core.setFlag("spring", true); + core.setFlag('spring', true); break; case 6: // 坚固之盾 +10防御 core.status.hero.def += 10; break; case 7: // 无上之盾 - core.setFlag("superSheild", true); + core.setFlag('superSheild', true); break; } core.status.hero.mdef -= list[index][4]; @@ -2072,7 +2649,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 由光标位置获得索引 this.getIdBySelector = function (x, y, page) { for (var i in list) { - if (list[i][8] == page && x == list[i][6][0] && y == list[i][6][1]) { + if ( + list[i][8] == page && + x == list[i][6][0] && + y == list[i][6][1] + ) { return i; } } @@ -2091,16 +2672,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { max = list[id][7], effect = list[id][9]; // 先建画布 - core.createCanvas("tree", 0, 0, 480, 480, 130); + core.createCanvas('tree', 0, 0, 480, 480, 130); // 背景 - core.fillRect("tree", 0, 0, 480, 480, [0, 0, 0, 0.95]); - core.drawLine("tree", 0, 172, 480, 172, [200, 200, 200, 0.95], 1); - core.drawLine("tree", 308, 172, 308, 480, [200, 200, 200, 0.95], 1); - core.drawLine("tree", 308, 450, 480, 450, [200, 200, 200, 0.95], 1); - core.drawLine("tree", 308, 220, 480, 220, [200, 200, 200, 0.95], 1); - core.drawLine("tree", 308, 413, 480, 413, [200, 200, 200, 0.95], 1); + core.fillRect('tree', 0, 0, 480, 480, [0, 0, 0, 0.95]); + core.drawLine('tree', 0, 172, 480, 172, [200, 200, 200, 0.95], 1); + core.drawLine('tree', 308, 172, 308, 480, [200, 200, 200, 0.95], 1); + core.drawLine('tree', 308, 450, 480, 450, [200, 200, 200, 0.95], 1); + core.drawLine('tree', 308, 220, 480, 220, [200, 200, 200, 0.95], 1); + core.drawLine('tree', 308, 413, 480, 413, [200, 200, 200, 0.95], 1); for (var i = 0; i <= 239; i++) { - core.drawLine("tree", i, 40, 480 - i, 40, [0, 255, 107, 0.002], 2); + core.drawLine( + 'tree', + i, + 40, + 480 - i, + 40, + [0, 255, 107, 0.002], + 2 + ); } // 每一项技能图标 for (var i in list) { @@ -2109,61 +2698,172 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { for (var j = 0; j < list[i][5].length; j += 2) { if (!list[i][5]) break; if (levels[list[i][5][j]] < list[i][5][j + 1]) - core.drawLine("tree", list[list[i][5][j]][6][0] * 56 - 14, list[list[i][5][j]][6][1] * 56 + 158, - list[i][6][0] * 56 - 14, list[i][6][1] * 56 + 158, "#aaaaaa", 1); - else core.drawLine("tree", list[list[i][5][j]][6][0] * 56 - 14, list[list[i][5][j]][6][1] * 56 + 158, - list[i][6][0] * 56 - 14, list[i][6][1] * 56 + 158, "#00FF88", 1); + core.drawLine( + 'tree', + list[list[i][5][j]][6][0] * 56 - 14, + list[list[i][5][j]][6][1] * 56 + 158, + list[i][6][0] * 56 - 14, + list[i][6][1] * 56 + 158, + '#aaaaaa', + 1 + ); + else + core.drawLine( + 'tree', + list[list[i][5][j]][6][0] * 56 - 14, + list[list[i][5][j]][6][1] * 56 + 158, + list[i][6][0] * 56 - 14, + list[i][6][1] * 56 + 158, + '#00FF88', + 1 + ); } } // 图标 for (var i in list) { // 图标 - core.drawImage("tree", "skill" + i + ".png", 0, 0, 114, 114, list[i][6][0] * 56 - 28, list[i][6][1] * 56 + 144, 28, 28); + core.drawImage( + 'tree', + 'skill' + i + '.png', + 0, + 0, + 114, + 114, + list[i][6][0] * 56 - 28, + list[i][6][1] * 56 + 144, + 28, + 28 + ); // 方框 if (levels[i] == 0) - core.strokeRect("tree", list[i][6][0] * 56 - 28, list[i][6][1] * 56 + 144, 28, 28, "#888888", 1); + core.strokeRect( + 'tree', + list[i][6][0] * 56 - 28, + list[i][6][1] * 56 + 144, + 28, + 28, + '#888888', + 1 + ); else if (levels[i] == list[i][7]) - core.strokeRect("tree", list[i][6][0] * 56 - 28, list[i][6][1] * 56 + 144, 28, 28, "#F7FF68", 1); + core.strokeRect( + 'tree', + list[i][6][0] * 56 - 28, + list[i][6][1] * 56 + 144, + 28, + 28, + '#F7FF68', + 1 + ); else - core.strokeRect("tree", list[i][6][0] * 56 - 28, list[i][6][1] * 56 + 144, 28, 28, "#00FF69", 1); + core.strokeRect( + 'tree', + list[i][6][0] * 56 - 28, + list[i][6][1] * 56 + 144, + 28, + 28, + '#00FF69', + 1 + ); // 光标 - core.strokeRect("tree", selector[0] * 56 - 28, selector[1] * 56 + 144, 28, 28, "#ffff00", 1); + core.strokeRect( + 'tree', + selector[0] * 56 - 28, + selector[1] * 56 + 144, + 28, + 28, + '#ffff00', + 1 + ); } // 说明 - core.setTextAlign("tree", "center"); - core.fillText("tree", name, 240, 30, "#00FFD5", "28px normal"); - core.setTextAlign("tree", "left") - core.drawTextContent("tree", " " + description, { left: 10, top: 42, maxWidth: 460, font: "normal", fontSize: 18 }); + core.setTextAlign('tree', 'center'); + core.fillText('tree', name, 240, 30, '#00FFD5', '28px normal'); + core.setTextAlign('tree', 'left'); + core.drawTextContent('tree', ' ' + description, { + left: 10, + top: 42, + maxWidth: 460, + font: 'normal', + fontSize: 18 + }); // 效果 if (level != 0) - core.drawTextContent("tree", "当前效果:" + effect, { left: 10, top: 122, maxWidth: 460, font: "normal", fontSize: 18 }); + core.drawTextContent('tree', '当前效果:' + effect, { + left: 10, + top: 122, + maxWidth: 460, + font: 'normal', + fontSize: 18 + }); if (level != max) { flags.levels[id] += 1; core.initializeList(false); effect = list[id][9]; - core.drawTextContent("tree", "下一级效果:" + effect, { left: 10, top: 147, maxWidth: 460, font: "normal", fontSize: 18 }); + core.drawTextContent('tree', '下一级效果:' + effect, { + left: 10, + top: 147, + maxWidth: 460, + font: 'normal', + fontSize: 18 + }); flags.levels[id]--; core.initializeList(false); effect = list[id][9]; } - core.setTextAlign("tree", "center"); + core.setTextAlign('tree', 'center'); // 等级 - core.fillText("tree", "等级:" + level + "/" + max, 394, 190, "#ffffff", "18px normal"); + core.fillText( + 'tree', + '等级:' + level + '/' + max, + 394, + 190, + '#ffffff', + '18px normal' + ); // 升级 if (level != max) - core.fillText("tree", "升级花费:" + cost, 394, 210, "#ffffff", "18px normal"); + core.fillText( + 'tree', + '升级花费:' + cost, + 394, + 210, + '#ffffff', + '18px normal' + ); // 退出 - core.fillText("tree", "退出", 394, 470, "#ffffff", "18px normal"); + core.fillText('tree', '退出', 394, 470, '#ffffff', '18px normal'); // 页码数 var text = core.replaceNumberWithChinese(currPage); - core.fillText("tree", "第" + text + "章", 394, 440, "#ffffff", "24px normal"); - if (currPage != 1) core.fillText("tree", "<", 334, 440, "#ffffff", "24px normal"); - if (currPage != flags.chapter) core.fillText("tree", ">", 454, 440, "#ffffff", "24px normal"); + core.fillText( + 'tree', + '第' + text + '章', + 394, + 440, + '#ffffff', + '24px normal' + ); + if (currPage != 1) + core.fillText('tree', '<', 334, 440, '#ffffff', '24px normal'); + if (currPage != flags.chapter) + core.fillText('tree', '>', 454, 440, '#ffffff', '24px normal'); // 前置技能 - core.fillText("tree", "前置技能", 394, 245, "#ffffff", "20px normal"); + core.fillText( + 'tree', + '前置技能', + 394, + 245, + '#ffffff', + '20px normal' + ); if (foreSkill.length > 0) { for (var i = 0; i < foreSkill.length; i += 2) { - core.fillText("tree", foreSkill[i + 1] + "级 " + list[foreSkill[i]][1], 394, 270 + 10 * i); + core.fillText( + 'tree', + foreSkill[i + 1] + '级 ' + list[foreSkill[i]][1], + 394, + 270 + 10 * i + ); } } }; @@ -2171,22 +2871,22 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.upgradeTree = function (index) { // 执行操作 if (levels[index] == list[index][7]) { - core.playSound("操作失败"); - core.insertAction(["该技能已满级!"]); + core.playSound('操作失败'); + core.insertAction(['该技能已满级!']); return; } // 判断前置技能 var fore = list[index][5]; for (var i = 0; i < fore.length; i += 2) { if (levels[fore[i]] < fore[i + 1]) { - core.playSound("操作失败"); - core.insertAction(["前置技能未满足!"]); + core.playSound('操作失败'); + core.insertAction(['前置技能未满足!']); return; } } if (core.status.hero.mdef < list[index][4]) { - core.playSound("操作失败"); - core.insertAction(["智慧点不足!"]); + core.playSound('操作失败'); + core.insertAction(['智慧点不足!']); return; } flags.levels[index]++; @@ -2196,17 +2896,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.updateStatusBar(); core.updateDamage(); // 音效 - core.playSound("tree.mp3"); - core.insertAction([ - { "type": "sleep", "time": 100, "noSkip": true }, - ]); + core.playSound('tree.mp3'); + core.insertAction([{ type: 'sleep', time: 100, noSkip: true }]); }; // 上下左右 this.moveSelector = function (keycode, times) { times = times || 0; - core.playSound("光标移动"); - if (keycode == 37 || keycode == 39) { // left right - if (times > 3) { // 正左右没有东西 移动至下一列 + core.playSound('光标移动'); + if (keycode == 37 || keycode == 39) { + // left right + if (times > 3) { + // 正左右没有东西 移动至下一列 selector[0] -= 3 * (keycode - 38); for (var i in list) { if (list[i][8] != currPage) continue; @@ -2219,15 +2919,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return; } selector[0] += keycode - 38; - for (var i in list) { // 正左右有技能 移动至最近的技能 + for (var i in list) { + // 正左右有技能 移动至最近的技能 if (list[i][8] != currPage) continue; - if (list[i][6][0] == selector[0] && list[i][6][1] == selector[1]) { + if ( + list[i][6][0] == selector[0] && + list[i][6][1] == selector[1] + ) { selector = list[i][6]; return; } } return core.moveSelector(keycode, times + 1); - } else { // up down + } else { + // up down if (times > 3) { selector[1] -= 3 * (keycode - 39); for (var i in list) { @@ -2243,7 +2948,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { selector[1] += keycode - 39; for (var i in list) { if (list[i][8] != currPage) continue; - if (list[i][6][1] == selector[1] && list[i][6][0] == selector[0]) { + if ( + list[i][6][1] == selector[1] && + list[i][6][0] == selector[0] + ) { selector = list[i][6]; return; } @@ -2257,14 +2965,18 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var x = Math.ceil(px / 56), y = Math.ceil((py - 172) / 56); if (selector[0] == x && selector[1] == y) { - var id = core.getIdBySelector(selector[0], selector[1], currPage); + var id = core.getIdBySelector( + selector[0], + selector[1], + currPage + ); core.upgradeTree(id); } else { for (var i in list) { if (list[i][8] != currPage) continue; if (list[i][6][0] == x && list[i][6][1] == y) { selector = [x, y]; - core.playSound("光标移动"); + core.playSound('光标移动'); return; } } @@ -2280,8 +2992,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { break; case 27: case 88: // 退出 - core.playSound("取消"); - core.insertAction({ "type": "break" }); + core.playSound('取消'); + core.insertAction({ type: 'break' }); break; case 37: case 38: @@ -2294,8 +3006,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 点击操作 this.treeClick = function (px, py) { if (px >= 308 && py >= 450) { - core.playSound("取消"); - core.insertAction({ "type": "break" }); + core.playSound('取消'); + core.insertAction({ type: 'break' }); } if (px <= 308 && py >= 172) { core.getSelectorByLoc(px, py); @@ -2310,59 +3022,91 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.openTree = function () { // 插入事件 core.initializeList(true); - core.playSound("打开界面"); - core.insertAction([{ - "type": "while", - "condition": "true", - "data": [ - { "type": "function", "function": "() => { core.plugin.drawTree(false); }" }, - { "type": "wait" }, - { "type": "function", "function": "() => { core.plugin.actTree(); }" } - ] - }, - { - "type": "function", - "function": "() => { core.deleteCanvas('tree');}" - } + core.playSound('打开界面'); + core.insertAction([ + { + type: 'while', + condition: 'true', + data: [ + { + type: 'function', + function: '() => { core.plugin.drawTree(false); }' + }, + { type: 'wait' }, + { + type: 'function', + function: '() => { core.plugin.actTree(); }' + } + ] + }, + { + type: 'function', + function: "() => { core.deleteCanvas('tree');}" + } ]); }; }, - "skills": function () { + skills: function () { // 所有的主动技能效果 var ignoreInJump = { event: ['X20007', 'X20001', 'X20006', 'X20014', 'X20010', 'X20007'], - bg: ['X20037', 'X20038', 'X20039', 'X20045', 'X20047', 'X20053', - 'X20054', 'X20055', 'X20067', 'X20068', 'X20075', 'X20076'] + bg: [ + 'X20037', + 'X20038', + 'X20039', + 'X20045', + 'X20047', + 'X20053', + 'X20054', + 'X20055', + 'X20067', + 'X20068', + 'X20075', + 'X20076' + ] }; // 跳跃 this.jumpSkill = function () { - if (core.status.floorId.startsWith("tower")) return core.drawTip("当无法使用该技能"); + if (core.status.floorId.startsWith('tower')) + return core.drawTip('当无法使用该技能'); if (!flags.skill2) return; - if (!flags['jump_' + core.status.floorId]) flags['jump_' + core.status.floorId] = 0; - if (core.status.floorId == 'MT14' && flags['jump_' + core.status.floorId] == 2 && !flags.MT14Jump) { - if (!(core.status.hero.loc.x == 77 && core.status.hero.loc.y == 5 && core.status.hero.loc.direction == 'right')) { - return core.drawTip("该地图还有一个必跳的地方,你还没有跳"); + if (!flags['jump_' + core.status.floorId]) + flags['jump_' + core.status.floorId] = 0; + if ( + core.status.floorId == 'MT14' && + flags['jump_' + core.status.floorId] == 2 && + !flags.MT14Jump + ) { + if ( + !( + core.status.hero.loc.x == 77 && + core.status.hero.loc.y == 5 && + core.status.hero.loc.direction == 'right' + ) + ) { + return core.drawTip('该地图还有一个必跳的地方,你还没有跳'); } else flags.MT14Jump = true; } - if (flags['jump_' + core.status.floorId] >= 3) return core.drawTip('当前地图使用次数已用完'); + if (flags['jump_' + core.status.floorId] >= 3) + return core.drawTip('当前地图使用次数已用完'); core.autosave(); var direction = core.status.hero.loc.direction; var loc = core.status.hero.loc; var checkLoc = {}; switch (direction) { - case "up": + case 'up': checkLoc.x = loc.x; checkLoc.y = loc.y - 1; break; - case "right": + case 'right': checkLoc.x = loc.x + 1; checkLoc.y = loc.y; break; - case "down": + case 'down': checkLoc.x = loc.x; checkLoc.y = loc.y + 1; break; - case "left": + case 'left': checkLoc.x = loc.x - 1; checkLoc.y = loc.y; break; @@ -2371,14 +3115,25 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var cls = core.getBlockCls(checkLoc.x, checkLoc.y); var noPass = core.noPass(checkLoc.x, checkLoc.y); var id = core.getBlockId(checkLoc.x, checkLoc.y) || ''; - var bgId = core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y)).event.id || ''; + var bgId = + core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y)) + .event.id || ''; // 可以通行 - if (!noPass || cls == "items" || (id.startsWith('X') && !ignoreInJump.event.includes(id)) || - (bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId))) - return core.drawTip("当前无法使用技能"); + if ( + !noPass || + cls == 'items' || + (id.startsWith('X') && !ignoreInJump.event.includes(id)) || + (bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId)) + ) + return core.drawTip('当前无法使用技能'); // 不是怪物且不可以通行 - if (noPass && !(cls == "enemys" || cls == "enemy48")) { - var toLoc = checkNoPass(direction, checkLoc.x, checkLoc.y, true); + if (noPass && !(cls == 'enemys' || cls == 'enemy48')) { + var toLoc = checkNoPass( + direction, + checkLoc.x, + checkLoc.y, + true + ); if (!toLoc) return; core.status.hero.hp -= 200 * flags.hard; core.updateStatusBar(); @@ -2388,14 +3143,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.updateStatusBar(); core.events.lose('你跳死了'); } - core.playSound("015-Jump01.ogg"); + core.playSound('015-Jump01.ogg'); core.insertAction([ - { "type": "jumpHero", "loc": [toLoc.x, toLoc.y], "time": 500 }, + { type: 'jumpHero', loc: [toLoc.x, toLoc.y], time: 500 } ]); } // 是怪物 - if (cls == "enemys" || cls == "enemy48") { - var firstNoPass = checkNoPass(direction, checkLoc.x, checkLoc.y, false); + if (cls == 'enemys' || cls == 'enemy48') { + var firstNoPass = checkNoPass( + direction, + checkLoc.x, + checkLoc.y, + false + ); if (!firstNoPass) return; core.status.hero.hp -= 200 * flags.hard; core.updateStatusBar(); @@ -2405,48 +3165,61 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.updateStatusBar(); core.events.lose('你跳死了'); } - core.playSound("015-Jump01.ogg"); - core.insertAction([{ - "type": "jump", - "from": [checkLoc.x, checkLoc.y], - "to": [firstNoPass.x, firstNoPass.y], - "time": 500, - "keep": true - },]); + core.playSound('015-Jump01.ogg'); + core.insertAction([ + { + type: 'jump', + from: [checkLoc.x, checkLoc.y], + to: [firstNoPass.x, firstNoPass.y], + time: 500, + keep: true + } + ]); } // 检查一条线上的不可通过 - function checkNoPass (direction, x, y, startNo) { + function checkNoPass(direction, x, y, startNo) { if (!startNo) startNo = false; switch (direction) { - case "up": + case 'up': y--; break; - case "right": + case 'right': x++; break; - case "down": + case 'down': y++; break; - case "left": + case 'left': x--; break; } - if (x > core.status.thisMap.width - 1 || y > - core.status.thisMap.height - 1 || x < 0 || y < 0) return core.drawTip("当前无法使用技能"); + if ( + x > core.status.thisMap.width - 1 || + y > core.status.thisMap.height - 1 || + x < 0 || + y < 0 + ) + return core.drawTip('当前无法使用技能'); var id = core.getBlockId(x, y) || ''; if (core.getBgNumber(x, y)) - var bgId = core.getBlockByNumber(core.getBgNumber(x, y)).event.id || ''; + var bgId = + core.getBlockByNumber(core.getBgNumber(x, y)).event + .id || ''; else var bgId = ''; - if (core.noPass(x, y) || core.getBlockCls(x, y) == "items" || (id.startsWith('X') && !ignoreInJump.event.includes(id)) || - (bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId)) || core.getBlockCls(x, y) == "animates") + if ( + core.noPass(x, y) || + core.getBlockCls(x, y) == 'items' || + (id.startsWith('X') && !ignoreInJump.event.includes(id)) || + (bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId)) || + core.getBlockCls(x, y) == 'animates' + ) return checkNoPass(direction, x, y, true); if (!startNo) return checkNoPass(direction, x, y, false); - return { 'x': x, 'y': y }; + return { x: x, y: y }; } }; }, - "changeFly": async function () { - + changeFly: async function () { // 该插件可自定义空间很大,自定义内容请看注释 // ------------------------- 安装说明 ------------------------- // @@ -2526,7 +3299,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const defaultValue = { font: 'Verdana', // 默认字体 scale: 3, // 默认地图缩放比例 - depth: Infinity, // 默认的遍历深度 + depth: Infinity // 默认的遍历深度 }; // ---- 不可自定义,计算数据 @@ -2537,9 +3310,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { right: [0, -1], upFloor: [0, 0], downFloor: [0, 0] - } + }; - let ignoreEnemies = this.ignoreEnemies = []; + let ignoreEnemies = (this.ignoreEnemies = []); let allChangeEntries = Object.entries(defaultChange); @@ -2559,7 +3332,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { await new Promise(res => { const result = bfsSearch(now, Infinity, true); mapCache[`${now}_Infinity_false`] = result; - areas.push({ name: core.floors[now].title, maps: result.order }); + areas.push({ + name: core.floors[now].title, + maps: result.order + }); for (const map of result.order) { scanned[map] = true; all = all.filter(v => !result.order.includes(v)); @@ -2568,30 +3344,47 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }); } })(); - } + }; /** 工具按钮 */ class Button extends Sprite { - constructor(name, x, y, w, h, text, fontSize = '20px', transition = true) { + constructor( + name, + x, + y, + w, + h, + text, + fontSize = '20px', + transition = true + ) { const btn = super(x, y, w, h, 1050, 'game', name); this.css(transition); setTimeout(() => btn.setCss(`opacity: 1;`), 50); const ctx = btn.context; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; - core.fillText(ctx, text, w / 2, h / 2, '#fff', `${fontSize} normal`, w - 10); + core.fillText( + ctx, + text, + w / 2, + h / 2, + '#fff', + `${fontSize} normal`, + w - 10 + ); sprites[name] = btn; } - css (transition) { + css(transition) { this.setCss( 'transition: opacity 0.6s linear, transform 0.2s linear;' + - 'background-color: #aaa;' + - 'box-shadow: 0px 0px 0px black;' + - (transition ? 'opacity: 0;' : '') + - 'filter: drop-shadow(1px 1px 2px black);' + - 'box-shadow: 0px 0px 4px black;' + - 'cursor: pointer;' + 'background-color: #aaa;' + + 'box-shadow: 0px 0px 0px black;' + + (transition ? 'opacity: 0;' : '') + + 'filter: drop-shadow(1px 1px 2px black);' + + 'box-shadow: 0px 0px 4px black;' + + 'cursor: pointer;' ); } } @@ -2608,14 +3401,18 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } } - /** + /** * 获取绘制信息 * @param {string?} center 中心地图id * @param {number?} depth 搜索深度 * @param {boolean?} noCache 是否不使用缓存 * @returns {MapDrawInfo} */ - this.getMapDrawInfo = function (center = core.status.floorId, depth = defaultValue.depth, noCache = false) { + this.getMapDrawInfo = function ( + center = core.status.floorId, + depth = defaultValue.depth, + noCache = false + ) { nowDepth = depth; drawingMap = center; const id = `${center}_${depth}_${noBorder}`; @@ -2627,22 +3424,27 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { res.upOrDown = map.upOrDown; drawCache[id] = res; return res; - } + }; - /** + /** * 绘制大地图,可拖动、滚轮缩放、点击对应位置可以楼传等 * @param {string} floorId 中心地图的id * @param {number} depth 遍历深度 * @param {boolean} noCache 是否不使用缓存 * @param {number} scale 绘制的缩放比例 */ - this.drawFlyMap = function (floorId = core.status.floorId, - depth = defaultValue.depth, noCache = false, scale = defaultValue.scale) { - + this.drawFlyMap = function ( + floorId = core.status.floorId, + depth = defaultValue.depth, + noCache = false, + scale = defaultValue.scale + ) { if (core.isReplaying()) return; // 把区域页码归零 - nowArea = areas.findIndex(v => v.maps.includes(core.status.floorId)); + nowArea = areas.findIndex(v => + v.maps.includes(core.status.floorId) + ); areaPage = 0; nowScale = scale; selecting = floorId; @@ -2655,7 +3457,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { status = 'flyMap'; core.lockControl(); core.canvas.data.canvas.style.zIndex = '990'; - } + }; /** * 获得某个区域的剩余怪物 @@ -2668,7 +3470,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * data: 怪物数量的原始信息,格式为{ 楼层id: { 'x,y': 怪物id } } * } */ - this.getRemainEnemy = function (floorId = core.status.floorId, area = false) { + this.getRemainEnemy = function ( + floorId = core.status.floorId, + area = false + ) { const res = bfsSearch(floorId, Infinity, false); // 整合怪物总数 /** @type {{[x: string]: number}} */ @@ -2676,37 +3481,51 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const toShow = area ? res.order : [floorId]; const strArr = []; const add = (...num) => num.reduce((pre, cur) => pre + cur, 0); - const name = (id) => core.material.enemys[id].name; - const title = (id) => core.status.maps[id].title; + const name = id => core.material.enemys[id].name; + const title = id => core.status.maps[id].title; for (const id of toShow) { const enemies = res.enemies[id]; Object.values(enemies).forEach(v => { // 编辑器不支持 ??=,悲 category[v] = category[v] ?? 0; category[v]++; - }) + }); // 每个怪物的信息 - strArr.push(...Object.entries(enemies) - .map(v => `${name(v[1])} 楼层:${title(id)},楼层id:${id},坐标:${v[0]}`)); + strArr.push( + ...Object.entries(enemies).map( + v => + `${name(v[1])} 楼层:${title( + id + )},楼层id:${id},坐标:${v[0]}` + ) + ); } // 输出字符串 - const all = `当前${area ? '区域' : '地图'}中剩余怪物数量:${add(...Object.values(category))}`; - const classified = Object.entries(category).map(v => `${name(v[0])} × ${v[1]}`).join`\n`; + const all = `当前${area ? '区域' : '地图'}中剩余怪物数量:${add( + ...Object.values(category) + )}`; + const classified = Object.entries(category).map( + v => `${name(v[0])} × ${v[1]}` + ).join`\n`; const detail = []; while (strArr.length > 0) { detail.push(strArr.splice(0, 20).join`\n`); } - return { rough: `${all}\n${classified}`, detail, data: res.enemies }; - } + return { + rough: `${all}\n${classified}`, + detail, + data: res.enemies + }; + }; - /** + /** * 广度优先搜索搜索地图路径 * @param {string} center 中心地图的id * @param {number} depth 搜索深度 * @param {boolean} noCache 是否不使用缓存 * @returns {BFSResult} 格式:floorId_x_y_dir: floorId_x_y */ - function bfsSearch (center, depth, noCache) { + function bfsSearch(center, depth, noCache) { // 检查缓存 const id = `${center}_${depth}_${noBorder}`; if (mapCache[id] && !noCache) return mapCache[id]; @@ -2738,7 +3557,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } // 检测触发器是否为切换楼层,不是则直接跳过 if (block.event.trigger !== 'changeFloor') continue; - const dirEntries = allChangeEntries.find(v => v[1] === block.event.id); + const dirEntries = allChangeEntries.find( + v => v[1] === block.event.id + ); // 如果不是那六种传送门,直接忽略 if (!dirEntries) continue; const data = block.event.data; @@ -2773,20 +3594,27 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * @param {string[]} order 遍历顺序 * @returns {MapDrawInfo} 地图的绘制信息 */ - function getDrawInfo (map, center, order) { + function getDrawInfo(map, center, order) { // 先根据地图id分类,从而确定每个地图连接哪些地图,同时方便处理 const links = {}; for (const i in map) { const splitted = i.split('_'); - const id = splitted[0] + const id = splitted[0]; if (!links[id]) links[id] = {}; links[id][i] = map[i]; } // 分类完毕,然后根据连接点先计算出各个地图的坐标,然后再进行判断 const centerFloor = core.status.maps[center]; const visitedCenter = core.hasVisitedFloor(center); - const locs = { // 格式:[中心x, 中心y, 宽, 高, 是否到达过] - [center]: [0, 0, centerFloor.width, centerFloor.height, visitedCenter] + const locs = { + // 格式:[中心x, 中心y, 宽, 高, 是否到达过] + [center]: [ + 0, + 0, + centerFloor.width, + centerFloor.height, + visitedCenter + ] }; const lines = {}; // 地图间的连线 // 可以上楼下楼的地图 @@ -2827,16 +3655,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { y = locs[tf][1]; } else { // 计算坐标,公式可以通过画图推断出 - x = fLoc[0] - ha * (fhw - fx + tx - thw) - v * (fhw + thw + dis); - y = fLoc[1] - va * (fhh - fy + ty - thh) - h * (fhh + thh + dis); - }; - locs[tf] = locs[tf] ?? [x, y, toFloor.width, toFloor.height, core.hasVisitedFloor(tf)]; + x = + fLoc[0] - + ha * (fhw - fx + tx - thw) - + v * (fhw + thw + dis); + y = + fLoc[1] - + va * (fhh - fy + ty - thh) - + h * (fhh + thh + dis); + } + locs[tf] = locs[tf] ?? [ + x, + y, + toFloor.width, + toFloor.height, + core.hasVisitedFloor(tf) + ]; // 添加连线 - lines[`${from}_${to}`] = [[ - fx - fhw + locs[ff][0], - fy - fhh + locs[ff][1], - x + tx - thw, y + ty - thh - ]]; + lines[`${from}_${to}`] = [ + [ + fx - fhw + locs[ff][0], + fy - fhh + locs[ff][1], + x + tx - thw, + y + ty - thh + ] + ]; } } // 获取地图绘制需要的长宽 @@ -2876,50 +3719,129 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 绘制背景 */ - function drawBack () { + function drawBack() { if (status !== 'none') return; - new Back('__map_back__', 0, 0, core._PX_, core._PY_, 175, 'rgba(0, 0, 0, 0.9)'); - const listen = new Sprite(0, 0, core._PX_, core._PY_, 1000, 'game', '__map_listen__'); + new Back( + '__map_back__', + 0, + 0, + core._PX_, + core._PY_, + 175, + 'rgba(0, 0, 0, 0.9)' + ); + const listen = new Sprite( + 0, + 0, + core._PX_, + core._PY_, + 1000, + 'game', + '__map_listen__' + ); addDrag(listen); - const exit = new Button('__map_exit__', core._PX_ - 64, core._PY_ - 26, 60, 22, '退出'); + const exit = new Button( + '__map_exit__', + core._PX_ - 64, + core._PY_ - 26, + 60, + 22, + '退出' + ); exit.addEventListener('click', close); sprites.listen = listen; } /** 绘制工具栏 */ - function drawTools () { - new Back('__map_toolback__', 0, core._PY_ - 30, core._PX_, 30, 600, 'rgba(200, 200, 200, 0.9)'); + function drawTools() { + new Back( + '__map_toolback__', + 0, + core._PY_ - 30, + core._PX_, + 30, + 600, + 'rgba(200, 200, 200, 0.9)' + ); // 无边框 - const border = new Button('__map_border__', core._PX_ - 150, core._PY_ - 26, 60, 22, '边框'); + const border = new Button( + '__map_border__', + core._PX_ - 150, + core._PY_ - 26, + 60, + 22, + '边框' + ); border.addEventListener('click', changeBorder); // 怪物数量 - const enemy = new Button('__map_enemy__', core._PX_ - 240, core._PY_ - 26, 60, 22, '怪物'); + const enemy = new Button( + '__map_enemy__', + core._PX_ - 240, + core._PY_ - 26, + 60, + 22, + '怪物' + ); enemy.addEventListener('click', triggerEnemy); // 区域显示 - const area = new Back('__map_areasback__', core._PX_ - 80, 0, 80, core._PY_ - 30, 550, 'rgba(200, 200, 200, 0.9)'); + const area = new Back( + '__map_areasback__', + core._PX_ - 80, + 0, + 80, + core._PY_ - 30, + 550, + 'rgba(200, 200, 200, 0.9)' + ); drawAreaList(); - core.drawLine(area.context, 0, core._PY_ - 30, 80, core._PY_ - 30, '#222', 2); + core.drawLine( + area.context, + 0, + core._PY_ - 30, + 80, + core._PY_ - 30, + '#222', + 2 + ); } /** 绘制区域列表 */ - function drawAreaList (transition = true) { + function drawAreaList(transition = true) { const start = perPage * areaPage; Object.values(areaSprite).forEach(v => v.destroy()); areaSprite = {}; for (let i = start; i < start + perPage && areas[i]; i++) { const n = i % perPage; const { name, maps } = areas[i]; - const btn = new Button(`_area_${maps[0]}`, core._PX_ - 75, 4 + 30 * n, 70, 22, name, '16px', transition); + const btn = new Button( + `_area_${maps[0]}`, + core._PX_ - 75, + 4 + 30 * n, + 70, + 22, + name, + '16px', + transition + ); areaSprite[maps[0]] = btn; if (i === nowArea) btn.setCss(`border: 2px solid gold;`); btn.addEventListener('click', e => { if (i === nowArea) return; changeArea(i); - }) + }); } // 上一页下一页 if (areaPage > 0) { - const last = new Button('_area_last_', core._PX_ - 75, core._PY_ - 50, 30, 16, '上一页', '14px', transition); + const last = new Button( + '_area_last_', + core._PX_ - 75, + core._PY_ - 50, + 30, + 16, + '上一页', + '14px', + transition + ); areaSprite._area_last_ = last; last.addEventListener('click', e => { areaPage--; @@ -2927,7 +3849,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }); } if (areaPage < Math.floor(areas.length / perPage)) { - const next = new Button('_area_next_', core._PX_ - 35, core._PY_ - 50, 30, 16, '下一页', '14px', transition); + const next = new Button( + '_area_next_', + core._PX_ - 35, + core._PY_ - 50, + 30, + 16, + '下一页', + '14px', + transition + ); areaSprite._area_next_ = next; next.addEventListener('click', e => { areaPage++; @@ -2936,12 +3867,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } } - /** + /** * 绘制大地图 * @param {MapDrawInfo} info 地图绘制信息 * @param {number} scale 地图的绘制比例 */ - function drawMap (info, scale = defaultValue.scale) { + function drawMap(info, scale = defaultValue.scale) { if (status === 'flyMap') return; const PX = core._PX_, PY = core._PY_; @@ -2963,11 +3894,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { for (const route in lines) { const line = lines[route]; for (const node of line) { - const from = `${node[0]},${node[1]}`, to = `${node[2]},${node[3]}`; - if (drawed[`${from}-${to}`] || drawed[`${to}-${from}`]) continue; + const from = `${node[0]},${node[1]}`, + to = `${node[2]},${node[3]}`; + if (drawed[`${from}-${to}`] || drawed[`${to}-${from}`]) + continue; drawed[`${from}-${to}`] = true; let lineWidth = scale / 2; - core.drawLine(ctx, node[0] * scale, node[1] * scale, node[2] * scale, node[3] * scale, '#fff', lineWidth); + core.drawLine( + ctx, + node[0] * scale, + node[1] * scale, + node[2] * scale, + node[3] * scale, + '#fff', + lineWidth + ); } } // 再绘制楼层 @@ -2976,20 +3917,39 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const loc = locs[id]; let color = '#000'; if (!loc[4]) color = '#f0f'; - const [x, y, w, h] = loc.map(v => typeof v === 'number' && v * scale); - let dx = 0, dy = 0; // 避免绘图误差 + const [x, y, w, h] = loc.map( + v => typeof v === 'number' && v * scale + ); + let dx = 0, + dy = 0; // 避免绘图误差 if (loc[2] % 2 === 0) dx = 0.5 * scale; if (loc[3] % 2 === 0) dy = 0.5 * scale; - const fx = x - w / 2 - dx, fy = y - h / 2 - dy; + const fx = x - w / 2 - dx, + fy = y - h / 2 - dy; core.fillRect(ctx, fx, fy, w, h, color); - if (id === selecting) core.strokeRect(ctx, fx, fy, w, h, 'gold', scale / 2); + if (id === selecting) + core.strokeRect(ctx, fx, fy, w, h, 'gold', scale / 2); else core.strokeRect(ctx, fx, fy, w, h, '#fff', scale / 2); const layer = info.upOrDown[id]; const min = Math.min(w, h); if (layer?.includes('upFloor')) - core.drawIcon(ctx, defaultChange.upFloor, fx, fy, min / 3, min / 3); + core.drawIcon( + ctx, + defaultChange.upFloor, + fx, + fy, + min / 3, + min / 3 + ); if (layer?.includes('downFloor')) - core.drawIcon(ctx, defaultChange.downFloor, fx + w - min / 3, fy + h - min / 3, min / 3, min / 3); + core.drawIcon( + ctx, + defaultChange.downFloor, + fx + w - min / 3, + fy + h - min / 3, + min / 3, + min / 3 + ); // 显示漏怪数量 if (showEnemy) { ctx.textAlign = 'center'; @@ -3002,7 +3962,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (n > 20) color = '#f22'; ctx.shadowBlur = 0.6 * nowScale; ctx.shadowColor = '#000'; - core.fillText(ctx, `怪物数量:${n}`, x, y, color, `${2 * nowScale}px normal`); + core.fillText( + ctx, + `怪物数量:${n}`, + x, + y, + color, + `${2 * nowScale}px normal` + ); ctx.shadowBlur = 0; } } @@ -3010,47 +3977,74 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { checkThumbnail(); } - /** + /** * 重新绘制缩略图 * @param {Sprite} sprite * @param {string} floor */ - function drawThumbnail (sprite, floor, x, y, w, h) { + function drawThumbnail(sprite, floor, x, y, w, h) { const ctx = sprite.context; const scale = nowScale; core.drawThumbnail(floor, void 0, { - ctx: ctx, x: x - w / 2, y: y - h / 2, - damage: true, all: true, size: Math.max(w, h) / Math.max(core._PX_, core._PY_), + ctx: ctx, + x: x - w / 2, + y: y - h / 2, + damage: true, + all: true, + size: Math.max(w, h) / Math.max(core._PX_, core._PY_), fromMap: true }); - const color = floor === core.status.floorId ? 'gold' : '#fff' + const color = floor === core.status.floorId ? 'gold' : '#fff'; if (!noBorder) - core.strokeRect(ctx, x - w / 2, y - h / 2, w, h, color, scale / 2); + core.strokeRect( + ctx, + x - w / 2, + y - h / 2, + w, + h, + color, + scale / 2 + ); } /** 检查是否需要绘制缩略图 */ - function checkThumbnail () { + function checkThumbnail() { const id = `${drawingMap}_${nowDepth}_${noBorder}`; const locs = drawCache[id].locs; const map = canDrag[`__flyMap__`]; for (const id in locs) { const loc = locs[id]; const scale = nowScale; - const [x, y, w, h] = loc.map(v => typeof v === 'number' && v * scale); - let dx = 0, dy = 0; // 避免绘图误差 + const [x, y, w, h] = loc.map( + v => typeof v === 'number' && v * scale + ); + let dx = 0, + dy = 0; // 避免绘图误差 if (loc[2] % 2 === 0) dx = 0.5 * scale; if (loc[3] % 2 === 0) dy = 0.5 * scale; - if (!drawedThumbnail[id] && x + map.x > 0 && x + map.x < core._PX_ && - y + map.y > 0 && y + map.y < core._PY_) { + if ( + !drawedThumbnail[id] && + x + map.x > 0 && + x + map.x < core._PX_ && + y + map.y > 0 && + y + map.y < core._PY_ + ) { if (!noBorder && core.hasVisitedFloor(id) && scale > 5) { drawThumbnail(map, id, x - dx, y - dy, w, h); drawedThumbnail[id] = true; } if (noBorder) { - drawThumbnail(map, id, x - dx, y - dy, w, h) + drawThumbnail(map, id, x - dx, y - dy, w, h); drawedThumbnail[id] = true; if (!core.hasVisitedFloor(id)) - core.fillRect(map.context, x - dx - w / 2, y - dy - h / 2, w, h, 'rgba(255,0,255,0.2)'); + core.fillRect( + map.context, + x - dx - w / 2, + y - dy - h / 2, + w, + h, + 'rgba(255,0,255,0.2)' + ); } } } @@ -3059,44 +4053,65 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { const loc = locs[selecting]; const scale = nowScale; if (loc) { - const [x, y, w, h] = loc.map(v => typeof v === 'number' && v * scale); - core.strokeRect(map.context, x - w / 2, y - h / 2, w, h, 'gold', scale / 2); + const [x, y, w, h] = loc.map( + v => typeof v === 'number' && v * scale + ); + core.strokeRect( + map.context, + x - w / 2, + y - h / 2, + w, + h, + 'gold', + scale / 2 + ); } } } /** 检查点击点是否在以x,y为中心的某一矩形中 */ - function inRect (x, y, w, h, px, py) { + function inRect(x, y, w, h, px, py) { x -= w / 2; y -= h / 2; return px > x && px < x + w && py > y && py < y + h; } /** 测试画布是否超过上限,摘自https://github.com/jhildenbiddle/canvas-size */ - function canvasTest (size) { + function canvasTest(size) { const width = Math.max(Math.ceil(size[0]), 1); const height = Math.max(Math.ceil(size[1]), 1); if (width === 0 || height === 0) return true; const fill = [width - 1, height - 1, 1, 1]; let cropCvs, testCvs; - cropCvs = document.createElement("canvas"); + cropCvs = document.createElement('canvas'); cropCvs.width = 1; cropCvs.height = 1; - testCvs = document.createElement("canvas"); + testCvs = document.createElement('canvas'); testCvs.width = width; testCvs.height = height; - const cropCtx = cropCvs.getContext("2d"); - const testCtx = testCvs.getContext("2d"); + const cropCtx = cropCvs.getContext('2d'); + const testCtx = testCvs.getContext('2d'); if (testCtx) { testCtx.fillRect.apply(testCtx, fill); - cropCtx.drawImage(testCvs, width - 1, height - 1, 1, 1, 0, 0, 1, 1); + cropCtx.drawImage( + testCvs, + width - 1, + height - 1, + 1, + 1, + 0, + 0, + 1, + 1 + ); } - const isTestPass = cropCtx && cropCtx.getImageData(0, 0, 1, 1).data[3] !== 0; + const isTestPass = + cropCtx && cropCtx.getImageData(0, 0, 1, 1).data[3] !== 0; return isTestPass; } /** 检查浏览器限制 */ - function checkMaximum (before, scale) { + function checkMaximum(before, scale) { for (const id in canDrag) { const sprite = canDrag[id]; const rate = scale / before; @@ -3112,19 +4127,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 关闭事件 */ - function close () { + function close() { document.body.removeEventListener('keyup', keyboard); - Object.values(sprites).forEach((v) => { + Object.values(sprites).forEach(v => { v.setCss('transition: opacity 0.6s linear;'); }); setTimeout(() => { - Object.values(sprites).forEach((v) => { + Object.values(sprites).forEach(v => { v.setCss('opacity: 0;'); }); }, 50); setTimeout(() => { core.unlockControl(); - Object.values(sprites).forEach((v) => { + Object.values(sprites).forEach(v => { v.destroy(); }); drawedThumbnail = {}; @@ -3135,12 +4150,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }, 650); } - /** + /** * 点击地图事件,尝试楼层传送 * @param {MouseEvent} e */ - function clickMap (e) { - if (moved) return moved = false; + function clickMap(e) { + if (moved) return (moved = false); const { x, y } = core.actions._getClickLoc(e.clientX, e.clientY); let px = x / core.domStyle.scale, py = y / core.domStyle.scale; @@ -3152,7 +4167,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { py -= sprite.y; for (const id in locs) { const loc = locs[id]; - const [x, y, w, h] = loc.map(v => typeof v === 'number' && v * scale); + const [x, y, w, h] = loc.map( + v => typeof v === 'number' && v * scale + ); if (inRect(x, y, w, h, px, py)) { return flyTo(id); } @@ -3160,21 +4177,23 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 飞向某个楼层 */ - function flyTo (id) { + function flyTo(id) { if (!core.hasItem('fly')) return core.drawTip('你没有楼层传送器'); sprites.__map_back__.setCss('opacity: 0.2;'); - return core.flyTo(id, () => setTimeout(() => { - if (sprites.__map_back__) core.lockControl(); - }, 100)); + return core.flyTo(id, () => + setTimeout(() => { + if (sprites.__map_back__) core.lockControl(); + }, 100) + ); } - /** + /** * 拖拽事件 * @param {MouseEvent} e */ - function drag (e) { + function drag(e) { if (!clicking) return; - const scale = core.domStyle.scale + const scale = core.domStyle.scale; moveEle(e.movementX / scale, e.movementY / scale); } @@ -3183,10 +4202,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * @param {TouchEvent} e * @this {HTMLCanvasElement} */ - function touchDrag (e) { + function touchDrag(e) { moved = true; const scale = core.domStyle.scale; - if (e.touches.length === 1) { // 拖拽 + if (e.touches.length === 1) { + // 拖拽 const info = e.touches[0]; if (!lastTouch[this.id]) { lastTouch[this.id] = [info.clientX, info.clientY]; @@ -3197,7 +4217,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { dy = y - lastTouch[this.id][1]; moveEle(dx / scale, dy / scale); lastTouch[this.id] = [info.clientX, info.clientY]; - } else if (e.touches.length >= 2) { // 双指放缩 + } else if (e.touches.length >= 2) { + // 双指放缩 const [first, second] = e.touches; const dx = first.clientX - second.clientX, dy = first.clientY - second.clientY; @@ -3225,11 +4246,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } } - /** + /** * 滚轮缩放 * @param {WheelEvent} e */ - function wheel (e) { + function wheel(e) { const delta = 1 - Math.sign(e.deltaY) / 10; const { x, y } = core.actions._getClickLoc(e.clientX, e.clientY); const scale = core.domStyle.scale; @@ -3248,19 +4269,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 切换边框 */ - function changeBorder () { + function changeBorder() { noBorder = !noBorder; redraw('border'); } /** 切换是否显示漏怪数量 */ - function triggerEnemy () { + function triggerEnemy() { showEnemy = !showEnemy; redraw('enemy'); } /** 改变区域 */ - function changeArea (index) { + function changeArea(index) { nowArea = index; drawAreaList(false); drawedThumbnail = {}; @@ -3270,21 +4291,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } /** 重绘 */ - function redraw (id, px, py, move = true) { + function redraw(id, px, py, move = true) { const { x, y } = canDrag.__flyMap__; status = id; drawedThumbnail = {}; - drawMap(core.plugin.getMapDrawInfo(drawingMap, nowDepth, true), nowScale); + drawMap( + core.plugin.getMapDrawInfo(drawingMap, nowDepth, true), + nowScale + ); if (move) canDrag.__flyMap__.move(px ?? x, py ?? y); checkThumbnail(); } - /** + /** * 拖拽时移动需要元素 * @param {string} dx * @param {string} dy */ - function moveEle (dx, dy) { + function moveEle(dx, dy) { moved = true; for (const id in canDrag) { const sprite = canDrag[id]; @@ -3296,12 +4320,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { checkThumbnail(); } - /** + /** * 缩放绘制地图 * @param {number} target 目标缩放比例 * @param {{[x: string]: [number, number]}} info 缩放后的sprite位置数据 */ - function scaleMap (target, info) { + function scaleMap(target, info) { // 检查浏览器限制 if (checkMaximum(nowScale, target)) return; clearTimeout(lastScale); @@ -3314,26 +4338,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { sprite.move(x - sprite.width / 2, y - sprite.height / 2); lastScale = setTimeout(() => { redraw('scale', x - sprite.width / 2, y - sprite.height / 2); - }, 200) + }, 200); } /** 键盘操作 * @param {KeyboardEvent} e */ - function keyboard (e) { - if (e.key === 'Enter' || e.key === 'C' || e.key === 'c' || e.key === '') { + function keyboard(e) { + if ( + e.key === 'Enter' || + e.key === 'C' || + e.key === 'c' || + e.key === '' + ) { return flyTo(selecting); } else if (e.key === 'Escape' || e.key === 'x' || e.key === 'X') { return close(); } else if (e.key.startsWith('Arrow')) { const dir = e.key.slice(5).toLowerCase(); // 获取目标楼层 - const res = mapCache[`${drawingMap}_${nowDepth}_${noBorder}`].res; - const key = Object.keys(res) - .find(v => { - const [floorId, x, y, d] = v.split('_'); - return floorId === selecting && d === dir; - }); + const res = + mapCache[`${drawingMap}_${nowDepth}_${noBorder}`].res; + const key = Object.keys(res).find(v => { + const [floorId, x, y, d] = v.split('_'); + return floorId === selecting && d === dir; + }); if (!key) return; const target = res[key].split('_')[0]; selecting = target; @@ -3345,75 +4374,179 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * 给需要的元素添加拖拽等事件 * @param {HTMLCanvasElement} ele */ - function addDrag (ele) { + function addDrag(ele) { ele.addEventListener('wheel', wheel); ele.addEventListener('mousemove', drag); ele.addEventListener('touchmove', touchDrag); ele.addEventListener('click', clickMap); - ele.addEventListener('mousedown', () => { clicking = true; }); - ele.addEventListener('mouseup', () => { clicking = false; }); - ele.addEventListener('touchend', () => { lastTouch = {}; lastLength = 0; }); + ele.addEventListener('mousedown', () => { + clicking = true; + }); + ele.addEventListener('mouseup', () => { + clicking = false; + }); + ele.addEventListener('touchend', () => { + lastTouch = {}; + lastLength = 0; + }); document.body.addEventListener('keyup', keyboard); } - maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { + maps.prototype._drawThumbnail_drawToTarget = function ( + floorId, + options + ) { const ctx = core.getContextByName(options.ctx); if (ctx == null) return; - const x = options.x || 0, y = options.y || 0, size = options.size || 1; + const x = options.x || 0, + y = options.y || 0, + size = options.size || 1; // size的含义改为(0,1]范围的系数以适配长方形,默认为1,楼传为3/4,SL界面为0.3 - let w = Math.ceil(size * core._PX_), h = Math.ceil(size * core._PY_); + let w = Math.ceil(size * core._PX_), + h = Math.ceil(size * core._PY_); // 特判是否为编辑器,编辑器中长宽均采用core.js的遗留正方形像素边长,以保证下面的绘制正常 if (main.mode == 'editor') w = h = size * core.__PIXELS__; - const width = core.floors[floorId].width, height = core.floors[floorId].height; - let centerX = options.centerX, centerY = options.centerY; + const width = core.floors[floorId].width, + height = core.floors[floorId].height; + let centerX = options.centerX, + centerY = options.centerY; if (centerX == null) centerX = Math.floor(width / 2); if (centerY == null) centerY = Math.floor(height / 2); const tempCanvas = core.bigmap.tempCanvas; if (options.all) { - const tempWidth = tempCanvas.canvas.width, tempHeight = tempCanvas.canvas.height; + const tempWidth = tempCanvas.canvas.width, + tempHeight = tempCanvas.canvas.height; // 绘制全景图 if (tempWidth <= tempHeight) { - const realHeight = h, realWidth = realHeight * tempWidth / tempHeight; + const realHeight = h, + realWidth = (realHeight * tempWidth) / tempHeight; const side = (w - realWidth) / 2; if (options.fromMap) { - return core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y, realWidth, realHeight); + return core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x, + y, + realWidth, + realHeight + ); } core.fillRect(ctx, x, y, side, realHeight, '#000000'); core.fillRect(ctx, x + w - side, y, side, realHeight); - core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x + side, y, realWidth, realHeight); - } - else { - const realWidth = w, realHeight = realWidth * tempHeight / tempWidth; + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x + side, + y, + realWidth, + realHeight + ); + } else { + const realWidth = w, + realHeight = (realWidth * tempHeight) / tempWidth; const side = (h - realHeight) / 2; if (options.fromMap) { - return core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y, realWidth, realHeight); + return core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x, + y, + realWidth, + realHeight + ); } core.fillRect(ctx, x, y, realWidth, side, '#000000'); core.fillRect(ctx, x, y + h - side, realWidth, side); - core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y + side, realWidth, realHeight); + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x, + y + side, + realWidth, + realHeight + ); } - } - else { + } else { // 只绘制可见窗口 - let pw = core._PX_, ph = core._PY_, hw = core._HALF_WIDTH_, hh = core._HALF_HEIGHT_, W = core._WIDTH_, H = core._HEIGHT_; - const ratio = core.domStyle.isVertical ? core.domStyle.ratio : core.domStyle.scale; - if (main.mode == 'editor') { pw = ph = core.__PIXELS__; hw = hh = core.__HALF_SIZE__; W = H = core.__SIZE__; } + let pw = core._PX_, + ph = core._PY_, + hw = core._HALF_WIDTH_, + hh = core._HALF_HEIGHT_, + W = core._WIDTH_, + H = core._HEIGHT_; + const ratio = core.domStyle.isVertical + ? core.domStyle.ratio + : core.domStyle.scale; + if (main.mode == 'editor') { + pw = ph = core.__PIXELS__; + hw = hh = core.__HALF_SIZE__; + W = H = core.__SIZE__; + } if (options.v2) { - core.drawImage(ctx, tempCanvas.canvas, 0, 0, pw * ratio, ph * ratio, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + pw * ratio, + ph * ratio, + x, + y, + w, + h + ); } else { const offsetX = core.clamp(centerX - hw, 0, width - W), offsetY = core.clamp(centerY - hh, 0, height - H); if (options.noHD) { - core.drawImage(ctx, tempCanvas.canvas, offsetX * 32, offsetY * 32, pw, ph, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + offsetX * 32, + offsetY * 32, + pw, + ph, + x, + y, + w, + h + ); return; } - core.drawImage(ctx, tempCanvas.canvas, offsetX * 32 * ratio, offsetY * 32 * ratio, pw * ratio, ph * ratio, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + offsetX * 32 * ratio, + offsetY * 32 * ratio, + pw * ratio, + ph * ratio, + x, + y, + w, + h + ); } } - } + }; }, - "loopMap": function () { + loopMap: function () { // 循环式地图相关 // 防止重开游戏出问题 ////// 加载某个楼层(从剧本或存档中) ////// @@ -3421,7 +4554,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var floor = fromReset ? main.floors[floorId] : core.floors[floorId]; if (!map) map = floor.map; if (map instanceof Array) { - map = { "map": map }; + map = { map: map }; } if (!map.map) map.map = core.clone(floor.map); var content = {}; @@ -3442,18 +4575,27 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }; ////// 自动存档 ////// control.prototype.autosave = function (removeLast) { - if (core.hasFlag('__forbidSave__') || core.status.floorId == 'tower6') return; + if ( + core.hasFlag('__forbidSave__') || + core.status.floorId == 'tower6' + ) + return; var x = null; if (removeLast) { x = core.status.route.pop(); - core.status.route.push("turn:" + core.getHeroLoc('direction')); + core.status.route.push('turn:' + core.getHeroLoc('direction')); } - if (core.status.event.id == 'action') // 事件中的自动存档 - core.setFlag("__events__", core.clone(core.status.event.data)); + if (core.status.event.id == 'action') + // 事件中的自动存档 + core.setFlag('__events__', core.clone(core.status.event.data)); if (core.saves.autosave.data == null) { core.saves.autosave.data = []; } - core.saves.autosave.data.splice(core.saves.autosave.now, 0, core.saveData()); + core.saves.autosave.data.splice( + core.saves.autosave.now, + 0, + core.saveData() + ); core.saves.autosave.now += 1; if (core.saves.autosave.data.length > core.saves.autosave.max) { if (core.saves.autosave.now < core.saves.autosave.max / 2) @@ -3465,7 +4607,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } core.saves.autosave.updated = true; core.saves.ids[0] = true; - core.removeFlag("__events__"); + core.removeFlag('__events__'); if (removeLast) { core.status.route.pop(); if (x) core.status.route.push(x); @@ -3477,37 +4619,46 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (!floorId) return; if (typeof floorId == 'string') floorId = [floorId]; var needRefresh = false; - floorId.forEach((t) => { + floorId.forEach(t => { core.status.maps[t] = core.maps.loadFloor(t, null, true); // 重置本层的全部独立事件 - Object.keys(core.status.hero.flags).forEach((one) => { - if (one.startsWith(floorId + '@')) delete core.status.hero.flags[one]; + Object.keys(core.status.hero.flags).forEach(one => { + if (one.startsWith(floorId + '@')) + delete core.status.hero.flags[one]; }); // 重置本层的图块删除信息 delete (flags.__disabled__ || {})[t]; delete (core.status.mapBlockObjs || {})[t]; if (t == core.status.floorId) needRefresh = true; - ['bg', 'bg2', 'fg', 'fg2'].forEach((layer) => { + ['bg', 'bg2', 'fg', 'fg2'].forEach(layer => { core.floors[floorId] = main.floors[floorId]; - }) + }); }); if (needRefresh) this.drawMap(); - core.drawTip("地图重置成功"); + core.drawTip('地图重置成功'); }; // 勇士不动图层动 control.prototype._moveAction_moving = function (callback) { core.setHeroMoveInterval(() => { - if (core.status.floorId != "tower6") { + if (core.status.floorId != 'tower6') { core.setHeroLoc('x', core.nextX(), true); } else { - if (core.status.hero.loc.direction != "down" && core.status.hero.loc.direction != "up") { + if ( + core.status.hero.loc.direction != 'down' && + core.status.hero.loc.direction != 'up' + ) { core.setHeroLoc('x', 12, true); - var block = core.getMapBlocksObj(core.status.floorId)[core.nextX() + "," + core.nextY]; + var block = core.getMapBlocksObj(core.status.floorId)[ + core.nextX() + ',' + core.nextY + ]; if (block) var trigger = block.event.trigger; - else var trigger = ""; - if (trigger != "battle") { - core.changeEventsBgFg(core.status.hero.loc.direction, - "tower6", ["tower1", "tower2", "tower4", "tower5"]); + else var trigger = ''; + if (trigger != 'battle') { + core.changeEventsBgFg( + core.status.hero.loc.direction, + 'tower6', + ['tower1', 'tower2', 'tower4', 'tower5'] + ); } core.drawMap(); } @@ -3535,21 +4686,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (core.status.replay.speed > 12) toAdd = 8; core.interval.heroMoveInterval = window.setInterval(() => { core.status.heroMoving += toAdd; - if (core.status.floorId == "tower6") - core.backgroundImage("tower6.jpeg"); + if (core.status.floorId == 'tower6') + core.backgroundImage('tower6.jpeg'); if (core.status.heroMoving >= 8) { clearInterval(core.interval.heroMoveInterval); core.status.heroMoving = 0; if (callback) callback(); } - }, core.values.moveSpeed / 8 * toAdd / core.status.replay.speed); + }, ((core.values.moveSpeed / 8) * toAdd) / core.status.replay.speed); }; // 事件层前景层背景层平移 this.changeEventsBgFg = function (direction, floorId, fromIds) { - if (direction == "up" || direction == "down") return; + if (direction == 'up' || direction == 'down') return; var floor = core.floors[floorId]; // 原始层楼层转换平移 - fromIds.forEach((id) => { + fromIds.forEach(id => { var toChanges = {}; for (var one in core.floors[id].changeFloor) { var data = core.floors[id].changeFloor[one]; @@ -3557,11 +4708,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { y = data.loc[1]; var blocks = core.getMapBlocksObj(id); var toFloor = data.floorId; - if (blocks[one] && !blocks[one].event.id.startsWith("A")) { + if (blocks[one] && !blocks[one].event.id.startsWith('A')) { toChanges[one] = { floorId: toFloor, loc: [x, y] }; continue; } else { - if (direction == "left") x = x >= floor.width - 1 ? 0 : x + 1; + if (direction == 'left') + x = x >= floor.width - 1 ? 0 : x + 1; else x = x <= 0 ? floor.width - 1 : x - 1; toChanges[one] = { floorId: toFloor, loc: [x, y] }; } @@ -3574,19 +4726,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.getMapBlocksObj(id, true); }); var list = ['events', 'changeFloor']; - list.forEach((name) => { + list.forEach(name => { var toEvents = {}; // 获得事件并删除原事件 for (var one in floor[name]) { - var loc = one.split(","); + var loc = one.split(','); var x = parseInt(loc[0]), y = parseInt(loc[1]); - if (direction == "left") { + if (direction == 'left') { var toX = x == floor.width - 1 ? 0 : x + 1; - toEvents[toX + "," + y] = floor[name][one]; + toEvents[toX + ',' + y] = floor[name][one]; } else { var toX = x == 0 ? floor.width - 1 : x - 1; - toEvents[toX + "," + y] = floor[name][one]; + toEvents[toX + ',' + y] = floor[name][one]; } delete core.floors[floorId][name][one]; } @@ -3595,7 +4747,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }); // 前景事件背景层图块平移 list = ['bgmap', 'bg2map', 'map', 'fgmap', 'fg2map']; - list.forEach((one) => { + list.forEach(one => { if (one == 'map') { var toBlocks = core.clone(core.status.maps[floorId].map); } else { @@ -3604,20 +4756,39 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (toBlocks.length == 0) return; for (var y = 0; y < toBlocks.length; y++) { for (var x = 0; x < toBlocks[y].length; x++) { - if (direction == "left") { - if (one != "map") - floor[one][y][x] = toBlocks[y][x == 0 ? floor.width - 1 : x - 1]; - else core.status.maps[floorId].map[y][x] = toBlocks[y][x == 0 ? floor.width - 1 : x - 1]; + if (direction == 'left') { + if (one != 'map') + floor[one][y][x] = + toBlocks[y][ + x == 0 ? floor.width - 1 : x - 1 + ]; + else + core.status.maps[floorId].map[y][x] = + toBlocks[y][ + x == 0 ? floor.width - 1 : x - 1 + ]; } else { - if (one != "map") - floor[one][y][x] = toBlocks[y][x == floor.width - 1 ? 0 : x + 1]; - else core.status.maps[floorId].map[y][x] = toBlocks[y][x == floor.width - 1 ? 0 : x + 1]; + if (one != 'map') + floor[one][y][x] = + toBlocks[y][ + x == floor.width - 1 ? 0 : x + 1 + ]; + else + core.status.maps[floorId].map[y][x] = + toBlocks[y][ + x == floor.width - 1 ? 0 : x + 1 + ]; } } } }); delete core.status.maps[floorId].blocks; - core.setMapBlockDisabled(floorId, core.nextX(), core.nextY(), false); + core.setMapBlockDisabled( + floorId, + core.nextX(), + core.nextY(), + false + ); core.extractBlocks(floorId); core.getMapBlocksObj(floorId, true); }; @@ -3632,19 +4803,33 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { w = image.width; // 裁剪 var sx = w / 2 - 240, - sy = core.bigmap.offsetY / (core.status.thisMap.height * 32 - 480) * (h - 480); + sy = + (core.bigmap.offsetY / + (core.status.thisMap.height * 32 - 480)) * + (h - 480); // 背景层遮挡 - core.createCanvas("bImage", 0, 0, 480, 480, 25); + core.createCanvas('bImage', 0, 0, 480, 480, 25); // 事件层遮挡 - core.createCanvas("eImage", 0, 0, 480, 480, 70); - core.clearMap("bImage"); + core.createCanvas('eImage', 0, 0, 480, 480, 70); + core.clearMap('bImage'); // 左半边 - core.drawImage("bImage", image, sx, sy, 96, 480, 0, 0, 96, 480); - core.drawImage("eImage", image, sx, sy, 64, 480, 0, 0, 64, 480); + core.drawImage('bImage', image, sx, sy, 96, 480, 0, 0, 96, 480); + core.drawImage('eImage', image, sx, sy, 64, 480, 0, 0, 64, 480); // 右半边 sx = w / 2 + 144; - core.drawImage("bImage", image, sx, sy, 96, 480, 384, 0, 96, 480); - core.drawImage("eImage", image, sx + 32, sy, 64, 480, 416, 0, 64, 480); + core.drawImage('bImage', image, sx, sy, 96, 480, 384, 0, 96, 480); + core.drawImage( + 'eImage', + image, + sx + 32, + sy, + 64, + 480, + 416, + 0, + 64, + 480 + ); }; // 到达地图重定位 this.relocateLoopMap = function (floorId, heroLoc, fromIds) { @@ -3653,13 +4838,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var toX = Math.floor(floor.width / 2); if (nowX == toX) return; // 设置勇士位置 - core.setHeroLoc("x", 12); + core.setHeroLoc('x', 12); // 计算偏移量 var dx = toX - nowX; // 转换 // 原始层楼层转换平移 - if (floorId == 'tower6') fromIds = ["tower1", "tower2", "tower4", "tower5"]; - fromIds.forEach((id) => { + if (floorId == 'tower6') + fromIds = ['tower1', 'tower2', 'tower4', 'tower5']; + fromIds.forEach(id => { var toChanges = {}; for (var one in core.floors[id].changeFloor) { var data = core.floors[id].changeFloor[one]; @@ -3667,11 +4853,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { y = data.loc[1]; var blocks = core.getMapBlocksObj(id); var toFloor = data.floorId; - if (blocks[one] && !blocks[one].event.id.startsWith("A")) { + if (blocks[one] && !blocks[one].event.id.startsWith('A')) { toChanges[one] = { floorId: toFloor, loc: [x, y] }; continue; } - if (dx > 0) x = x + dx > floor.width - 1 ? dx + x - floor.width : dx + x; + if (dx > 0) + x = + x + dx > floor.width - 1 + ? dx + x - floor.width + : dx + x; else x = x + dx < 0 ? dx + x + floor.width : dx + x; toChanges[one] = { floorId: toFloor, loc: [x, y] }; } @@ -3683,11 +4873,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.getMapBlocksObj(id, true); }); var list = ['events', 'changeFloor']; - list.forEach((name) => { + list.forEach(name => { var toEvents = {}; // 获得事件并删除原事件 for (var one in floor[name]) { - var loc = one.split(","); + var loc = one.split(','); var x = parseInt(loc[0]), y = parseInt(loc[1]); if (x + dx > floor.width - 1) { @@ -3697,7 +4887,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } else { x += dx; } - toEvents[x + "," + y] = floor[name][one]; + toEvents[x + ',' + y] = floor[name][one]; delete core.floors[floorId][name][one]; } // 转换 @@ -3706,7 +4896,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { dx = -dx; // 前景事件背景层图块平移 list = ['bgmap', 'bg2map', 'map', 'fgmap', 'fg2map']; - list.forEach((one) => { + list.forEach(one => { if (one == 'map') { var toBlocks = core.clone(core.status.maps[floorId].map); } else { @@ -3716,13 +4906,35 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { for (var y = 0; y < toBlocks.length; y++) { for (var x = 0; x < toBlocks[y].length; x++) { if (dx > 0) { - if (one != "map") - floor[one][y][x] = toBlocks[y][x + dx > floor.width - 1 ? dx + x - floor.width : dx + x]; - else core.status.maps[floorId].map[y][x] = toBlocks[y][x + dx > floor.width - 1 ? dx + x - floor.width : dx + x]; + if (one != 'map') + floor[one][y][x] = + toBlocks[y][ + x + dx > floor.width - 1 + ? dx + x - floor.width + : dx + x + ]; + else + core.status.maps[floorId].map[y][x] = + toBlocks[y][ + x + dx > floor.width - 1 + ? dx + x - floor.width + : dx + x + ]; } else { - if (one != "map") - floor[one][y][x] = toBlocks[y][x + dx < 0 ? dx + x + floor.width : dx + x]; - else core.status.maps[floorId].map[y][x] = toBlocks[y][x + dx < 0 ? dx + x + floor.width : dx + x]; + if (one != 'map') + floor[one][y][x] = + toBlocks[y][ + x + dx < 0 + ? dx + x + floor.width + : dx + x + ]; + else + core.status.maps[floorId].map[y][x] = + toBlocks[y][ + x + dx < 0 + ? dx + x + floor.width + : dx + x + ]; } } } @@ -3738,7 +4950,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (!floorId) { var map = {}; for (var id in maps) { - if (id == "tower6") continue; + if (id == 'tower6') continue; var obj = this.saveMap(id); if (Object.keys(obj).length > 0) map[id] = obj; } @@ -3751,7 +4963,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var map = maps[floorId]; var thisFloor = this._compressFloorData(map, core.floors[floorId]); - var mapArr = this.compressMap(map.blocks ? this._getMapArrayFromBlocks(map.blocks, map.width, map.height, true) : map.map, floorId); + var mapArr = this.compressMap( + map.blocks + ? this._getMapArrayFromBlocks( + map.blocks, + map.width, + map.height, + true + ) + : map.map, + floorId + ); if (mapArr != null) thisFloor.map = mapArr; return thisFloor; }; @@ -3759,13 +4981,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.saveLoopMap = function (floorId, fromIds) { // 当前层 var data = {}; - ['bg2map', 'bgmap', 'changeFloor', 'fgmap', 'fg2map'].forEach((one) => { - data[one] = core.floors[floorId][one]; - }); + ['bg2map', 'bgmap', 'changeFloor', 'fgmap', 'fg2map'].forEach( + one => { + data[one] = core.floors[floorId][one]; + } + ); // 可以到达该层的楼层转换 data.map = core.status.maps[floorId].map; - data.changes = {} - fromIds.forEach((id) => { + data.changes = {}; + fromIds.forEach(id => { data.changes[id] = core.floors[id].changeFloor; }); return data; @@ -3791,70 +5015,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } }; }, - "warning": function () { - // warning - // 初始化 - if (main.replayChecking) return; - // 默认音效名 - var defaultSound = 'warning.mp3'; - // 默认字体名 - var defaultFont = 'normal'; - - var timeout; - /** warning提示 - * @param {number} x 横坐标 - * @param {number} y 纵坐标 - * @param {string} text 显示的文字 - */ - this.drawWarning = function (x, y, text) { - if (timeout) return; - x = x || 6; - y = y || 6; - text = text || 'boss'; - text += '
'; - for (var i = 0; i < 10; i++) text += ' '; - text += 'danger'; - // 生成文字 - var elements = document.querySelectorAll('.gameCanvas'); - var t = document.createElement('p'); - t.innerHTML = text; - t.style.position = 'absolute'; - t.style.fontSize = '4em'; - t.style.left = -(300 * core.domStyle.scale) + 'px'; - t.style.top = (parseInt(elements[0].style.height) / 2 - 100) + 'px'; - t.style.zIndex = '300'; - t.style.color = '#f11'; - t.style.fontFamily = defaultFont; - t.style.overflow = 'none'; - t.style.width = '100%'; - t.classList.add('warning'); - core.dom.gameDraw.appendChild(t); - setTimeout(() => { t.style.left = (416 * core.domStyle.scale) + 'px' }, 50); - // 计算偏移量 - var px = (6 - x) / 12 * 50; - var py = (6 - y) / 12 * 50; - // 修改画布的scale和transform - elements.forEach((v) => { - if (v instanceof HTMLCanvasElement) { - v.style.transform = 'scale(2)translate(' + px + '%, ' + py + '%)'; - } - }); - core.playSound(defaultSound); - // 拉回镜头 - timeout = setTimeout(() => { - timeout = setTimeout(() => { - timeout = void 0; - core.dom.gameDraw.removeChild(t); - }, 1500); - elements.forEach((v) => { - if (v instanceof HTMLCanvasElement) { - v.style.transform = 'none'; - } - }); - }, 1600); - } - }, - "towerBoss": function () { + towerBoss: function () { // 智慧boss // 变量们 var stage = 1, @@ -3870,58 +5031,69 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { heroHp = core.status.hero.hp; core.dynamicChangeHp(0, 10000, 10000); core.autoFixRouteBoss(true); - core.insertAction([ - { "type": "sleep", "time": 1000, "noSkip": true }, - ]); + core.insertAction([{ type: 'sleep', time: 1000, noSkip: true }]); setTimeout(core.bossCore, 1000); }; // 录像自动修正 this.autoFixRouteBoss = function (isStart) { var route = core.status.route; - if (isStart) { // 开始修正 记录当前录像长度 + if (isStart) { + // 开始修正 记录当前录像长度 flags.startFix = route.length - 1; return; } // 结束修正 删除录像 并追加跳过步骤 route.splice(flags.startFix); - route.push("choices:0"); + route.push('choices:0'); delete flags.startFix; }; // 血条 this.healthBar = function (now, total) { - // 关闭小地图 + // 关闭小地图 flags.__useMinimap__ = false; core.drawMinimap(); - var nowLength = now / total * 476; // 当前血量下绘制长度 - var color = [255 * 2 - now / total * 2 * 255, now / total * 2 * 255, 0, 1]; // 根据当前血量计算颜色 + var nowLength = (now / total) * 476; // 当前血量下绘制长度 + var color = [ + 255 * 2 - (now / total) * 2 * 255, + (now / total) * 2 * 255, + 0, + 1 + ]; // 根据当前血量计算颜色 // 建画布 if (!core.dymCanvas.healthBar) - core.createCanvas("healthBar", 0, 0, 480, 16, 140); + core.createCanvas('healthBar', 0, 0, 480, 16, 140); else core.clearMap('healthBar'); // 底 - core.fillRect("healthBar", 0, 0, 480, 16, "#bbbbbb"); + core.fillRect('healthBar', 0, 0, 480, 16, '#bbbbbb'); // css特效 - var style = document.getElementById("healthBar").getContext("2d"); - style.shadowColor = "rgba(0, 0, 0, 0.8)"; + var style = document.getElementById('healthBar').getContext('2d'); + style.shadowColor = 'rgba(0, 0, 0, 0.8)'; style.shadowBlur = 5; style.shadowOffsetX = 10; style.shadowOffsetY = 5; - style.filter = "blur(1px)"; + style.filter = 'blur(1px)'; // 绘制 - core.fillRect("healthBar", 2, 2, nowLength, 12, color); + core.fillRect('healthBar', 2, 2, nowLength, 12, color); // css特效 - style.shadowColor = "rgba(0, 0, 0, 0.5)"; + style.shadowColor = 'rgba(0, 0, 0, 0.5)'; style.shadowOffsetX = 0; style.shadowOffsetY = 0; // 绘制边框 - core.strokeRect("healthBar", 1, 1, 478, 14, "#ffffff", 2); + core.strokeRect('healthBar', 1, 1, 478, 14, '#ffffff', 2); // 绘制文字 - style.shadowColor = "rgba(0, 0, 0, 1)"; + style.shadowColor = 'rgba(0, 0, 0, 1)'; style.shadowBlur = 3; style.shadowOffsetX = 2; style.shadowOffsetY = 1; - style.filter = "none"; - core.fillText("healthBar", now + "/" + total, 5, 13.5, "#ffffff", "16px normal"); + style.filter = 'none'; + core.fillText( + 'healthBar', + now + '/' + total, + 5, + 13.5, + '#ffffff', + '16px normal' + ); }; // 血量变化 this.dynamicChangeHp = function (from, to, total) { @@ -3945,24 +5117,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { time = time || 3000; // 创建画布 if (!core.dymCanvas.words) - core.createCanvas("words", x, y, 480, 24, 135); - else core.clearMap("words"); + core.createCanvas('words', x, y, 480, 24, 135); + else core.clearMap('words'); if (flags.wordsTimeOut) clearTimeout(flags.wordsTimeOut); core.dynamicCurtain(y, y + 24, time / 3); // css - var style = document.getElementById("words").getContext("2d"); - style.shadowColor = "rgba(0, 0, 0, 1)"; + var style = document.getElementById('words').getContext('2d'); + style.shadowColor = 'rgba(0, 0, 0, 1)'; style.shadowBlur = 3; style.shadowOffsetX = 2; style.shadowOffsetY = 1; // 一个一个绘制 skip1(0); // 跳字 - function skip1 (now) { + function skip1(now) { if (parseInt(now) >= words.length) { flags.wordsTimeOut = setTimeout(() => { - core.deleteCanvas("words"); - core.deleteCanvas("wordsBg"); + core.deleteCanvas('words'); + core.deleteCanvas('wordsBg'); }, time); return; } @@ -3972,50 +5144,86 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var skip2 = window.setInterval(() => { blur -= 0.4; frame++; - core.clearMap("words", nx, 0, 24, 24); - style.filter = "blur(" + blur + "px)"; - core.fillText("words", words[now], nx, 20, "#ffffff", "22px normal"); + core.clearMap('words', nx, 0, 24, 24); + style.filter = 'blur(' + blur + 'px)'; + core.fillText( + 'words', + words[now], + nx, + 20, + '#ffffff', + '22px normal' + ); if (frame == 5) { clearInterval(skip2); skip1(now + 1); } }, 20); - } }; // 匀变速下降背景 this.dynamicCurtain = function (from, to, time, width) { width = width || 480; if (!core.dymCanvas.wordsBg) - core.createCanvas("wordsBg", 0, from, width, 24, 130); - else core.clearMap("wordsBg"); + core.createCanvas('wordsBg', 0, from, width, 24, 130); + else core.clearMap('wordsBg'); time /= 1000; var ny = from, frame = 0, - a = 2 * (to - from) / Math.pow(time * 50, 2), + a = (2 * (to - from)) / Math.pow(time * 50, 2), speed = a * time * 50; - var style = document.getElementById("wordsBg").getContext("2d"); - style.shadowColor = "rgba(0, 0, 0, 0.8)"; + var style = document.getElementById('wordsBg').getContext('2d'); + style.shadowColor = 'rgba(0, 0, 0, 0.8)'; var wordsInterval = window.setInterval(() => { frame++; speed -= a; ny += speed; - core.clearMap("wordsBg"); + core.clearMap('wordsBg'); style.shadowBlur = 8; style.shadowOffsetY = 2; - core.fillRect("wordsBg", 0, 0, width, ny - from, [180, 180, 180, 0.7]); + core.fillRect( + 'wordsBg', + 0, + 0, + width, + ny - from, + [180, 180, 180, 0.7] + ); style.shadowBlur = 3; style.shadowOffsetY = 0; - core.strokeRect("wordsBg", 1, 1, width - 2, ny - from - 2, [255, 255, 255, 0.7], 2); + core.strokeRect( + 'wordsBg', + 1, + 1, + width - 2, + ny - from - 2, + [255, 255, 255, 0.7], + 2 + ); if (frame >= time * 50) { clearInterval(wordsInterval); - core.clearMap("wordsBg"); + core.clearMap('wordsBg'); style.shadowBlur = 8; style.shadowOffsetY = 2; - core.fillRect("wordsBg", 0, 0, width, to - from, [180, 180, 180, 0.7]); + core.fillRect( + 'wordsBg', + 0, + 0, + width, + to - from, + [180, 180, 180, 0.7] + ); style.shadowBlur = 3; style.shadowOffsetY = 0; - core.strokeRect("wordsBg", 1, 1, width - 2, ny - from - 2, [255, 255, 255, 0.7], 2); + core.strokeRect( + 'wordsBg', + 1, + 1, + width - 2, + ny - from - 2, + [255, 255, 255, 0.7], + 2 + ); } }, 20); }; @@ -4040,29 +5248,55 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 在地图上显示 flags.canAttack = true; if (!core.dymCanvas.attackBoss) - core.createCanvas("attackBoss", 0, 0, 480, 480, 35); - else core.clearMap("attackBoss"); - var style = document.getElementById("attackBoss").getContext("2d"); + core.createCanvas('attackBoss', 0, 0, 480, 480, 35); + else core.clearMap('attackBoss'); + var style = document.getElementById('attackBoss').getContext('2d'); var frame1 = 0, blur = 3, scale = 2, speed = 0.04, a = 0.0008; var atkAnimate = window.setInterval(() => { - core.clearMap("attackBoss"); + core.clearMap('attackBoss'); frame1++; speed -= a; scale -= speed; blur -= 0.06; - style.filter = "blur(" + blur + "px)"; - core.strokeCircle("attackBoss", nx * 32 + 16, ny * 32 + 16, 16 * scale, [255, 150, 150, 0.7], 4); - core.fillCircle("attackBoss", nx * 32 + 16, ny * 32 + 16, 3 * scale, [255, 150, 150, 0.7]); + style.filter = 'blur(' + blur + 'px)'; + core.strokeCircle( + 'attackBoss', + nx * 32 + 16, + ny * 32 + 16, + 16 * scale, + [255, 150, 150, 0.7], + 4 + ); + core.fillCircle( + 'attackBoss', + nx * 32 + 16, + ny * 32 + 16, + 3 * scale, + [255, 150, 150, 0.7] + ); if (frame1 == 50) { clearInterval(atkAnimate); - core.clearMap("attactkBoss"); - style.filter = "none"; - core.strokeCircle("attackBoss", nx * 32 + 16, ny * 32 + 16, 16, [255, 150, 150, 0.7], 4); - core.fillCircle("attackBoss", nx * 32 + 16, ny * 32 + 16, 3, [255, 150, 150, 0.7]); + core.clearMap('attactkBoss'); + style.filter = 'none'; + core.strokeCircle( + 'attackBoss', + nx * 32 + 16, + ny * 32 + 16, + 16, + [255, 150, 150, 0.7], + 4 + ); + core.fillCircle( + 'attackBoss', + nx * 32 + 16, + ny * 32 + 16, + 3, + [255, 150, 150, 0.7] + ); } }, 20); // 实时检测勇士位置 @@ -4077,7 +5311,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { delete flags.canAttack; }, 4000); clearInterval(atkBoss); - core.deleteCanvas("attackBoss"); + core.deleteCanvas('attackBoss'); return; } if (nx == x && ny == y) { @@ -4087,11 +5321,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.dynamicChangeHp(hp, hp - 500, 10000); hp -= 500; clearInterval(atkBoss); - core.deleteCanvas("attackBoss"); - if (hp > 3500) core.drawAnimate("hand", 7, 1); - else if (hp > 2000) core.drawAnimate("hand", 7, 2); - else if (hp > 1000) core.drawAnimate("hand", 7, 3); - else core.drawAnimate("hand", 7, 4); + core.deleteCanvas('attackBoss'); + if (hp > 3500) core.drawAnimate('hand', 7, 1); + else if (hp > 2000) core.drawAnimate('hand', 7, 2); + else if (hp > 1000) core.drawAnimate('hand', 7, 3); + else core.drawAnimate('hand', 7, 4); return; } }, 20); @@ -4100,27 +5334,38 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.bossCore = function () { var interval = window.setInterval(() => { if (stage == 1) { - if (seconds == 8) core.skipWord("智慧之神:你和之前来的人不一样"); - if (seconds == 12) core.skipWord("智慧之神:他们只会一股脑地向前冲"); - if (seconds == 16) core.skipWord("智慧之神:而你却会躲避这些攻击"); - if (seconds == 20) core.skipWord("提示:踩在红圈上可以对智慧之神造成伤害"); + if (seconds == 8) + core.skipWord('智慧之神:你和之前来的人不一样'); + if (seconds == 12) + core.skipWord('智慧之神:他们只会一股脑地向前冲'); + if (seconds == 16) + core.skipWord('智慧之神:而你却会躲避这些攻击'); + if (seconds == 20) + core.skipWord('提示:踩在红圈上可以对智慧之神造成伤害'); if (seconds > 10) core.attackBoss(); if (seconds % 10 == 0) core.intelligentArrow(); - if (seconds % 7 == 0 && seconds != 0) core.intelligentDoor(); + if (seconds % 7 == 0 && seconds != 0) + core.intelligentDoor(); if (seconds > 20 && seconds % 13 == 0) core.icyMomentem(); } if (stage == 1 && hp <= 7000) { stage++; seconds = 0; - core.skipWord("智慧之神:不错小伙子"); + core.skipWord('智慧之神:不错小伙子'); core.pauseBgm(); } if (stage == 2) { - if (seconds == 4) core.skipWord("智慧之神:你很有潜力"); - if (seconds == 8) core.skipWord("智慧之神:看来你很可能成为改变历史的人"); - if (seconds == 12) core.skipWord("智慧之神:不过,这场战斗才刚刚开始"); - if (seconds == 25) core.skipWord("提示:方形区域均为危险区域"); - if (seconds == 15) setTimeout(() => { core.playSound("thunder.mp3"); }, 500); + if (seconds == 4) core.skipWord('智慧之神:你很有潜力'); + if (seconds == 8) + core.skipWord('智慧之神:看来你很可能成为改变历史的人'); + if (seconds == 12) + core.skipWord('智慧之神:不过,这场战斗才刚刚开始'); + if (seconds == 25) + core.skipWord('提示:方形区域均为危险区域'); + if (seconds == 15) + setTimeout(() => { + core.playSound('thunder.mp3'); + }, 500); if (seconds == 16) core.startStage2(); if (seconds > 20) core.attackBoss(); if (seconds % 4 == 0 && seconds > 20) core.randomThunder(); @@ -4129,12 +5374,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (hp <= 3500 && stage == 2) { stage++; seconds = 0; - core.skipWord("智慧之神:不得不说小伙子"); + core.skipWord('智慧之神:不得不说小伙子'); core.pauseBgm(); } if (stage >= 3) { - if (seconds == 4) core.skipWord("智慧之神:我越来越欣赏你了"); - if (seconds == 8) core.skipWord("智慧之神:不过,你还得再过我一关!"); + if (seconds == 4) + core.skipWord('智慧之神:我越来越欣赏你了'); + if (seconds == 8) + core.skipWord('智慧之神:不过,你还得再过我一关!'); if (seconds == 12) core.startStage3(); if (seconds == 15) { flags.booming = true; @@ -4145,7 +5392,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (hp == 2000 && stage == 3) { stage++; flags.booming = false; - core.skipWord("智慧之神:还没有结束!"); + core.skipWord('智慧之神:还没有结束!'); core.startStage4(); setTimeout(() => { flags.booming = true; @@ -4155,7 +5402,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (hp == 1000 && stage == 4) { stage++; flags.booming = false; - core.skipWord("智慧之神:还没有结束!!!!!!"); + core.skipWord('智慧之神:还没有结束!!!!!!'); core.startStage5(); setTimeout(() => { flags.booming = true; @@ -4171,27 +5418,30 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { delete flags.__bgm__; core.pauseBgm(); core.insertAction([ - "\t[智慧之神,E557]\b[down,7,4]不错不错,你确实可以成为改变历史的人", - "\t[智慧之神,E557]\b[down,7,4]我的职责就到此结束了", - "\t[智慧之神,E557]\b[down,7,4]之后还是要看你自己了,千万不要让我失望!", - "\t[智慧之神,E557]\b[down,7,4]东边的机关门我已经替你打开了", - { "type": "openDoor", "loc": [13, 6], "floorId": "MT19" }, - "\t[智慧之神,E557]\b[down,7,4]我这就把你传送出去", - { "type": "setValue", "name": "flag:boss1", "value": "true" }, - { "type": "changeFloor", "floorId": "MT20", "loc": [7, 9] }, - { "type": "function", "function": "() => {\ncore.deleteAllCanvas();\n}" }, - { "type": "forbidSave" }, + '\t[智慧之神,E557]\b[down,7,4]不错不错,你确实可以成为改变历史的人', + '\t[智慧之神,E557]\b[down,7,4]我的职责就到此结束了', + '\t[智慧之神,E557]\b[down,7,4]之后还是要看你自己了,千万不要让我失望!', + '\t[智慧之神,E557]\b[down,7,4]东边的机关门我已经替你打开了', + { type: 'openDoor', loc: [13, 6], floorId: 'MT19' }, + '\t[智慧之神,E557]\b[down,7,4]我这就把你传送出去', + { type: 'setValue', name: 'flag:boss1', value: 'true' }, + { type: 'changeFloor', floorId: 'MT20', loc: [7, 9] }, + { + type: 'function', + function: '() => {\ncore.deleteAllCanvas();\n}' + }, + { type: 'forbidSave' } ]); } seconds++; }, 1000); }; - // ------ 第一阶段 10000~7000血 ------ // + // ------ 第一阶段 10000~7000血 ------ // // 技能1 智慧之箭 1000伤害 this.intelligentArrow = function (fromSelf) { // 坐标 var loc = Math.floor(Math.random() * 13 + 1); - var direction = Math.random() > 0.5 ? "horizon" : "vertical"; + var direction = Math.random() > 0.5 ? 'horizon' : 'vertical'; // 执行次数 if (!fromSelf) { var times = Math.ceil(Math.random() * 8) + 4; @@ -4205,54 +5455,106 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }, 200); } // 防重复 - if (core.dymCanvas["inteArrow" + loc + direction]) return core.intelligentArrow(true); + if (core.dymCanvas['inteArrow' + loc + direction]) + return core.intelligentArrow(true); // 危险区域 if (!core.dymCanvas.danger1) - core.createCanvas("danger1", 0, 0, 480, 480, 35); - if (direction == "horizon") { + core.createCanvas('danger1', 0, 0, 480, 480, 35); + if (direction == 'horizon') { for (var nx = 1; nx < 14; nx++) { - core.fillRect("danger1", nx * 32 + 2, loc * 32 + 2, 28, 28, [255, 0, 0, 0.6]); + core.fillRect( + 'danger1', + nx * 32 + 2, + loc * 32 + 2, + 28, + 28, + [255, 0, 0, 0.6] + ); } } else { for (var ny = 1; ny < 14; ny++) { - core.fillRect("danger1", loc * 32 + 2, ny * 32 + 2, 28, 28, [255, 0, 0, 0.6]); + core.fillRect( + 'danger1', + loc * 32 + 2, + ny * 32 + 2, + 28, + 28, + [255, 0, 0, 0.6] + ); } } // 箭 - if (!core.dymCanvas["inteArrow" + loc + direction]) - core.createCanvas("inteArrow" + loc + direction, 0, 0, 544, 544, 65); - core.clearMap("inteArrow" + loc + direction); - if (direction == "horizon") - core.drawImage("inteArrow" + loc + direction, "arrow.png", 448, loc * 32, 102, 32); + if (!core.dymCanvas['inteArrow' + loc + direction]) + core.createCanvas( + 'inteArrow' + loc + direction, + 0, + 0, + 544, + 544, + 65 + ); + core.clearMap('inteArrow' + loc + direction); + if (direction == 'horizon') + core.drawImage( + 'inteArrow' + loc + direction, + 'arrow.png', + 448, + loc * 32, + 102, + 32 + ); else - core.drawImage("inteArrow" + loc + direction, "arrow.png", 0, 0, 259, 75, loc * 32 - 32, 480, 102, 32, Math.PI / 2); + core.drawImage( + 'inteArrow' + loc + direction, + 'arrow.png', + 0, + 0, + 259, + 75, + loc * 32 - 32, + 480, + 102, + 32, + Math.PI / 2 + ); // 动画与伤害函数 setTimeout(() => { - core.playSound("arrow.mp3"); - core.deleteCanvas("danger1"); + core.playSound('arrow.mp3'); + core.deleteCanvas('danger1'); // 动画效果 var nloc = 0, speed = 0; - var damaged = {} + var damaged = {}; var skill1 = window.setInterval(() => { speed -= 1; nloc += speed; - if (direction == "horizon") - core.relocateCanvas("inteArrow" + loc + direction, nloc, 0); + if (direction == 'horizon') + core.relocateCanvas( + 'inteArrow' + loc + direction, + nloc, + 0 + ); else - core.relocateCanvas("inteArrow" + loc + direction, 0, nloc); + core.relocateCanvas( + 'inteArrow' + loc + direction, + 0, + nloc + ); if (nloc < -480) { - core.deleteCanvas("inteArrow" + loc + direction); + core.deleteCanvas('inteArrow' + loc + direction); clearInterval(skill1); } // 伤害判定 if (!damaged[loc + direction]) { var x = core.status.hero.loc.x, y = core.status.hero.loc.y; - if (direction == "horizon") { - if (y == loc && Math.floor((480 + nloc) / 32) == x) { + if (direction == 'horizon') { + if ( + y == loc && + Math.floor((480 + nloc) / 32) == x + ) { damaged[loc + direction] = true; - core.drawHeroAnimate("hand"); + core.drawHeroAnimate('hand'); core.status.hero.hp -= 1000; core.popupDamage(1000, x, y, false); core.updateStatusBar(); @@ -4265,9 +5567,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } } } else { - if (x == loc && Math.floor((480 + nloc) / 32) == y) { + if ( + x == loc && + Math.floor((480 + nloc) / 32) == y + ) { damaged[loc + direction] = true; - core.drawHeroAnimate("hand"); + core.drawHeroAnimate('hand'); core.status.hero.hp -= 1000; core.popupDamage(1000, x, y, false); core.updateStatusBar(); @@ -4291,42 +5596,57 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var toX = Math.floor(Math.random() * 13) + 1, toY = Math.floor(Math.random() * 13) + 1; // 在勇士身上绘制动画 - core.drawHeroAnimate("magicAtk"); + core.drawHeroAnimate('magicAtk'); // 在目标位置绘制动画 - if (!core.dymCanvas["door" + toX + "_" + toY]) - core.createCanvas("door" + toX + "_" + toY, 0, 0, 480, 480, 35); - else core.clearMap("door" + toX + "_" + toY); - var style = document.getElementById("door" + toX + "_" + toY).getContext("2d"); + if (!core.dymCanvas['door' + toX + '_' + toY]) + core.createCanvas('door' + toX + '_' + toY, 0, 0, 480, 480, 35); + else core.clearMap('door' + toX + '_' + toY); + var style = document + .getElementById('door' + toX + '_' + toY) + .getContext('2d'); var frame = 0, width = 0, a = 0.0128, speed = 0.64; // 动画 var skill2 = window.setInterval(() => { - frame++ + frame++; if (frame < 40) return; if (frame == 100) { clearInterval(skill2); // 执行传送 - core.insertAction([ - { "type": "changePos", "loc": [toX, toY] }, - ]); + core.insertAction([{ type: 'changePos', loc: [toX, toY] }]); // 删除传送门 setTimeout(() => { - core.deleteCanvas("door" + toX + "_" + toY); + core.deleteCanvas('door' + toX + '_' + toY); }, 2000); return; } width += speed * 2; speed -= a; - core.clearMap("door" + toX + "_" + toY); - style.shadowColor = "rgba(255, 255, 255, 1)"; + core.clearMap('door' + toX + '_' + toY); + style.shadowColor = 'rgba(255, 255, 255, 1)'; style.shadowBlur = 7; - style.filter = "blur(5px)"; - core.fillRect("door" + toX + "_" + toY, toX * 32, toY * 32 - 24, width, 48, [255, 255, 255, 0.7]); - style.shadowColor = "rgba(0, 0, 0, 0.5)"; - style.filter = "blur(3px)"; - core.strokeRect("door" + toX + "_" + toY, toX * 32, toY * 32 - 24, width, 48, [255, 255, 255, 0.7], 3); + style.filter = 'blur(5px)'; + core.fillRect( + 'door' + toX + '_' + toY, + toX * 32, + toY * 32 - 24, + width, + 48, + [255, 255, 255, 0.7] + ); + style.shadowColor = 'rgba(0, 0, 0, 0.5)'; + style.filter = 'blur(3px)'; + core.strokeRect( + 'door' + toX + '_' + toY, + toX * 32, + toY * 32 - 24, + width, + 48, + [255, 255, 255, 0.7], + 3 + ); }, 20); }; // 技能3 万冰之势 全屏随机转换滑冰 如果转换时在滑冰上造成5000点伤害 @@ -4339,14 +5659,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { now = 0; flags.haveIce = true; if (!core.dymCanvas.icyMomentem) - core.createCanvas("icyMomentem", 0, 0, 480, 480, 35); - else core.clearMap("icyMomentem"); + core.createCanvas('icyMomentem', 0, 0, 480, 480, 35); + else core.clearMap('icyMomentem'); var skill3 = window.setInterval(() => { var nx = Math.floor(Math.random() * 13) + 1, ny = Math.floor(Math.random() * 13) + 1; if (!locs.includes([nx, ny])) { locs.push([nx, ny]); - core.fillRect("icyMomentem", locs[now][0] * 32 + 2, locs[now][1] * 32 + 2, 28, 28, [150, 150, 255, 0.6]); + core.fillRect( + 'icyMomentem', + locs[now][0] * 32 + 2, + locs[now][1] * 32 + 2, + 28, + 28, + [150, 150, 255, 0.6] + ); } if (now == times) { clearInterval(skill3); @@ -4355,17 +5682,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { now++; }, 20); // 动画和伤害函数 - function skill3Effect () { + function skill3Effect() { // 防卡 setInterval var index = 0; var effect = window.setInterval(() => { var x = core.status.hero.loc.x, y = core.status.hero.loc.y; - core.clearMap("icyMomentem", locs[index][0] * 32, locs[index][1] * 32, 32, 32); - core.setBgFgBlock("bg", 167, locs[index][0], locs[index][1]); - core.drawAnimate("ice", locs[index][0], locs[index][1]); + core.clearMap( + 'icyMomentem', + locs[index][0] * 32, + locs[index][1] * 32, + 32, + 32 + ); + core.setBgFgBlock( + 'bg', + 167, + locs[index][0], + locs[index][1] + ); + core.drawAnimate('ice', locs[index][0], locs[index][1]); if (x == locs[index][0] && y == locs[index][1]) { - core.drawHeroAnimate("hand"); + core.drawHeroAnimate('hand'); core.status.hero.hp -= 5000; core.popupDamage(5000, x, y, false); core.updateStatusBar(); @@ -4387,15 +5725,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }, 50); } // 删除函数 - function deleteIce (locs) { + function deleteIce(locs) { // 照样 setInterval var index = 0; var deleteIce = window.setInterval(() => { - core.setBgFgBlock("bg", 0, locs[index][0], locs[index][1]); + core.setBgFgBlock('bg', 0, locs[index][0], locs[index][1]); index++; if (index >= locs.length) { clearInterval(deleteIce); - core.deleteCanvas("icyMomentem"); + core.deleteCanvas('icyMomentem'); setTimeout(() => { delete flags.haveIce; }, 5000); @@ -4407,32 +5745,32 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 开始第二阶段 this.startStage2 = function () { // 闪烁 - core.createCanvas("flash", 0, 0, 480, 480, 160); + core.createCanvas('flash', 0, 0, 480, 480, 160); var alpha = 0; var frame = 0; var start1 = window.setInterval(() => { - core.clearMap("flash"); + core.clearMap('flash'); frame++; if (frame <= 8) alpha += 0.125; else alpha -= 0.01; - core.fillRect("flash", 0, 0, 480, 480, [255, 255, 255, alpha]); + core.fillRect('flash', 0, 0, 480, 480, [255, 255, 255, alpha]); if (alpha == 0) { clearInterval(start1); - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); } if (frame == 8) { changeWeather(); } }); // 切换天气 - function changeWeather () { + function changeWeather() { core.setWeather(); - core.setWeather("rain", 10); - core.setWeather("fog", 8); + core.setWeather('rain', 10); + core.setWeather('fog', 8); // 色调也得换 core.setCurtain([0, 0, 0, 0.3]); // bgm - core.playBgm("towerBoss2.mp3"); + core.playBgm('towerBoss2.mp3'); } }; // ----- 打雷相关 ----- // @@ -4443,20 +5781,27 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { power = Math.ceil(Math.random() * 6); // 绘制危险区域 if (!core.dymCanvas.thunderDanger) - core.createCanvas("thunderDanger", 0, 0, 480, 480, 35); - else core.clearMap("thunderDanger"); + core.createCanvas('thunderDanger', 0, 0, 480, 480, 35); + else core.clearMap('thunderDanger'); // 3*3范围 for (var nx = x - 1; nx <= x + 1; nx++) { for (var ny = y - 1; ny <= y + 1; ny++) { - core.fillRect("thunderDanger", nx * 32 + 2, ny * 32 + 2, 28, 28, [255, 255, 255, 0.6]); + core.fillRect( + 'thunderDanger', + nx * 32 + 2, + ny * 32 + 2, + 28, + 28, + [255, 255, 255, 0.6] + ); } } - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); setTimeout(() => { - core.playSound("thunder.mp3"); + core.playSound('thunder.mp3'); }, 500); setTimeout(() => { - core.deleteCanvas("thunderDanger"); + core.deleteCanvas('thunderDanger'); core.drawThunder(x, y, power); }, 1000); }; @@ -4465,18 +5810,26 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var route = core.getThunderRoute(x * 32 + 16, y * 32 + 16, power); // 开始绘制 if (!core.dymCanvas.thunder) - core.createCanvas("thunder", 0, 0, 480, 480, 65); - else core.clearMap("thunder"); + core.createCanvas('thunder', 0, 0, 480, 480, 65); + else core.clearMap('thunder'); var style = core.dymCanvas.thunder; - style.shadowColor = "rgba(220, 220, 255, 1)"; + style.shadowColor = 'rgba(220, 220, 255, 1)'; style.shadowBlur = power; - style.filter = "blur(2.5px)"; + style.filter = 'blur(2.5px)'; for (var num in route) { // 一个个绘制 for (var i = 0; i < route[num].length - 1; i++) { var now = route[num][i], next = route[num][i + 1]; - core.drawLine("thunder", now[0], now[1], next[0], next[1], "#ffffff", 2.5); + core.drawLine( + 'thunder', + now[0], + now[1], + next[0], + next[1], + '#ffffff', + 2.5 + ); } } // 伤害 @@ -4485,19 +5838,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var frame1 = 0, alpha = 0.5; if (!core.dymCanvas.flash) - core.createCanvas("flash", 0, 0, 480, 480, 160); - else core.clearMap("flash"); + core.createCanvas('flash', 0, 0, 480, 480, 160); + else core.clearMap('flash'); var thunderFlash = window.setInterval(() => { alpha -= 0.05; frame1++; - core.clearMap("flash"); - core.fillRect("flash", 0, 0, 480, 480, [255, 255, 255, alpha]); + core.clearMap('flash'); + core.fillRect('flash', 0, 0, 480, 480, [255, 255, 255, alpha]); if (frame1 >= 10) { clearInterval(thunderFlash); - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); // 删除闪电 setTimeout(() => { - core.deleteCanvas("thunder"); + core.deleteCanvas('thunder'); }, 700); } }, 20); @@ -4548,9 +5901,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // setInterval执行 var ballThunder = window.setInterval(() => { // 画布 - if (!core.dymCanvas["ballThunder" + now]) - core.createCanvas("ballThunder" + now, 0, 0, 480, 480, 35); - else core.clearMap("ballThunder" + now); + if (!core.dymCanvas['ballThunder' + now]) + core.createCanvas('ballThunder' + now, 0, 0, 480, 480, 35); + else core.clearMap('ballThunder' + now); var nx = Math.floor(Math.random() * 13) + 1, ny = Math.floor(Math.random() * 13) + 1; // 添加位置 绘制危险区域 @@ -4558,10 +5911,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { locs.push([nx, ny]); // 横竖都要画 for (var mx = 1; mx < 14; mx++) { - core.fillRect("ballThunder" + now, mx * 32 + 2, ny * 32 + 2, 28, 28, [190, 190, 255, 0.6]); + core.fillRect( + 'ballThunder' + now, + mx * 32 + 2, + ny * 32 + 2, + 28, + 28, + [190, 190, 255, 0.6] + ); } for (var my = 1; my < 14; my++) { - core.fillRect("ballThunder" + now, nx * 32 + 2, my * 32 + 2, 28, 28, [190, 190, 255, 0.6]); + core.fillRect( + 'ballThunder' + now, + nx * 32 + 2, + my * 32 + 2, + 28, + 28, + [190, 190, 255, 0.6] + ); } } now++; @@ -4573,56 +5940,118 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } }, 200); // 动画 伤害 - function thunderAnimate (locs) { + function thunderAnimate(locs) { var frame = 0; // 画布 if (!core.dymCanvas.ballAnimate) - core.createCanvas("ballAnimate", 0, 0, 480, 480, 65); - else core.clearMap("ballAnimate"); + core.createCanvas('ballAnimate', 0, 0, 480, 480, 65); + else core.clearMap('ballAnimate'); var style = core.dymCanvas.ballAnimate; - style.shadowColor = "rgba(255, 255, 255, 1)"; + style.shadowColor = 'rgba(255, 255, 255, 1)'; var damaged = []; var animate = window.setInterval(() => { - core.clearMap("ballAnimate"); + core.clearMap('ballAnimate'); for (var i = 0; i < locs.length; i++) { style.shadowBlur = 16 * Math.random(); // 错开执行动画 if (frame - 10 * i > 0) { var now = frame - 10 * i; - if (now == 1) core.playSound("electron.mp3"); + if (now == 1) core.playSound('electron.mp3'); // 动画 var nx = locs[i][0] * 32 + 16, ny = locs[i][1] * 32 + 16; if (now <= 2) { - core.fillCircle("ballAnimate", nx, ny, 16 + 3 * now, [255, 255, 255, 0.9]); + core.fillCircle( + 'ballAnimate', + nx, + ny, + 16 + 3 * now, + [255, 255, 255, 0.9] + ); } else { // 上 - core.fillCircle("ballAnimate", nx, ny - 4 * now, 7 + 2 * Math.random(), [255, 255, 255, 0.7]); + core.fillCircle( + 'ballAnimate', + nx, + ny - 4 * now, + 7 + 2 * Math.random(), + [255, 255, 255, 0.7] + ); // 下 - core.fillCircle("ballAnimate", nx, ny + 4 * now, 7 + 2 * Math.random(), [255, 255, 255, 0.7]); + core.fillCircle( + 'ballAnimate', + nx, + ny + 4 * now, + 7 + 2 * Math.random(), + [255, 255, 255, 0.7] + ); // 左 - core.fillCircle("ballAnimate", nx - 4 * now, ny, 7 + 2 * Math.random(), [255, 255, 255, 0.7]); + core.fillCircle( + 'ballAnimate', + nx - 4 * now, + ny, + 7 + 2 * Math.random(), + [255, 255, 255, 0.7] + ); // 右 - core.fillCircle("ballAnimate", nx + 4 * now, ny, 7 + 2 * Math.random(), [255, 255, 255, 0.7]); + core.fillCircle( + 'ballAnimate', + nx + 4 * now, + ny, + 7 + 2 * Math.random(), + [255, 255, 255, 0.7] + ); } // 清除危险区域 - core.clearMap("ballThunder" + i, nx - 16, ny - 16 - 4 * now, 32, 32); - core.clearMap("ballThunder" + i, nx - 16, ny - 16 + 4 * now, 32, 32); - core.clearMap("ballThunder" + i, nx - 16 - 4 * now, ny - 16, 32, 32); - core.clearMap("ballThunder" + i, nx - 16 + 4 * now, ny - 16, 32, 32); + core.clearMap( + 'ballThunder' + i, + nx - 16, + ny - 16 - 4 * now, + 32, + 32 + ); + core.clearMap( + 'ballThunder' + i, + nx - 16, + ny - 16 + 4 * now, + 32, + 32 + ); + core.clearMap( + 'ballThunder' + i, + nx - 16 - 4 * now, + ny - 16, + 32, + 32 + ); + core.clearMap( + 'ballThunder' + i, + nx - 16 + 4 * now, + ny - 16, + 32, + 32 + ); // 伤害 if (!damaged[i]) { var x = core.status.hero.loc.x, y = core.status.hero.loc.y; - if (((Math.floor((nx - 16 - 4 * now) / 32) == x || - Math.floor((nx - 16 + 4 * now) / 32) == x) && locs[i][1] == y) || - ((Math.floor((ny - 16 - 4 * now) / 32) == y || - Math.floor((ny - 16 + 4 * now) / 32) == y) && locs[i][0] == x)) { - damaged[i] = true + if ( + ((Math.floor((nx - 16 - 4 * now) / 32) == + x || + Math.floor((nx - 16 + 4 * now) / 32) == + x) && + locs[i][1] == y) || + ((Math.floor((ny - 16 - 4 * now) / 32) == + y || + Math.floor((ny - 16 + 4 * now) / 32) == + y) && + locs[i][0] == x) + ) { + damaged[i] = true; core.status.hero.hp -= 3000; core.popupDamage(3000, x, y, false); core.updateStatusBar(); - core.playSound("electron.mp3"); + core.playSound('electron.mp3'); if (core.status.hero.hp < 0) { core.status.hero.hp = 0; core.updateStatusBar(); @@ -4640,145 +6069,286 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } frame++; }, 20); - }; + } }; // ------ 第三阶段 3500~0 ------ // this.startStage3 = function () { // 闪烁 - core.createCanvas("flash", 0, 0, 480, 480, 160); + core.createCanvas('flash', 0, 0, 480, 480, 160); var alpha = 0; var frame = 0; var start1 = window.setInterval(() => { - core.clearMap("flash"); + core.clearMap('flash'); frame++; if (frame <= 8) alpha += 0.125; else alpha -= 0.01; - core.fillRect("flash", 0, 0, 480, 480, [255, 255, 255, alpha]); + core.fillRect('flash', 0, 0, 480, 480, [255, 255, 255, alpha]); if (alpha == 0) { clearInterval(start1); - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); } if (frame == 8) { - core.playSound("thunder.mp3"); + core.playSound('thunder.mp3'); changeTerra(); - core.insertAction([ - { "type": "changePos", "loc": [7, 7] }, - ]); + core.insertAction([{ type: 'changePos', loc: [7, 7] }]); } }); // 改变地形 - function changeTerra () { + function changeTerra() { for (var nx = 0; nx < 15; nx++) { for (var ny = 0; ny < 15; ny++) { if (nx == 0 || nx == 14 || ny == 0 || ny == 14) { core.removeBlock(nx, ny); } - if ((nx == 1 || nx == 13 || ny == 1 || ny == 13) && - nx != 0 && nx != 14 && ny != 0 && ny != 14) { + if ( + (nx == 1 || nx == 13 || ny == 1 || ny == 13) && + nx != 0 && + nx != 14 && + ny != 0 && + ny != 14 + ) { core.setBlock(527, nx, ny); } } } - core.createCanvas("tower7", 0, 0, 480, 480, 15); + core.createCanvas('tower7', 0, 0, 480, 480, 15); // 画贴图 - core.drawImage("tower7", "tower7.jpeg", 360, 0, 32, 480, 0, 0, 32, 480); - core.drawImage("tower7", "tower7.jpeg", 840, 0, 32, 480, 448, 0, 32, 480); - core.drawImage("tower7", "tower7.jpeg", 392, 0, 416, 32, 32, 0, 416, 32); - core.drawImage("tower7", "tower7.jpeg", 392, 448, 416, 32, 32, 448, 416, 32); - core.setBlock("E557", 7, 2); - core.playBgm("towerBoss3.mp3"); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 360, + 0, + 32, + 480, + 0, + 0, + 32, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 840, + 0, + 32, + 480, + 448, + 0, + 32, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 392, + 0, + 416, + 32, + 32, + 0, + 416, + 32 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 392, + 448, + 416, + 32, + 32, + 448, + 416, + 32 + ); + core.setBlock('E557', 7, 2); + core.playBgm('towerBoss3.mp3'); } }; // 进入第四阶段 this.startStage4 = function () { // 闪烁 - core.createCanvas("flash", 0, 0, 480, 480, 160); + core.createCanvas('flash', 0, 0, 480, 480, 160); var alpha = 0; var frame = 0; var start1 = window.setInterval(() => { - core.clearMap("flash"); + core.clearMap('flash'); frame++; if (frame <= 8) alpha += 0.125; else alpha -= 0.01; - core.fillRect("flash", 0, 0, 480, 480, [255, 255, 255, alpha]); + core.fillRect('flash', 0, 0, 480, 480, [255, 255, 255, alpha]); if (alpha == 0) { clearInterval(start1); - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); } if (frame == 8) { - core.playSound("thunder.mp3"); + core.playSound('thunder.mp3'); changeTerra(); - core.insertAction([ - { "type": "changePos", "loc": [7, 7] }, - ]); + core.insertAction([{ type: 'changePos', loc: [7, 7] }]); } }); // 改变地形 - function changeTerra () { + function changeTerra() { for (var nx = 1; nx < 14; nx++) { for (var ny = 1; ny < 14; ny++) { if (nx == 1 || nx == 13 || ny == 1 || ny == 13) { core.removeBlock(nx, ny); } - if ((nx == 2 || nx == 12 || ny == 2 || ny == 12) && - nx != 1 && nx != 13 && ny != 1 && ny != 13) { + if ( + (nx == 2 || nx == 12 || ny == 2 || ny == 12) && + nx != 1 && + nx != 13 && + ny != 1 && + ny != 13 + ) { core.setBlock(527, nx, ny); } } } - core.createCanvas("tower7", 0, 0, 480, 480, 15); + core.createCanvas('tower7', 0, 0, 480, 480, 15); // 画贴图 - core.drawImage("tower7", "tower7.jpeg", 360, 0, 64, 480, 0, 0, 64, 480); - core.drawImage("tower7", "tower7.jpeg", 776, 0, 64, 480, 416, 0, 64, 480); - core.drawImage("tower7", "tower7.jpeg", 424, 0, 352, 64, 64, 0, 352, 64); - core.drawImage("tower7", "tower7.jpeg", 424, 416, 352, 64, 64, 416, 352, 64); - core.setBlock("E557", 7, 3); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 360, + 0, + 64, + 480, + 0, + 0, + 64, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 776, + 0, + 64, + 480, + 416, + 0, + 64, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 424, + 0, + 352, + 64, + 64, + 0, + 352, + 64 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 424, + 416, + 352, + 64, + 64, + 416, + 352, + 64 + ); + core.setBlock('E557', 7, 3); } }; // 进入第五阶段 this.startStage5 = function () { // 闪烁 - core.createCanvas("flash", 0, 0, 480, 480, 160); + core.createCanvas('flash', 0, 0, 480, 480, 160); var alpha = 0; var frame = 0; var start1 = window.setInterval(() => { - core.clearMap("flash"); + core.clearMap('flash'); frame++; if (frame <= 8) alpha += 0.125; else alpha -= 0.01; - core.fillRect("flash", 0, 0, 480, 480, [255, 255, 255, alpha]); + core.fillRect('flash', 0, 0, 480, 480, [255, 255, 255, alpha]); if (alpha == 0) { clearInterval(start1); - core.deleteCanvas("flash"); + core.deleteCanvas('flash'); } if (frame == 8) { - core.playSound("thunder.mp3"); + core.playSound('thunder.mp3'); changeTerra(); - core.insertAction([ - { "type": "changePos", "loc": [7, 7] }, - ]); + core.insertAction([{ type: 'changePos', loc: [7, 7] }]); } }); // 改变地形 - function changeTerra () { + function changeTerra() { for (var nx = 2; nx < 13; nx++) { for (var ny = 2; ny < 13; ny++) { if (nx == 2 || nx == 12 || ny == 2 || ny == 12) { core.removeBlock(nx, ny); } - if ((nx == 3 || nx == 11 || ny == 3 || ny == 11) && - nx != 2 && nx != 12 && ny != 2 && ny != 12) { + if ( + (nx == 3 || nx == 11 || ny == 3 || ny == 11) && + nx != 2 && + nx != 12 && + ny != 2 && + ny != 12 + ) { core.setBlock(527, nx, ny); } } } - core.createCanvas("tower7", 0, 0, 480, 480, 15); + core.createCanvas('tower7', 0, 0, 480, 480, 15); // 画贴图 - core.drawImage("tower7", "tower7.jpeg", 360, 0, 96, 480, 0, 0, 96, 480); - core.drawImage("tower7", "tower7.jpeg", 744, 0, 96, 480, 384, 0, 96, 480); - core.drawImage("tower7", "tower7.jpeg", 456, 0, 288, 96, 96, 0, 288, 96); - core.drawImage("tower7", "tower7.jpeg", 456, 384, 288, 96, 96, 384, 288, 96); - core.setBlock("E557", 7, 4); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 360, + 0, + 96, + 480, + 0, + 0, + 96, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 744, + 0, + 96, + 480, + 384, + 0, + 96, + 480 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 456, + 0, + 288, + 96, + 96, + 0, + 288, + 96 + ); + core.drawImage( + 'tower7', + 'tower7.jpeg', + 456, + 384, + 288, + 96, + 96, + 384, + 288, + 96 + ); + core.setBlock('E557', 7, 4); } }; // 链状闪电 随机连接 碰到勇士则受伤 @@ -4787,8 +6357,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var times = Math.ceil(Math.random() * 6) + 3; // 画布 if (!core.dymCanvas.chainDanger) - core.createCanvas("chainDanger", 0, 0, 480, 480, 35); - else core.clearMap("chainDanger"); + core.createCanvas('chainDanger', 0, 0, 480, 480, 35); + else core.clearMap('chainDanger'); // setInterval执行 var locs = [], now = 0; @@ -4808,14 +6378,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } else return; // 危险线 if (now > 0) { - core.drawLine("chainDanger", locs[now - 1][0] * 32 + 16, locs[now - 1][1] * 32 + 16, - nx * 32 + 16, ny * 32 + 16, [220, 100, 255, 0.6], 3); + core.drawLine( + 'chainDanger', + locs[now - 1][0] * 32 + 16, + locs[now - 1][1] * 32 + 16, + nx * 32 + 16, + ny * 32 + 16, + [220, 100, 255, 0.6], + 3 + ); } if (now >= times) { clearInterval(chain); setTimeout(() => { core.getChainRoute(locs); - core.deleteCanvas("chainDanger"); + core.deleteCanvas('chainDanger'); }, 1000); } now++; @@ -4826,33 +6403,64 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (!route) return core.chainThunder(); // 画布 if (!core.dymCanvas.chain) - core.createCanvas("chain", 0, 0, 480, 480, 65); - else core.clearMap("chain"); + core.createCanvas('chain', 0, 0, 480, 480, 65); + else core.clearMap('chain'); var style = core.dymCanvas.chain; style.shadowBlur = 3; - style.shadowColor = "rgba(255, 255, 255, 1)"; - style.filter = "blur(2px)"; + style.shadowColor = 'rgba(255, 255, 255, 1)'; + style.filter = 'blur(2px)'; // 当然还是setInterval var frame = 0, now = 0; var animate = window.setInterval(() => { if (now >= route.length - 1) { clearInterval(animate); - setTimeout(() => { core.deleteCanvas("chain"); }, 1000); + setTimeout(() => { + core.deleteCanvas('chain'); + }, 1000); return; } frame++; if (frame % 2 != 0) return; - core.drawLine("chain", route[now][0], route[now][1], route[now + 1][0], route[now + 1][1], "#ffffff", 3); + core.drawLine( + 'chain', + route[now][0], + route[now][1], + route[now + 1][0], + route[now + 1][1], + '#ffffff', + 3 + ); // 节点 if (now == 0) { - core.fillCircle("chain", route[0][0], route[0][1], 7, "#ffffff"); + core.fillCircle( + 'chain', + route[0][0], + route[0][1], + 7, + '#ffffff' + ); } - if ((route[now + 1][0] - 16) % 32 == 0 && (route[now + 1][1] - 16) % 32 == 0) { - core.fillCircle("chain", route[now + 1][0], route[now + 1][1], 7, "#ffffff"); + if ( + (route[now + 1][0] - 16) % 32 == 0 && + (route[now + 1][1] - 16) % 32 == 0 + ) { + core.fillCircle( + 'chain', + route[now + 1][0], + route[now + 1][1], + 7, + '#ffffff' + ); } // 判断伤害 - core.lineDamage(route[now][0], route[now][1], route[now + 1][0], route[now + 1][1], 4000); + core.lineDamage( + route[now][0], + route[now][1], + route[now + 1][0], + route[now + 1][1], + 4000 + ); now++; }, 20); }; @@ -4878,7 +6486,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { nx += Math.random() * 50 * Math.cos(angle); ny += Math.random() * 50 * Math.sin(angle); routes.push([nx, ny]); - if (Math.sqrt(Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2)) <= 100) { + if ( + Math.sqrt( + Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2) + ) <= 100 + ) { routes.push([tx, ty]); break; } @@ -4929,15 +6541,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.boomingAnimate = function () { // 直接setInterval if (!core.dymCanvas.boom) - core.createCanvas("boom", 0, 0, 480, 480, 65); - else core.clearMap("boom"); + core.createCanvas('boom', 0, 0, 480, 480, 65); + else core.clearMap('boom'); var boomAnimate = window.setInterval(() => { if (boomLocs.length == 0) return; if (!flags.booming && boomLocs.length == 0) { clearInterval(boomAnimate); return; } - core.clearMap("boom"); + core.clearMap('boom'); boomLocs.forEach((loc, index) => { loc[2]++; var x = loc[0] * 32 + 16, @@ -4949,25 +6561,60 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var radius = 0.12 * Math.pow(20 - loc[2], 2) + 12, alpha = Math.max(1, 2 - loc[2] * 0.1); } - var angle = loc[2] * Math.PI / 50; + var angle = (loc[2] * Math.PI) / 50; // 开始绘制 - core.fillCircle("boom", x, y, 3, [255, 50, 50, alpha]); - core.strokeCircle("boom", x, y, radius, [255, 50, 50, alpha], 2); + core.fillCircle('boom', x, y, 3, [255, 50, 50, alpha]); + core.strokeCircle( + 'boom', + x, + y, + radius, + [255, 50, 50, alpha], + 2 + ); // 旋转的线 - core.drawLine("boom", x + radius * Math.cos(angle), y + radius * Math.sin(angle), - x + (radius + 15) * Math.cos(angle), y + (radius + 15) * Math.sin(angle), [255, 50, 50, alpha], 1); + core.drawLine( + 'boom', + x + radius * Math.cos(angle), + y + radius * Math.sin(angle), + x + (radius + 15) * Math.cos(angle), + y + (radius + 15) * Math.sin(angle), + [255, 50, 50, alpha], + 1 + ); angle += Math.PI; - core.drawLine("boom", x + radius * Math.cos(angle), y + radius * Math.sin(angle), - x + (radius + 15) * Math.cos(angle), y + (radius + 15) * Math.sin(angle), [255, 50, 50, alpha], 1); + core.drawLine( + 'boom', + x + radius * Math.cos(angle), + y + radius * Math.sin(angle), + x + (radius + 15) * Math.cos(angle), + y + (radius + 15) * Math.sin(angle), + [255, 50, 50, alpha], + 1 + ); // 炸弹 下落 if (loc[2] > 70) { - var h = y - (20 * (85 - loc[2]) + 2.8 * Math.pow(85 - loc[2], 2)); - core.drawImage("boom", "boom.png", x - 18, h - 80, 36, 80); + var h = + y - + (20 * (85 - loc[2]) + + 2.8 * Math.pow(85 - loc[2], 2)); + core.drawImage( + 'boom', + 'boom.png', + x - 18, + h - 80, + 36, + 80 + ); } if (loc[2] == 85) { - core.drawAnimate("explosion1", (x - 16) / 32, (y - 16) / 32); + core.drawAnimate( + 'explosion1', + (x - 16) / 32, + (y - 16) / 32 + ); boomLocs.splice(index, 1); - if (boomLocs.length == 0) core.deleteCanvas("boom"); + if (boomLocs.length == 0) core.deleteCanvas('boom'); // 伤害判定 var hx = core.status.hero.loc.x, hy = core.status.hero.loc.y; @@ -4994,8 +6641,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var x = core.status.hero.loc.x, y = core.status.hero.loc.y; // 是否可能碰到勇士 - if ((x1 < x * 32 - 12 && x2 < x * 32 - 12) || (x1 > x * 32 + 12 && x2 > x * 32 + 12) || - (y1 < y * 32 - 16 && y2 < y * 32 - 16) || (y1 > y * 32 + 16 && y2 > y * 32 + 16)) return; + if ( + (x1 < x * 32 - 12 && x2 < x * 32 - 12) || + (x1 > x * 32 + 12 && x2 > x * 32 + 12) || + (y1 < y * 32 - 16 && y2 < y * 32 - 16) || + (y1 > y * 32 + 16 && y2 > y * 32 + 16) + ) + return; // 对角线的端点是否在直线异侧 勇士视为24 * 32 for (var time = 1; time <= 2; time++) { // 左下右上 @@ -5003,13 +6655,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var loc1 = [x * 32 - 12, y * 32 + 16], loc2 = [x * 32 + 12, y * 32 - 16]; // 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1 - var n1 = (y2 - y1) / (x2 - x1) * (loc1[0] - x1) + y1 - loc1[1], - n2 = (y2 - y1) / (x2 - x1) * (loc2[0] - x1) + y1 - loc2[1]; + var n1 = + ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + + y1 - + loc1[1], + n2 = + ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + + y1 - + loc2[1]; if (n1 * n2 <= 0) { core.status.hero.hp -= damage; core.popupDamage(damage, x, y, false); core.updateStatusBar(); - core.playSound("electron.mp3"); + core.playSound('electron.mp3'); if (core.status.hero.hp < 0) { core.status.hero.hp = 0; core.updateStatusBar(); @@ -5018,17 +6676,24 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } return; } - } else { // 左上右下 + } else { + // 左上右下 var loc1 = [x * 32 - 12, y * 32 - 16], loc2 = [x * 32 + 12, y * 32 + 16]; // 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1 - var n1 = (y2 - y1) / (x2 - x1) * (loc1[0] - x1) + y1 - loc1[1], - n2 = (y2 - y1) / (x2 - x1) * (loc2[0] - x1) + y1 - loc2[1]; + var n1 = + ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + + y1 - + loc1[1], + n2 = + ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + + y1 - + loc2[1]; if (n1 * n2 <= 0) { core.status.hero.hp -= damage; core.popupDamage(damage, x, y, false); core.updateStatusBar(); - core.playSound("electron.mp3"); + core.playSound('electron.mp3'); if (core.status.hero.hp < 0) { core.status.hero.hp = 0; core.updateStatusBar(); @@ -5041,13 +6706,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } }; }, - "weatherSuperimpose": function () { + weatherSuperimpose: function () { // 天气叠加功能 ////// 更改天气效果 ////// control.prototype.setWeather = function (type, level) { // 非雨雪 if (type == null) { - Object.keys(core.control.weathers).forEach((one) => { + Object.keys(core.control.weathers).forEach(one => { core.deleteCanvas('weather' + one); }); core.animateFrame.weather.type = []; @@ -5058,64 +6723,86 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } if (!core.animateFrame.weather.level || level == null) core.animateFrame.weather.level = {}; - if (!core.animateFrame.weather.type) core.animateFrame.weather.type = []; + if (!core.animateFrame.weather.type) + core.animateFrame.weather.type = []; level = core.clamp(parseInt(level) || 5, 1, 10); // 当前天气:则忽略 - if (core.animateFrame.weather.type.includes(type) && level == core.animateFrame.weather.level[type]) return; + if ( + core.animateFrame.weather.type.includes(type) && + level == core.animateFrame.weather.level[type] + ) + return; if (core.animateFrame.weather.nodes[type]) return; // 计算当前的宽高 - core.createCanvas('weather' + type, 0, 0, core.__PIXELS__, core.__PIXELS__, 80); + core.createCanvas( + 'weather' + type, + 0, + 0, + core.__PIXELS__, + core.__PIXELS__, + 80 + ); core.animateFrame.weather.type.push(type); core.animateFrame.weather.level[type] = level; this._setWeather_createNodes(type, level); }; control.prototype._setWeather_createNodes = function (type, level) { - var number = level * parseInt(20 * core.bigmap.width * core.bigmap.height / (core.__SIZE__ * core.__SIZE__)); - if (!core.animateFrame.weather.nodes[type]) core.animateFrame.weather.nodes[type] = []; + var number = + level * + parseInt( + (20 * core.bigmap.width * core.bigmap.height) / + (core.__SIZE__ * core.__SIZE__) + ); + if (!core.animateFrame.weather.nodes[type]) + core.animateFrame.weather.nodes[type] = []; switch (type) { case 'rain': for (var a = 0; a < number; a++) { core.animateFrame.weather.nodes.rain.push({ - 'x': Math.random() * core.bigmap.width * 32, - 'y': Math.random() * core.bigmap.height * 32, - 'l': Math.random() * 2.5, - 'xs': -4 + Math.random() * 4 + 2, - 'ys': Math.random() * 10 + 10 - }) + x: Math.random() * core.bigmap.width * 32, + y: Math.random() * core.bigmap.height * 32, + l: Math.random() * 2.5, + xs: -4 + Math.random() * 4 + 2, + ys: Math.random() * 10 + 10 + }); } break; case 'snow': for (var a = 0; a < number; a++) { core.animateFrame.weather.nodes.snow.push({ - 'x': Math.random() * core.bigmap.width * 32, - 'y': Math.random() * core.bigmap.height * 32, - 'r': Math.random() * 5 + 1, - 'd': Math.random() * Math.min(level, 200), - }) + x: Math.random() * core.bigmap.width * 32, + y: Math.random() * core.bigmap.height * 32, + r: Math.random() * 5 + 1, + d: Math.random() * Math.min(level, 200) + }); } break; case 'fog': if (core.animateFrame.weather.fog) { - core.animateFrame.weather.nodes[type] = [{ - 'level': number, - 'x': 0, - 'y': -core.__PIXELS__ / 2, - 'dx': -Math.random() * 1.5, - 'dy': Math.random(), - 'delta': 0.001, - }]; + core.animateFrame.weather.nodes[type] = [ + { + level: number, + x: 0, + y: -core.__PIXELS__ / 2, + dx: -Math.random() * 1.5, + dy: Math.random(), + delta: 0.001 + } + ]; } break; case 'cloud': if (core.animateFrame.weather.cloud) { - core.animateFrame.weather.nodes[type] = [{ - 'level': number, - 'x': 0, - 'y': -core.__PIXELS__ / 2, - 'dx': -Math.random() * 1.5, - 'dy': Math.random(), - 'delta': 0.001, - }]; + core.animateFrame.weather.nodes[type] = [ + { + level: number, + x: 0, + y: -core.__PIXELS__ / 2, + dx: -Math.random() * 1.5, + dy: Math.random(), + delta: 0.001 + } + ]; } break; case 'sun': @@ -5123,19 +6810,33 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 直接绘制 core.clearMap('weather' + type); core.setAlpha('weather' + type, level / 10); - core.drawImage('weather' + type, core.animateFrame.weather.sun, 0, 0, - core.animateFrame.weather.sun.width, core.animateFrame.weather.sun.height, 0, 0, core.__PIXELS__, core.__PIXELS__); + core.drawImage( + 'weather' + type, + core.animateFrame.weather.sun, + 0, + 0, + core.animateFrame.weather.sun.width, + core.animateFrame.weather.sun.height, + 0, + 0, + core.__PIXELS__, + core.__PIXELS__ + ); core.setAlpha('weather' + type, 1); } break; } }; - core.registerAnimationFrame("weather", true, (timestamp) => { + core.registerAnimationFrame('weather', true, timestamp => { var weather = core.animateFrame.weather; if (!weather.type) return; - weather.type.forEach((one) => { - if (timestamp - weather.time[one] <= 30 || !core.dymCanvas["weather" + one]) return; - core.control["_animationFrame_weather_" + one](); + weather.type.forEach(one => { + if ( + timestamp - weather.time[one] <= 30 || + !core.dymCanvas['weather' + one] + ) + return; + core.control['_animationFrame_weather_' + one](); weather.time[one] = timestamp; }); }); @@ -5148,14 +6849,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { ctx.strokeStyle = 'rgba(174,194,224,0.8)'; ctx.lineWidth = 1; ctx.lineCap = 'round'; - core.animateFrame.weather.nodes.rain.forEach((p) => { + core.animateFrame.weather.nodes.rain.forEach(p => { ctx.beginPath(); ctx.moveTo(p.x - ox, p.y - oy); ctx.lineTo(p.x + p.l * p.xs - ox, p.y + p.l * p.ys - oy); ctx.stroke(); p.x += p.xs; p.y += p.ys; - if (p.x > core.bigmap.width * 32 || p.y > core.bigmap.height * 32) { + if ( + p.x > core.bigmap.width * 32 || + p.y > core.bigmap.height * 32 + ) { p.x = Math.random() * core.bigmap.width * 32; p.y = -10; } @@ -5168,27 +6872,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { ox = core.bigmap.offsetX, oy = core.bigmap.offsetY; core.clearMap('weathersnow'); - ctx.fillStyle = "rgba(255, 255, 255, 0.8)"; + ctx.fillStyle = 'rgba(255, 255, 255, 0.8)'; ctx.beginPath(); - if (!core.animateFrame.weather.data) core.animateFrame.weather.data = {}; - core.animateFrame.weather.data.snow = core.animateFrame.weather.data.snow || 0; + if (!core.animateFrame.weather.data) + core.animateFrame.weather.data = {}; + core.animateFrame.weather.data.snow = + core.animateFrame.weather.data.snow || 0; core.animateFrame.weather.data.snow += 0.01; var angle = core.animateFrame.weather.data.snow; - core.animateFrame.weather.nodes.snow.forEach((p) => { + core.animateFrame.weather.nodes.snow.forEach(p => { ctx.moveTo(p.x - ox, p.y - oy); ctx.arc(p.x - ox, p.y - oy, p.r, 0, Math.PI * 2, true); // update p.x += Math.sin(angle) * core.animateFrame.weather.level.snow; p.y += Math.cos(angle + p.d) + 1 + p.r / 2; - if (p.x > core.bigmap.width * 32 + 5 || p.x < -5 || p.y > core.bigmap.height * 32) { + if ( + p.x > core.bigmap.width * 32 + 5 || + p.x < -5 || + p.y > core.bigmap.height * 32 + ) { if (Math.random() > 1 / 3) { p.x = Math.random() * core.bigmap.width * 32; p.y = -10; } else { - if (Math.sin(angle) > 0) - p.x = -5; - else - p.x = core.bigmap.width * 32 + 5; + if (Math.sin(angle) > 0) p.x = -5; + else p.x = core.bigmap.width * 32 + 5; p.y = Math.random() * core.bigmap.height * 32; } } @@ -5196,7 +6904,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { ctx.fill(); }; // 图片天气 - control.prototype.__animateFrame_weather_image = function (image, type) { + control.prototype.__animateFrame_weather_image = function ( + image, + type + ) { if (!image) return; var node = core.animateFrame.weather.nodes[type][0]; core.setAlpha('weather' + type, node.level / 500); @@ -5223,10 +6934,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } for (var i = 0; i < 3; ++i) { for (var j = 0; j < 3; ++j) { - if (node.x + (i + 1) * width <= 0 || node.x + i * width >= core.__PIXELS__ || - node.y + (j + 1) * height <= 0 || node.y + j * height >= core.__PIXELS__) + if ( + node.x + (i + 1) * width <= 0 || + node.x + i * width >= core.__PIXELS__ || + node.y + (j + 1) * height <= 0 || + node.y + j * height >= core.__PIXELS__ + ) continue; - core.drawImage('weather' + type, image, node.x + i * width, node.y + j * height); + core.drawImage( + 'weather' + type, + image, + node.x + i * width, + node.y + j * height + ); } } core.setAlpha('weather' + type, 1); @@ -5234,28 +6954,37 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 雾 control.prototype._animationFrame_weather_fog = function () { core.clearMap('weatherfog'); - this.__animateFrame_weather_image(core.animateFrame.weather.fog, 'fog'); + this.__animateFrame_weather_image( + core.animateFrame.weather.fog, + 'fog' + ); }; // 云 control.prototype._animationFrame_weather_cloud = function () { core.clearMap('weathercloud'); - this.__animateFrame_weather_image(core.animateFrame.weather.cloud, 'cloud'); - } + this.__animateFrame_weather_image( + core.animateFrame.weather.cloud, + 'cloud' + ); + }; }, - "popupDamage": function () { + popupDamage: function () { // 伤害弹出 // 复写阻激夹域检测 control.prototype.checkBlock = function () { var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), - loc = x + "," + y; + loc = x + ',' + y; var damage = core.status.checkBlock.damage[loc]; if (damage) { core.addPop(x * 32 + 12, y * 32 + 20, damage, '#f00', '#000'); core.status.hero.hp -= damage; - var text = (Object.keys(core.status.checkBlock.type[loc] || {}).join(",")) || "伤害"; - core.drawTip("受到" + text + damage + "点"); - core.drawHeroAnimate("zone"); + var text = + Object.keys(core.status.checkBlock.type[loc] || {}).join( + ',' + ) || '伤害'; + core.drawTip('受到' + text + damage + '点'); + core.drawHeroAnimate('zone'); this._checkBlock_disableQuickShop(); core.status.hero.statistics.extraDamage += damage; if (core.status.hero.hp <= 0) { @@ -5270,368 +6999,26 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this._checkBlock_ambush(core.status.checkBlock.ambush[loc]); this._checkBlock_repulse(core.status.checkBlock.repulse[loc]); }; - - /** 血量弹出 */ - function pop () { - var ctx = core.getContextByName('pop'); - if (!ctx) ctx = core.createCanvas('pop', 0, 0, 416, 416, 90); - core.clearMap(ctx); - var list = core.status.pop || []; - var count = 0; - list.forEach((one) => { - // 由frame计算出dy - var dy = 6 - one.frame * 0.2; - var dx = 1; - one.py -= dy; - one.px += dx; - one.frame++; - // 绘制 - if (one.frame >= 60) core.setAlpha(ctx, 3 - one.frame / 30); - else core.setAlpha(ctx, 1); - core.fillBoldText(ctx, one.value, one.px, one.py, one.color || 'red', one.boldColor || 'black', '20px normal'); - if (one.frame >= 90) count++; - }); - if (count > 0) list.splice(0, count); - } - if (!main.replayChecking) core.registerAnimationFrame('pop', true, pop); - - /** 添加弹出内容 */ - this.addPop = function (px, py, value, color, boldColor) { - var data = { px: px, py: py, value: value, color: color, boldColor: boldColor, frame: 0 }; - if (!core.status.pop) core.status.pop = [data]; - else core.status.pop.push(data); - } }, - "bgms": function () { - // bgm查看界面 - ////// 播放背景音乐 ////// - control.prototype.playBgm = function (bgm, startTime) { - core.listenBgm(bgm); - bgm = core.getMappedName(bgm); - if (main.mode != 'play' || !core.material.bgms[bgm]) return; - // 如果不允许播放 - if (!core.musicStatus.bgmStatus) { - try { - core.musicStatus.playingBgm = bgm; - core.musicStatus.lastBgm = bgm; - core.material.bgms[bgm].pause(); - } catch (e) { - main.log(e); - } - return; - } - this.setMusicBtn(); - try { - this._playBgm_play(bgm, startTime); - } catch (e) { - console.log("无法播放BGM " + bgm); - main.log(e); - core.musicStatus.playingBgm = null; - } - }; - // 索引 名称 中文名 是否听过 - var bgms = [ - [0, "title.mp3", "标题界面", true], - [1, "cave.mp3", "山洞", false], - [2, "grass.mp3", "草原", false], - [3, "mount.mp3", "山路", false], - [4, "escape.mp3", "逃脱", false], - [5, "plot1.mp3", "勇气之路", false], - [6, "tower.mp3", "智慧之塔", false], - [7, "beforeBoss.mp3", "战前独白", false], - [8, "towerBoss.mp3", "Boss战一", false], - [9, "towerBoss2.mp3", "Boss战二", false], - [10, "towerBoss3.mp3", "Boss战三", false], - ]; - var selector = 0; // 光标 - // 获得听歌信息 - this.getListenedBgm = function () { - var listened = core.getLocalStorage("listening", []); - listened.forEach((bgm, index) => { - if (bgm) { - bgms[index][3] = true; - } else { - bgms[index][3] = false; - } - }); - return bgms; - }; - // 听bgm - this.listenBgm = function (bgm) { - for (var i in bgms) { - if (bgms[i][1] == bgm) { - var listened = core.getLocalStorage("listening", []); - listened[i] = true; - core.setLocalStorage("listening", listened); - return; - } - } - }; - // 获得每一项bgm的文字描述 - this.getBgmContent = function (index) { - switch (index) { - case 0: - return ["川井憲次 —— 破裂足音", "出自 永远的七日之都", - "人类不断地超越自己,突破极限", - "他们无穷的智慧推动着社会的发展和科技的进步", - "而这一次,我们要上演的是 人类:开天辟地" - ]; - case 1: - return ["Faodial —— Wren", - "为躲避危险,人们进入了山洞,便成就了今日我们的主角 —— 山顶洞人", - "作为初始山洞的bgm,该bgm既有略微紧张的氛围,也有山顶洞人踏出山洞的勇气" - ]; - case 2: - return ["李伟伟 —— 大树与鹿", - "草原嘛,就要欢快一点,这个bgm完美地表现出了草原的自然情景", - "而作为人类踏出山洞的第一步,这个bgm也展示出了人们的踏出山洞的积极" - ]; - case 3: - return ["Epistra —— Dream Of A Dream", - "三段完全重复的旋律,演绎出了人们在挫折中一次次跌倒,又一次次爬起的坚强的毅力,他们绝对不会失败,因为,他们有探索未知的勇气" - ]; - case 4: - return ["Gareth Coker —— Escaping a Foul Presence", "出自 Ori and the Will of the Wisps (奥日与萤火意志)", - "作为奥日2里面的“横向银之树”追逐战,这个bgm充分展示了对方的强大和自身的弱小,放在这里也再合适不过" - ]; - case 5: - return ["英雄联盟等 —— Rags To Rings", "出自 英雄联盟全球总决赛BP音乐", - "作为总决赛的BP音乐,该音乐绝佳地体现出了选手禁用/选择英雄时的紧张与勇气,而用在这里,充分地体现出了人们探索未知的勇气" - ]; - case 6: - return ["Falcom Sound Team jdk —— A Light Illuminating The Depths", "出自 英雄传说:零之轨迹", - "一个紧张刺激的音乐,作为boss战前一个区域的bgm,可以极大程度地激励玩家的斗志,也体现出了将要面对的敌人的强大" - ]; - case 7: - return ["Evan LE NY —— Some Calm", "出自 SpaceChem (太空化学)", - "作为战前boss的独白bgm,充分体现出了未来的人们的穷奢极恶造成的结局的悲惨,同时又展现出智慧之神忠于责任,改变历史的决心" - ]; - case 8: - return ["Evan LE NY —— Opening", "出自 SpaceChem (太空化学)", - "boss战第一阶段,战斗还不是很激烈,用这个不太振奋,同时又能展现出boss的强大的bgm,再合适不过" - ]; - case 9: - return ["Laura Shigihara —— Brainiac Maniac", "出自 Plants Vs Zombies (植物大战僵尸)", - "植物大战僵尸的僵王bgm,作为boss战的第二阶段,充分体现出了智慧之神改变历史的决心" - ]; - case 10: - return ["Epic Score —— MechaDragon", - "智慧,可以抵御恐惧,可以引向光明,智慧之神为改变历史付出一切,借助科技之力磨练人才,为拯救人类做出历史性贡献,更为人类开天辟地画上绝佳一笔" - ]; - } - }; - // 绘制 - this.drawBgms = function () { - this.getListenedBgm(); - if (!core.dymCanvas.bgms) - core.createCanvas("bgms", 0, 0, 480, 480, 150); - else core.clearMap("bgms"); - core.playBgm(bgms[selector][1]); - var style = core.dymCanvas.bgms; - style.shadowBlur = 0; - // 背景 - core.fillRect("bgms", 0, 0, 480, 480, [0, 0, 0, 0.9]); - core.drawLine("bgms", 128, 0, 128, 480, "#ffffff", 1); - core.drawLine("bgms", 128, 458, 480, 458, "#ffffff", 1); - core.drawLine("bgms", 0, 420, 128, 420, "#ffffff", 1); - core.drawLine("bgms", 0, 450, 128, 450, "#ffffff", 1); - // 绘制bgm - core.setTextAlign("bgms", "center"); - style.shadowColor = "rgba(200, 200, 50, 1)"; - style.shadowBlur = 5; - var text; - bgms.forEach((bgm, index) => { - if (!bgm[3]) text = "?????"; - else text = bgm[2]; - // 绘制 - core.fillText("bgms", text, 64, 32 * index + 28, "#ffffff", "24px normal"); - }); - // 绘制光标 - core.drawUIEventSelector(1, "winskin.png", 0, 32 * selector + 4, 128, 30, 160); - // 绘制说明文字 - core.fillText("bgms", bgms[selector][2], 304, 32, "#ffffff", "28px normal"); - core.fillText("bgms", "点击右侧任意位置退出", 304, 475, "#ffffff", "18px normal"); - core.fillText("bgms", "设为BGM", 64, 444, "#ffffff", "24px normal"); - core.fillText("bgms", "还原BGM", 64, 474, "#ffffff", "24px normal"); - style.shadowBlur = 2; - var content = this.getBgmContent(selector).join("\n"); - core.drawTextContent("bgms", content, { top: 350, left: 132, maxWidth: 344, fontSize: 16, align: "center" }); - // 图片 - style.shadowColor = "rgba(255, 255, 255, 1)"; - style.shadowBlur = 10; - core.drawImage("bgms", bgms[selector][1].split(".")[0] + ".jpg", 138, 42, 332, 305); - }; - // 键盘操作 - this.keyBoardBgms = function (keycode, loop, origin) { - if (!origin) origin = selector; - loop = loop || false; - switch (keycode) { - case 40: - if (loop && selector == bgms.length - 1) { - selector = origin; - return; - } - if (selector < bgms.length - 1) { - selector++; - if (!bgms[selector][3]) return this.keyBoardBgms(keycode, true, origin); - core.playSound("光标移动"); - } - return; - case 38: - if (loop && selector == bgms.length - 1) { - selector = origin; - return; - } - if (selector > 0) { - selector--; - if (!bgms[selector][3]) return this.keyBoardBgms(keycode, true, origin); - core.playSound("光标移动"); - } - return; - } - core.playSound("取消"); - core.insertAction({ "type": "break" }); - return; - }; - // 点击操作 - this.clickBgms = function (px, py) { - if (px >= 128) { - core.playSound("取消"); - core.insertAction({ "type": "break" }); - return; - } - if (py > 420 && py <= 450) { - core.playSound("光标移动"); - core.drawTip("成功设置为默认bgm,还原后将会恢复地图bgm"); - flags.__bgm__ = bgms[selector][1]; - return; - } - if (py > 450) { - core.playSound("光标移动"); - core.drawTip("成功恢复地图bgm"); - delete flags.__bgm__; - return; - } - // 获得点击索引 - if (py <= 420) { - if (bgms[Math.floor(py / 32)] && bgms[Math.floor(py / 32)][3]) { - selector = Math.floor(py / 32); - core.playSound("光标移动"); - } - return; - } - }; - // 操作 - this.actionInBgms = function () { - if (flags.type == 0) return this.keyBoardBgms(flags.keycode); - else return this.clickBgms(flags.px, flags.py); - }; - // 开启 - this.openBgms = function () { - // 插入事件 - core.playSound("打开界面"); - core.insertAction([{ - "type": "while", - "condition": "true", - "data": [ - { "type": "function", "function": "() => { core.plugin.drawBgms(); }" }, - { "type": "wait" }, - { "type": "function", "function": "() => { core.plugin.actionInBgms(); }" } - ] - }, - { - "type": "function", - "function": "() => { core.playBgm(flags.__bgm__ || core.status.maps[core.status.floorId].bgm || '');core.deleteCanvas('bgms');core.ui.clearUIEventSelector();}" - } - ]); - }; - }, - "drawSkills": function () { - // 技能查看界面 0索引 1名称 2快捷键 3拥有情况 4简介 - var skills = [ - [0, "断灭之刃", "1", false, "开启后会在战斗时会额外增加一定量的攻击, 但同时减少一定量的防御,具体属性请在技能树界面查看"], - [1, "跳跃", "2", false, "消耗200点生命值,困难消耗400点,每个地图最多使用3次\n1.人物前方一格是怪物,那么将怪物踢至面前第一个不能通行的图块后\n2.前方是不可通行的图块,那么将会跳至面前第一个可以通行的图块\n3.跳跃时物品视为不可通行,但使用技能时不能对着物品使用"] - ]; - // 获得拥有的技能 - this.getHadSkills = function () { - skills[0][3] = flags.bladeOn || false; - skills[1][3] = flags.skill2 || false; - }; - // 绘制 - this.drawSkills = function () { - this.getHadSkills(); - if (!core.dymCanvas.skills) - core.createCanvas("skills", 0, 0, 480, 480, 150); - else core.clearMap("skills"); - var style = core.dymCanvas.skills; - style.shadowBlur = 0; - // 分栏绘制 - core.fillRect("skills", 0, 0, 480, 480, [0, 0, 0, 0.9]); - core.drawLine("skills", 0, 80, 480, 80, "#ffffff", 1); - core.drawLine("skills", 0, 260, 480, 260, "#ffffff", 1); - core.drawLine("skills", 80, 0, 80, 480, [255, 255, 255, 0.5], 1); - core.drawLine("skills", 400, 0, 400, 480, [255, 255, 255, 0.5], 1); - // 绘制技能 - style.shadowColor = "rgba(200, 200, 50, 1)"; - core.setTextAlign("skills", "center"); - style.shadowBlur = 5; - if (skills[0][3]) - core.fillText("skills", skills[0][1], 40, 50, "#ffffff", "20px normal"); - if (skills[1][3]) - core.fillText("skills", skills[1][1], 40, 180, "#ffffff", "20px normal"); - if (skills[0][3]) - core.fillText("skills", "快捷键" + skills[0][2], 440, 50, "#ffffff", "20px normal"); - if (skills[1][3]) - core.fillText("skills", "快捷键" + skills[1][2], 440, 180, "#ffffff", "20px normal"); - style.shadowBlur = 2; - if (skills[0][3]) - core.drawTextContent("skills", skills[0][4], { left: 90, maxWidth: 300, fontSize: 16, top: 10 }); - if (skills[1][3]) - core.drawTextContent("skills", skills[1][4], { left: 90, maxWidth: 300, fontSize: 16, top: 90 }); - }; - // 操作 都是直接退出 - this.actionInSkills = function () { - core.insertAction({ "type": "break" }); - }; - // 开启 - this.openSkills = function () { - // 插入事件 - core.playSound("打开界面"); - core.insertAction([{ - "type": "while", - "condition": "true", - "data": [ - { "type": "function", "function": "() => { core.plugin.drawSkills(); }" }, - { "type": "wait" }, - { "type": "function", "function": "() => { core.plugin.actionInSkills(); }" } - ] - }, - { - "type": "function", - "function": "() => { core.deleteCanvas('skills');}" - } - ]); - }; - }, - "equipBox": function () { + equipBox: function () { // 注:///// *** 裹起来的区域: 该区域内参数可以随意更改调整ui绘制 不会影响总体布局 // 请尽量修改该区域而不是其他区域 修改的时候最好可以对照现有ui修改 ///// *** 道具类型 // cls对应name var itemClsName = { - "constants": "永久道具", - "tools": "消耗道具", - } + constants: '永久道具', + tools: '消耗道具' + }; // 一页最大放的道具数量 将把整个道具左栏分成num份 每份是一个道具项 var itemNum = 12; ///// *** // 背景设置 this.drawBoxBackground = function (ctx) { - core.setTextAlign(ctx, "left"); + core.setTextAlign(ctx, 'left'); core.clearMap(ctx); - core.deleteCanvas("_selector"); + core.deleteCanvas('_selector'); var info = core.status.thisUIEventInfo || {}; ///// *** 背景设置 @@ -5642,8 +7029,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { h = w; var borderWidth = 2, borderRadius = 5, // radius:圆角矩形的圆角半径 - borderStyle = "#fff"; - var backgroundColor = "gray"; + borderStyle = '#fff'; + var backgroundColor = 'gray'; // 设置背景不透明度(0.85) var backgroundAlpha = 0.85; ///// *** @@ -5657,8 +7044,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 有关渐变色的具体知识请网上搜索canvas createGradient了解 var grd = ctx.createLinearGradient(x, y, x + w, y); - grd.addColorStop(0, "#555555"); - grd.addColorStop(1, "#cccccc"); + grd.addColorStop(0, '#555555'); + grd.addColorStop(1, '#cccccc'); backgroundColor = grd; // 使用图片背景要注释掉下面的strokeRect和fillRoundRect @@ -5668,8 +7055,25 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.strokeRect(ctx, x, y, w, h, borderStyle, borderWidth); */ core.setAlpha(ctx, backgroundAlpha); - core.strokeRoundRect(ctx, x, y, w, h, borderRadius, borderStyle, borderWidth); - core.fillRoundRect(ctx, start_x, start_y, width, height, borderRadius, backgroundColor); + core.strokeRoundRect( + ctx, + x, + y, + w, + h, + borderRadius, + borderStyle, + borderWidth + ); + core.fillRoundRect( + ctx, + start_x, + start_y, + width, + height, + borderRadius, + backgroundColor + ); core.setAlpha(ctx, 1); ///// *** 左栏配置 @@ -5685,13 +7089,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var leftbar_y = start_y; ///// *** 道具栏配置 - var boxName_color = "#fff"; + var boxName_color = '#fff'; var boxName_fontSize = 15; var boxName_font = core.ui._buildFont(boxName_fontSize, true); var arrow_x = 10 + start_x; var arrow_y = 10 + start_y; var arrow_width = 20; - var arrow_style = "white"; + var arrow_style = 'white'; // 暂时只能是1 否则不太行 等待新样板(2.7.3)之后对drawArrow做优化 var arrow_lineWidth = 1; // 右箭头 @@ -5701,18 +7105,44 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { ///// *** var itembar_right = rightArrow_right; - var boxName = core.status.event.id == "toolbox" ? "\r[yellow]道具栏\r | 装备栏" : "道具栏 | \r[yellow]装备栏\r"; - core.drawArrow(ctx, arrow_x + arrow_width, arrow_y, arrow_x, arrow_y, arrow_style, arrow_lineWidth); - core.drawArrow(ctx, rightArrow_right - arrow_width, arrow_y, rightArrow_right, arrow_y, arrow_style, arrow_lineWidth); - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "middle"); + var boxName = + core.status.event.id == 'toolbox' + ? '\r[yellow]道具栏\r | 装备栏' + : '道具栏 | \r[yellow]装备栏\r'; + core.drawArrow( + ctx, + arrow_x + arrow_width, + arrow_y, + arrow_x, + arrow_y, + arrow_style, + arrow_lineWidth + ); + core.drawArrow( + ctx, + rightArrow_right - arrow_width, + arrow_y, + rightArrow_right, + arrow_y, + arrow_style, + arrow_lineWidth + ); + core.setTextAlign(ctx, 'center'); + core.setTextBaseline(ctx, 'middle'); var changeBox = () => { var id = core.status.event.id; core.closePanel(); - if (id == "toolbox") core.openEquipbox(); + if (id == 'toolbox') core.openEquipbox(); else core.openToolbox(); - } - core.fillText(ctx, boxName, (leftbar_right + leftbar_x) / 2, arrow_y + 2, boxName_color, boxName_font); + }; + core.fillText( + ctx, + boxName, + (leftbar_right + leftbar_x) / 2, + arrow_y + 2, + boxName_color, + boxName_font + ); ///// *** 底栏按钮 var pageBtn_radius = 8; @@ -5721,27 +7151,54 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var pageBtn_right = leftbar_right - 3; // xxx_bottom 最底部坐标 var pageBtn_bottom = leftbar_bottom - 2; - var pageBtn_borderStyle = "#fff"; + var pageBtn_borderStyle = '#fff'; var pageBtn_borderWidth = 2; - var pageText_color = "#fff"; + var pageText_color = '#fff'; // 底部按钮与上面的道具内栏的间隔大小 var bottomSpace = 8; ///// *** - core.drawItemListbox_setPageBtn(ctx, pageBtn_left, pageBtn_right, pageBtn_bottom, pageBtn_radius, pageBtn_borderStyle, pageBtn_borderWidth); + core.drawItemListbox_setPageBtn( + ctx, + pageBtn_left, + pageBtn_right, + pageBtn_bottom, + pageBtn_radius, + pageBtn_borderStyle, + pageBtn_borderWidth + ); var page = info.page || 1; var pageFontSize = pageBtn_radius * 2 - 4; var pageFont = core.ui._buildFont(pageFontSize); core.setPageItems(page); var num = itemNum; - if (core.status.event.id == "equipbox") num -= 5; + if (core.status.event.id == 'equipbox') num -= 5; var maxPage = info.maxPage; - var pageText = page + " / " + maxPage; - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "bottom"); - core.fillText(ctx, pageText, (leftbar_x + leftbar_right) / 2, pageBtn_bottom, pageText_color, pageFont); - core.addUIEventListener(start_x, start_y, leftbar_right - start_x, arrow_y - start_y + 13, changeBox); - var itembar_height = Math.ceil(pageBtn_bottom - pageBtn_radius * 2 - pageBtn_borderWidth / 2 - bottomSpace - itembar_top); + var pageText = page + ' / ' + maxPage; + core.setTextAlign(ctx, 'center'); + core.setTextBaseline(ctx, 'bottom'); + core.fillText( + ctx, + pageText, + (leftbar_x + leftbar_right) / 2, + pageBtn_bottom, + pageText_color, + pageFont + ); + core.addUIEventListener( + start_x, + start_y, + leftbar_right - start_x, + arrow_y - start_y + 13, + changeBox + ); + var itembar_height = Math.ceil( + pageBtn_bottom - + pageBtn_radius * 2 - + pageBtn_borderWidth / 2 - + bottomSpace - + itembar_top + ); var oneItemHeight = (itembar_height - 4) / itemNum; return { x: start_x, @@ -5756,8 +7213,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { height: itembar_height, oneItemHeight: oneItemHeight } - } - } + }; + }; this.drawItemListbox = function (ctx, obj) { ctx = ctx || core.canvas.ui; @@ -5775,7 +7232,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { select = info.select || {}; ///// *** 道具栏内栏配置 - var itembar_style = "black"; + var itembar_style = 'black'; var itembar_alpha = 0.7; // 一个竖屏下减少道具显示的例子: // if (core.domStyle.isVertical) itemNum = 10; @@ -5786,28 +7243,52 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var item_x = itembar_x + 2, item_y = itembar_y + 2, item_right = itembar_right - 2, - itemName_color = "#fff"; + itemName_color = '#fff'; // 修改此项以更换闪烁光标 - var item_selector = "winskin.png"; + var item_selector = 'winskin.png'; ///// *** core.setAlpha(ctx, itembar_alpha); - core.fillRect(ctx, itembar_x, itembar_y, itembar_width, itembar_height, itembar_style); + core.fillRect( + ctx, + itembar_x, + itembar_y, + itembar_width, + itembar_height, + itembar_style + ); core.setAlpha(ctx, 1); var pageItems = core.setPageItems(page); var marginHeight = itembar_marginHeightRatio * oneItemHeight; - core.setTextBaseline(ctx, "middle"); + core.setTextBaseline(ctx, 'middle'); var originColor = itemName_color; for (var i = 0; i < pageItems.length; i++) { itemName_color = originColor; var item = pageItems[i]; // 设置某个的字体颜色的一个例子 // if (item.id == "xxx") itemName_color = "green"; - core.drawItemListbox_drawItem(ctx, item_x, item_right, item_y, oneItemHeight, item_marginLeft, marginHeight, itemName_color, pageItems[i]); - if (index == i + 1) core.ui._drawWindowSelector(item_selector, item_x + 1, item_y - 1, item_right - item_x - 2, oneItemHeight - 2); + core.drawItemListbox_drawItem( + ctx, + item_x, + item_right, + item_y, + oneItemHeight, + item_marginLeft, + marginHeight, + itemName_color, + pageItems[i] + ); + if (index == i + 1) + core.ui._drawWindowSelector( + item_selector, + item_x + 1, + item_y - 1, + item_right - item_x - 2, + oneItemHeight - 2 + ); item_y += oneItemHeight; } - } + }; this.drawToolboxRightbar = function (ctx, obj) { ctx = ctx || core.canvas.ui; @@ -5822,17 +7303,25 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var toolboxRight = start_x + width, toolboxBottom = start_y + height; - ///// *** 侧边栏(rightbar)背景设置(物品介绍) var rightbar_width = width * 0.4; var rightbar_height = height; var rightbar_lineWidth = 2; - var rightbar_lineStyle = "#fff"; + var rightbar_lineStyle = '#fff'; ///// *** - var rightbar_x = toolboxRight - rightbar_width - rightbar_lineWidth / 2; + var rightbar_x = + toolboxRight - rightbar_width - rightbar_lineWidth / 2; var rightbar_y = start_y; - core.drawLine(ctx, rightbar_x, rightbar_y, rightbar_x, rightbar_y + rightbar_height, rightbar_lineStyle, rightbar_lineWidth); + core.drawLine( + ctx, + rightbar_x, + rightbar_y, + rightbar_x, + rightbar_y + rightbar_height, + rightbar_lineStyle, + rightbar_lineWidth + ); // 获取道具id(有可能为null) var itemId = select.id; @@ -5847,7 +7336,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var iconRect_radius = 2, iconRect_width = 32, iconRect_height = 32, - iconRect_style = "#fff", + iconRect_style = '#fff', iconRect_lineWidth = 2; ///// *** @@ -5860,32 +7349,33 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { itemText_y = Math.floor(start_y + rightbar_height * 0.25), // 坐标取整防止模糊 itemClsFontSize = 15, itemClsFont = core.ui._buildFont(itemClsFontSize), - itemClsColor = "#fff", + itemClsColor = '#fff', itemCls_x = itemText_x - itemClsFontSize / 2, itemCls_middle = (iconRect_bottom + itemText_y) / 2, //_middle代表文字的中心y坐标 itemNameFontSize = 18, - itemNameColor = "#fff", + itemNameColor = '#fff', itemNameFont = core.ui._buildFont(itemNameFontSize, true); var itemName_x = iconRect_right + space; - var itemName_middle = iconRect_y + iconRect_height / 2 + iconRect_lineWidth; + var itemName_middle = + iconRect_y + iconRect_height / 2 + iconRect_lineWidth; // 修改这里可以编辑未选中道具时的默认值 var defaultItem = { - cls: "constants", - name: "未知道具", - text: "没有道具最永久" - } + cls: 'constants', + name: '未知道具', + text: '没有道具最永久' + }; var defaultEquip = { - cls: "equips", - name: "未知装备", - text: "一无所有,又何尝不是一种装备", + cls: 'equips', + name: '未知装备', + text: '一无所有,又何尝不是一种装备', equip: { - type: "装备" + type: '装备' } - } + }; ///// *** var originItem = item; - if (core.status.event.id == "equipbox") item = item || defaultEquip; + if (core.status.event.id == 'equipbox') item = item || defaultEquip; item = item || defaultItem; var itemCls = item.cls, itemName = item.name, @@ -5894,32 +7384,84 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { * if (item.id == "xxx") itemNameColor = "red"; */ var itemClsName = core.getItemClsName(item); - var itemNameMaxWidth = rightbar_width - iconRect_width - iconRect_lineWidth * 2 - space * 2; - core.strokeRoundRect(ctx, iconRect_x, iconRect_y, iconRect_width, iconRect_height, iconRect_radius, iconRect_style, iconRect_lineWidth); + var itemNameMaxWidth = + rightbar_width - + iconRect_width - + iconRect_lineWidth * 2 - + space * 2; + core.strokeRoundRect( + ctx, + iconRect_x, + iconRect_y, + iconRect_width, + iconRect_height, + iconRect_radius, + iconRect_style, + iconRect_lineWidth + ); if (item.id) - core.drawIcon(ctx, item.id, iconRect_x + iconRect_lineWidth / 2, iconRect_y + iconRect_lineWidth / 2, iconRect_width - iconRect_lineWidth, iconRect_height - iconRect_lineWidth); - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "middle"); - core.fillText(ctx, itemName, itemName_x, itemName_middle, itemNameColor, itemNameFont, itemNameMaxWidth); - core.fillText(ctx, "【" + itemClsName + "】", itemCls_x, itemCls_middle, itemClsColor, itemClsFont); - var statusText = ""; - if (core.status.event.id == "equipbox") { + core.drawIcon( + ctx, + item.id, + iconRect_x + iconRect_lineWidth / 2, + iconRect_y + iconRect_lineWidth / 2, + iconRect_width - iconRect_lineWidth, + iconRect_height - iconRect_lineWidth + ); + core.setTextAlign(ctx, 'left'); + core.setTextBaseline(ctx, 'middle'); + core.fillText( + ctx, + itemName, + itemName_x, + itemName_middle, + itemNameColor, + itemNameFont, + itemNameMaxWidth + ); + core.fillText( + ctx, + '【' + itemClsName + '】', + itemCls_x, + itemCls_middle, + itemClsColor, + itemClsFont + ); + var statusText = ''; + if (core.status.event.id == 'equipbox') { var type = item.equip.type; - if (typeof type == "string") type = core.getEquipTypeByName(type); - var compare = core.compareEquipment(item.id, core.getEquip(type)); - if (info.select.action == "unload") compare = core.compareEquipment(null, item.id); + if (typeof type == 'string') + type = core.getEquipTypeByName(type); + var compare = core.compareEquipment( + item.id, + core.getEquip(type) + ); + if (info.select.action == 'unload') + compare = core.compareEquipment(null, item.id); // --- 变化值... for (var name in core.status.hero) { if (typeof core.status.hero[name] != 'number') continue; var nowValue = core.getRealStatus(name); // 查询新值 - var newValue = Math.floor((core.getStatus(name) + (compare.value[name] || 0)) * - (core.getBuff(name) * 100 + (compare.percentage[name] || 0)) / 100); + var newValue = Math.floor( + ((core.getStatus(name) + (compare.value[name] || 0)) * + (core.getBuff(name) * 100 + + (compare.percentage[name] || 0))) / + 100 + ); if (nowValue == newValue) continue; var color = newValue > nowValue ? '#00FF00' : '#FF0000'; nowValue = core.formatBigNumber(nowValue); newValue = core.formatBigNumber(newValue); - statusText += core.getStatusLabel(name) + " " + nowValue + "->\r[" + color + "]" + newValue + "\r\n"; + statusText += + core.getStatusLabel(name) + + ' ' + + nowValue + + '->\r[' + + color + + ']' + + newValue + + '\r\n'; } } itemText = statusText + itemText; @@ -5927,10 +7469,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { left: itemText_x, top: itemText_y, bold: false, - color: "white", - align: "left", + color: 'white', + align: 'left', fontSize: itemTextFontSize, - maxWidth: rightbar_width - (itemText_x - rightbar_x) * 2 + itemTextFontSize / 2 + maxWidth: + rightbar_width - + (itemText_x - rightbar_x) * 2 + + itemTextFontSize / 2 }); ///// *** 退出按钮设置 @@ -5938,13 +7483,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var btnBorderWidth = 2; var btnRight = toolboxRight - 2; var btnBottom = toolboxBottom - 2; - var btnBorderStyle = "#fff"; + var btnBorderStyle = '#fff'; ///// *** // 获取圆心位置 var btn_x = btnRight - btnRadius - btnBorderWidth / 2; btn_y = btnBottom - btnRadius - btnBorderWidth / 2; - core.drawToolbox_setExitBtn(ctx, btn_x, btn_y, btnRadius, btnBorderStyle, btnBorderWidth); + core.drawToolbox_setExitBtn( + ctx, + btn_x, + btn_y, + btnRadius, + btnBorderStyle, + btnBorderWidth + ); ///// *** 使用按钮设置 var useBtnHeight = btnRadius * 2; @@ -5952,12 +7504,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var useBtnRadius = useBtnHeight / 2; var useBtn_x = rightbar_x + 4, useBtn_y = btnBottom - useBtnHeight; - var useBtnBorderStyle = "#fff"; + var useBtnBorderStyle = '#fff'; var useBtnBorderWidth = btnBorderWidth; ///// *** - core.drawToolbox_setUseBtn(ctx, useBtn_x, useBtn_y, useBtnRadius, useBtnHeight, useBtnBorderStyle, useBtnBorderWidth); - } + core.drawToolbox_setUseBtn( + ctx, + useBtn_x, + useBtn_y, + useBtnRadius, + useBtnHeight, + useBtnBorderStyle, + useBtnBorderWidth + ); + }; this.drawEquipbox_drawOthers = function (ctx, obj) { var info = core.status.thisUIEventInfo; @@ -5966,17 +7526,26 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var equipList_lineWidth = 2; var equipList_boxSize = 32; var equipList_borderWidth = 2; - var equipList_borderStyle = "#fff"; - var equipList_nameColor = "#fff"; + var equipList_borderStyle = '#fff'; + var equipList_nameColor = '#fff'; ///// *** var equipList_x = obj.x + 4, equipList_bottom = obj.obj.y - equipList_lineWidth, - equipList_y = equipList_bottom - obj.obj.oneItemHeight * reduceItem - 2, + equipList_y = + equipList_bottom - obj.obj.oneItemHeight * reduceItem - 2, equipList_height = equipList_bottom - equipList_y; var equipList_right = obj.leftbar_right, equipList_width = equipList_right - equipList_x; - core.drawLine(ctx, obj.x, equipList_bottom + equipList_lineWidth / 2, equipList_right, equipList_bottom + equipList_lineWidth / 2, equipList_borderStyle, equipList_lineWidth); + core.drawLine( + ctx, + obj.x, + equipList_bottom + equipList_lineWidth / 2, + equipList_right, + equipList_bottom + equipList_lineWidth / 2, + equipList_borderStyle, + equipList_lineWidth + ); var toDrawList = core.status.globalAttribute.equipName, len = toDrawList.length; @@ -5984,15 +7553,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var maxItem = 4; var box_width = 32, box_height = 32, - box_borderStyle = "#fff", - box_selectBorderStyle = "gold", // 选中的装备格的颜色 + box_borderStyle = '#fff', + box_selectBorderStyle = 'gold', // 选中的装备格的颜色 box_borderWidth = 2; var boxName_fontSize = 14, boxName_space = 2, - boxName_color = "#fff"; // 装备格名称与上面的装备格框的距离 + boxName_color = '#fff'; // 装备格名称与上面的装备格框的距离 var maxLine = Math.ceil(len / maxItem); ///// *** - var l = Math.sqrt(len) + var l = Math.sqrt(len); if (Math.pow(l) == len && len != 4) { if (l <= maxItem) maxItem = l; } @@ -6002,27 +7571,57 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var boxName_font = core.ui._buildFont(boxName_fontSize); // 总宽高减去所有装备格宽高得到空隙大小 var oneBoxWidth = box_width + box_borderWidth * 2; - var oneBoxHeight = box_height + boxName_fontSize + boxName_space + 2 * box_borderWidth; - var space_y = (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), - space_x = (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); + var oneBoxHeight = + box_height + + boxName_fontSize + + boxName_space + + 2 * box_borderWidth; + var space_y = + (equipList_height - maxLine * oneBoxHeight) / (1 + maxLine), + space_x = + (equipList_width - maxItem * oneBoxWidth) / (1 + maxItem); var box_x = equipList_x + space_x, box_y = equipList_y + space_y; for (var i = 0; i < len; i++) { var id = core.getEquip(i), name = toDrawList[i]; var selectBorder = false; - if (core.status.thisUIEventInfo.select.type == i) selectBorder = true; - var borderStyle = selectBorder ? box_selectBorderStyle : box_borderStyle; - core.drawEquipbox_drawOne(ctx, name, id, box_x, box_y, box_width, box_height, boxName_space, boxName_font, boxName_color, borderStyle, box_borderWidth); - var todo = new Function("core.clickOneEquipbox('" + id + "'," + i + ")"); - core.addUIEventListener(box_x - box_borderWidth / 2, box_y - box_borderWidth / 2, oneBoxWidth, oneBoxHeight, todo); + if (core.status.thisUIEventInfo.select.type == i) + selectBorder = true; + var borderStyle = selectBorder + ? box_selectBorderStyle + : box_borderStyle; + core.drawEquipbox_drawOne( + ctx, + name, + id, + box_x, + box_y, + box_width, + box_height, + boxName_space, + boxName_font, + boxName_color, + borderStyle, + box_borderWidth + ); + var todo = new Function( + "core.clickOneEquipbox('" + id + "'," + i + ')' + ); + core.addUIEventListener( + box_x - box_borderWidth / 2, + box_y - box_borderWidth / 2, + oneBoxWidth, + oneBoxHeight, + todo + ); box_x += space_x + oneBoxWidth; if ((i + 1) % maxItem == 0) { box_x = equipList_x + space_x; box_y += space_y + oneBoxHeight; } } - } + }; this.drawToolbox = function (ctx) { ctx = ctx || core.canvas.ui; @@ -6032,9 +7631,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { info.itemNum = itemNum; core.drawItemListbox(ctx, info.obj); core.drawToolboxRightbar(ctx, info); - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - } + core.setTextBaseline(ctx, 'alphabetic'); + core.setTextAlign('left'); + }; var reduceItem = 4; this.drawEquipbox = function (ctx) { @@ -6047,48 +7646,114 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.drawItemListbox(ctx, info.obj); core.drawEquipbox_drawOthers(ctx, info); core.drawToolboxRightbar(ctx, info); - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - } + core.setTextBaseline(ctx, 'alphabetic'); + core.setTextAlign('left'); + }; - this.drawEquipbox_drawOne = function (ctx, name, id, x, y, width, height, space, font, color, style, lineWidth) { - if (id) core.drawIcon(ctx, id, x + lineWidth / 2, y + lineWidth / 2, width, height); - core.strokeRect(ctx, x, y, width + lineWidth, height + lineWidth, style, lineWidth); - core.setTextAlign(ctx, "center"); - core.setTextBaseline(ctx, "top"); + this.drawEquipbox_drawOne = function ( + ctx, + name, + id, + x, + y, + width, + height, + space, + font, + color, + style, + lineWidth + ) { + if (id) + core.drawIcon( + ctx, + id, + x + lineWidth / 2, + y + lineWidth / 2, + width, + height + ); + core.strokeRect( + ctx, + x, + y, + width + lineWidth, + height + lineWidth, + style, + lineWidth + ); + core.setTextAlign(ctx, 'center'); + core.setTextBaseline(ctx, 'top'); var tx = (x + x + lineWidth / 2 + width) / 2, - ty = y + height + lineWidth / 2 * 3 + space; + ty = y + height + (lineWidth / 2) * 3 + space; core.fillText(ctx, name, tx, ty, color, font); - core.setTextBaseline(ctx, "alphabetic"); - core.setTextAlign("left"); - } + core.setTextBaseline(ctx, 'alphabetic'); + core.setTextAlign('left'); + }; - this.drawItemListbox_drawItem = function (ctx, left, right, top, height, marginLeft, marginHeight, style, id) { + this.drawItemListbox_drawItem = function ( + ctx, + left, + right, + top, + height, + marginLeft, + marginHeight, + style, + id + ) { var info = core.status.thisUIEventInfo; var nowClick = info.index; var item = core.material.items[id] || {}; - var name = item.name || "???"; + var name = item.name || '???'; var num = core.itemCount(id) || 0; var fontSize = Math.floor(height - marginHeight * 2); - core.setTextAlign(ctx, "right"); - var numText = "x" + num; - core.fillText(ctx, numText, right - marginLeft, top + height / 2, style, core.ui._buildFont(fontSize)); - if (name != "???") core.drawIcon(ctx, id, left + marginLeft, top + marginHeight, fontSize, fontSize); + core.setTextAlign(ctx, 'right'); + var numText = 'x' + num; + core.fillText( + ctx, + numText, + right - marginLeft, + top + height / 2, + style, + core.ui._buildFont(fontSize) + ); + if (name != '???') + core.drawIcon( + ctx, + id, + left + marginLeft, + top + marginHeight, + fontSize, + fontSize + ); var text_x = left + marginLeft + fontSize + 2; var maxWidth = right - core.calWidth(ctx, numText) - text_x; - core.setTextAlign(ctx, "left"); - core.fillText(ctx, name, text_x, top + height / 2, style, core.ui._buildFont(fontSize), maxWidth); - var todo = new Function("var id = '" + id + "';\ncore.clickItemFunc(id)"); + core.setTextAlign(ctx, 'left'); + core.fillText( + ctx, + name, + text_x, + top + height / 2, + style, + core.ui._buildFont(fontSize), + maxWidth + ); + var todo = new Function( + "var id = '" + id + "';\ncore.clickItemFunc(id)" + ); core.addUIEventListener(left, top, right - left, height, todo); - } + }; this.setPageItems = function (page) { var num = itemNum; - if (core.status.event.id == "equipbox") num -= reduceItem; + if (core.status.event.id == 'equipbox') num -= reduceItem; var info = core.status.thisUIEventInfo; if (!info) return; page = page || info.page; - var items = core.getToolboxItems(core.status.event.id == "toolbox" ? "all" : "equips"); + var items = core.getToolboxItems( + core.status.event.id == 'toolbox' ? 'all' : 'equips' + ); info.allItems = items; var maxPage = Math.ceil(items.length / num); info.maxPage = maxPage; @@ -6101,30 +7766,54 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { return core.setPageItems(info.page); } return pageItems; - } + }; - this.drawToolbox_setExitBtn = function (ctx, x, y, r, style, lineWidth) { + this.drawToolbox_setExitBtn = function ( + ctx, + x, + y, + r, + style, + lineWidth + ) { core.strokeCircle(ctx, x, y, r, style, lineWidth); - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; var textSize = Math.sqrt(2) * r; - core.fillText(ctx, "x", x, y, style, core.ui._buildFont(textSize), textSize); - core.setTextAlign(ctx, "start"); - core.setTextBaseline(ctx, "top"); + core.fillText( + ctx, + 'x', + x, + y, + style, + core.ui._buildFont(textSize), + textSize + ); + core.setTextAlign(ctx, 'start'); + core.setTextBaseline(ctx, 'top'); var todo = () => { core.closePanel(); - } + }; core.addUIEventListener(x - r, y - r, r * 2, r * 2, todo); - } + }; - this.drawToolbox_setUseBtn = function (ctx, x, y, r, h, style, lineWidth) { - core.setTextAlign(ctx, "left"); - core.setTextBaseline(ctx, "top"); + this.drawToolbox_setUseBtn = function ( + ctx, + x, + y, + r, + h, + style, + lineWidth + ) { + core.setTextAlign(ctx, 'left'); + core.setTextBaseline(ctx, 'top'); var fontSize = h - 4; var font = core.ui._buildFont(fontSize); - var text = core.status.event.id == "toolbox" ? "使用" : "装备"; - if (core.status.thisUIEventInfo.select.action == "unload") text = "卸下"; + var text = core.status.event.id == 'toolbox' ? '使用' : '装备'; + if (core.status.thisUIEventInfo.select.action == 'unload') + text = '卸下'; var w = core.calWidth(ctx, text, font) + 2 * r + lineWidth / 2; core.strokeRoundRect(ctx, x, y, w, h, r, style, lineWidth); @@ -6132,39 +7821,67 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var todo = () => { core.useSelectItemInBox(); - } + }; core.addUIEventListener(x, y, w, h, todo); - } + }; - this.drawItemListbox_setPageBtn = function (ctx, left, right, bottom, r, style, lineWidth) { + this.drawItemListbox_setPageBtn = function ( + ctx, + left, + right, + bottom, + r, + style, + lineWidth + ) { var offset = lineWidth / 2 + r; var x = left + offset; var y = bottom - offset; - var pos = Math.sqrt(2) / 2 * (r - lineWidth / 2); - core.fillPolygon(ctx, [ - [x - pos, y], - [x + pos - 2, y - pos], - [x + pos - 2, y + pos] - ], style); + var pos = (Math.sqrt(2) / 2) * (r - lineWidth / 2); + core.fillPolygon( + ctx, + [ + [x - pos, y], + [x + pos - 2, y - pos], + [x + pos - 2, y + pos] + ], + style + ); core.strokeCircle(ctx, x, y, r, style, lineWidth); var todo = () => { core.addItemListboxPage(-1); - } - core.addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); + }; + core.addUIEventListener( + x - r - 2, + y - r - 2, + r * 2 + 4, + r * 2 + 4, + todo + ); x = right - offset; - core.fillPolygon(ctx, [ - [x + pos, y], - [x - pos + 2, y - pos], - [x - pos + 2, y + pos] - ], style); + core.fillPolygon( + ctx, + [ + [x + pos, y], + [x - pos + 2, y - pos], + [x - pos + 2, y + pos] + ], + style + ); core.strokeCircle(ctx, x, y, r, style, lineWidth); var todo = () => { core.addItemListboxPage(1); - } - core.addUIEventListener(x - r - 2, y - r - 2, r * 2 + 4, r * 2 + 4, todo); - } + }; + core.addUIEventListener( + x - r - 2, + y - r - 2, + r * 2 + 4, + r * 2 + 4, + todo + ); + }; this.clickItemFunc = function (id) { var info = core.status.thisUIEventInfo; @@ -6174,69 +7891,77 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { info.select.id = id; core.setIndexAndSelect('index'); core.refreshBox(); - } + }; this.clickOneEquipbox = function (id, type) { var info = core.status.thisUIEventInfo; if (!info) return; - if (info.select.id == id && info.select.type == type) core.useSelectItemInBox(); - else core.status.thisUIEventInfo.select = { - id: id, - type: type, - action: "unload" - } + if (info.select.id == id && info.select.type == type) + core.useSelectItemInBox(); + else + core.status.thisUIEventInfo.select = { + id: id, + type: type, + action: 'unload' + }; return core.refreshBox(); - } + }; core.ui.getToolboxItems = function (cls) { var list = Object.keys(core.status.hero.items[cls] || {}); - if (cls == "all") { + if (cls == 'all') { for (var name in core.status.hero.items) { - if (name == "equips") continue; - list = list.concat(Object.keys(core.status.hero.items[name])); + if (name == 'equips') continue; + list = list.concat( + Object.keys(core.status.hero.items[name]) + ); } - return list.filter((id) => { - return !core.material.items[id].hideInToolbox; - }).sort(); + return list + .filter(id => { + return !core.material.items[id].hideInToolbox; + }) + .sort(); } if (this.uidata.getToolboxItems) { return this.uidata.getToolboxItems(cls); } - return list.filter((id) => { - return !core.material.items[id].hideInToolbox; - }).sort(); - } + return list + .filter(id => { + return !core.material.items[id].hideInToolbox; + }) + .sort(); + }; this.useSelectItemInBox = function () { var info = core.status.thisUIEventInfo; if (!info) return; if (!info.select.id) return; var id = info.select.id; - if (core.status.event.id == "toolbox") { + if (core.status.event.id == 'toolbox') { core.events.tryUseItem(id); // core.closePanel(); - } else if (core.status.event.id == "equipbox") { - var action = info.select.action || "load"; + } else if (core.status.event.id == 'equipbox') { + var action = info.select.action || 'load'; info.index = 1; - if (action == "load") { + if (action == 'load') { var type = core.getEquipTypeById(id); core.loadEquip(id, () => { - core.status.route.push("equip:" + id); + core.status.route.push('equip:' + id); info.select.type = type; - core.setIndexAndSelect("select"); + core.setIndexAndSelect('select'); core.drawEquipbox(); }); } else { var type = info.select.type; core.unloadEquip(type, () => { - core.status.route.push("unEquip:" + type); - core.setIndexAndSelect("select"); + core.status.route.push('unEquip:' + type); + core.setIndexAndSelect('select'); core.drawEquipbox(); }); } } - } + }; this.setIndexAndSelect = function (toChange) { var info = core.status.thisUIEventInfo; @@ -6250,19 +7975,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { info.index = null; info.select = { id: id, - action: "unload", + action: 'unload', type: type }; return; } else { info.select.type = null; } - if (toChange == "index") info.index = items.indexOf(info.select.id) + 1; + if (toChange == 'index') + info.index = items.indexOf(info.select.id) + 1; else { var id = info.pageItems[index - 1]; info.select.id = id; } - } + }; this.addItemListboxPage = function (num) { var info = core.status.thisUIEventInfo; @@ -6274,9 +8000,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (info.page > maxPage) info.page = 1; info.index = 1; core.setPageItems(info.page); - core.setIndexAndSelect("select"); + core.setIndexAndSelect('select'); core.refreshBox(); - } + }; this.addItemListboxIndex = function (num) { var info = core.status.thisUIEventInfo; @@ -6286,9 +8012,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { info.index += num; if (info.index <= 0) info.index = 1; if (info.index > maxItem) info.index = maxItem; - core.setIndexAndSelect("select"); + core.setIndexAndSelect('select'); core.refreshBox(); - } + }; this.addEquipboxType = function (num) { var info = core.status.thisUIEventInfo; @@ -6305,36 +8031,38 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.refreshBox(); return; } - } + }; core.actions._keyDownToolbox = function (keycode) { if (!core.status.thisEventClickArea) return; - if (keycode == 37) { // left + if (keycode == 37) { + // left core.addItemListboxPage(-1); return; } - if (keycode == 38) { // up + if (keycode == 38) { + // up core.addItemListboxIndex(-1); return; } - if (keycode == 39) { // right + if (keycode == 39) { + // right core.addItemListboxPage(1); return; } - if (keycode == 40) { // down + if (keycode == 40) { + // down core.addItemListboxIndex(1); return; } - } + }; ////// 工具栏界面时,放开某个键的操作 ////// core.actions._keyUpToolbox = function (keycode) { if (keycode == 81) { core.ui.closePanel(); - if (core.isReplaying()) - core.control._replay_equipbox(); - else - core.openEquipbox(); + if (core.isReplaying()) core.control._replay_equipbox(); + else core.openEquipbox(); return; } if (keycode == 84 || keycode == 27 || keycode == 88) { @@ -6348,36 +8076,41 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } return; } - } + }; core.actions._keyDownEquipbox = function (keycode) { if (!core.status.thisEventClickArea) return; - if (keycode == 37) { // left + if (keycode == 37) { + // left var info = core.status.thisUIEventInfo; if (info.index != null) return core.addItemListboxPage(-1); return core.addEquipboxType(-1); } - if (keycode == 38) { // up + if (keycode == 38) { + // up var info = core.status.thisUIEventInfo; if (info.index == 1) { - info.select.type = core.status.globalAttribute.equipName.length - 1; + info.select.type = + core.status.globalAttribute.equipName.length - 1; core.setIndexAndSelect(); return core.refreshBox(); } if (info.index) return core.addItemListboxIndex(-1); return core.addEquipboxType(-1 * info.equips); } - if (keycode == 39) { // right + if (keycode == 39) { + // right var info = core.status.thisUIEventInfo; if (info.index != null) return core.addItemListboxPage(1); return core.addEquipboxType(1); } - if (keycode == 40) { // down + if (keycode == 40) { + // down var info = core.status.thisUIEventInfo; if (info.index) return core.addItemListboxIndex(1); return core.addEquipboxType(info.equips); } - } + }; core.actions._keyUpEquipbox = function (keycode, altKey) { if (altKey && keycode >= 48 && keycode <= 57) { @@ -6386,10 +8119,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } if (keycode == 84) { core.ui.closePanel(); - if (core.isReplaying()) - core.control._replay_toolbox(); - else - core.openToolbox(); + if (core.isReplaying()) core.control._replay_toolbox(); + else core.openToolbox(); return; } if (keycode == 81 || keycode == 27 || keycode == 88) { @@ -6401,24 +8132,39 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (info.select) core.useSelectItemInBox(); return; } - } + }; - core.registerAction("ondown", "inEventClickAction", (x, y, px, py) => { - if (!core.status.thisEventClickArea) return false; - // console.log(px + "," + py); - var info = core.status.thisEventClickArea; - for (var i = 0; i < info.length; i++) { - var obj = info[i]; - if (px >= obj.x && px <= obj.x + obj.width && py > obj.y && py < obj.y + obj.height) { - if (obj.todo) obj.todo(); - break; + core.registerAction( + 'ondown', + 'inEventClickAction', + (x, y, px, py) => { + if (!core.status.thisEventClickArea) return false; + // console.log(px + "," + py); + var info = core.status.thisEventClickArea; + for (var i = 0; i < info.length; i++) { + var obj = info[i]; + if ( + px >= obj.x && + px <= obj.x + obj.width && + py > obj.y && + py < obj.y + obj.height + ) { + if (obj.todo) obj.todo(); + break; + } } - } - return true; - }, 51); - core.registerAction("onclick", "stopClick", () => { - if (core.status.thisEventClickArea) return true; - }, 51); + return true; + }, + 51 + ); + core.registerAction( + 'onclick', + 'stopClick', + () => { + if (core.status.thisEventClickArea) return true; + }, + 51 + ); this.addUIEventListener = function (x, y, width, height, todo) { if (!core.status.thisEventClickArea) return; @@ -6428,9 +8174,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { width: width, height: height, todo: todo - } + }; core.status.thisEventClickArea.push(obj); - } + }; this.initThisEventInfo = function () { core.status.thisUIEventInfo = { @@ -6438,19 +8184,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { select: {} }; core.status.thisEventClickArea = []; - } + }; this.refreshBox = function () { if (!core.status.event.id) return; - if (core.status.event.id == "toolbox") core.drawToolbox(); + if (core.status.event.id == 'toolbox') core.drawToolbox(); else core.drawEquipbox(); - } + }; core.ui.closePanel = function () { if (core.status.hero && core.status.hero.flags) { // 清除全部临时变量 - Object.keys(core.status.hero.flags).forEach((name) => { - if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) { + Object.keys(core.status.hero.flags).forEach(name => { + if (name.startsWith('@temp@') || /^arg\d+$/.test(name)) { delete core.status.hero.flags[name]; } }); @@ -6465,71 +8211,84 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.status.event.ui = null; core.status.event.interval = null; core.status.thisUIEventInfo = null; - core.status.thisEventClickArea = null - } + core.status.thisEventClickArea = null; + }; this.getItemClsName = function (item) { if (item == null) return itemClsName; - if (item.cls == "equips") { - if (typeof item.equip.type == "string") return item.equip.type; + if (item.cls == 'equips') { + if (typeof item.equip.type == 'string') return item.equip.type; var type = core.getEquipTypeById(item.id); return core.status.globalAttribute.equipName[type]; } else return itemClsName[item.cls] || item.cls; - } + }; core.events.openToolbox = function (fromUserAction) { if (core.isReplaying()) return; if (!this._checkStatus('toolbox', fromUserAction)) return; core.initThisEventInfo(); core.drawToolbox(); - } + }; core.events.openEquipbox = function (fromUserAction) { if (core.isReplaying()) return; if (!this._checkStatus('equipbox', fromUserAction)) return; core.initThisEventInfo(); core.drawEquipbox(); - } + }; core.control._replay_toolbox = function () { if (!core.isPlaying() || !core.isReplaying()) return; - if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); - if (core.isMoving() || core.status.replay.animate || core.status.event.id) - return core.drawTip("请等待当前事件的处理结束"); + if (!core.status.replay.pausing) + return core.drawTip('请先暂停录像'); + if ( + core.isMoving() || + core.status.replay.animate || + core.status.event.id + ) + return core.drawTip('请等待当前事件的处理结束'); core.lockControl(); core.status.event.id = 'toolbox'; core.drawToolbox(); - } + }; core.control._replay_equipbox = function () { if (!core.isPlaying() || !core.isReplaying()) return; - if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); - if (core.isMoving() || core.status.replay.animate || core.status.event.id) - return core.drawTip("请等待当前事件的处理结束"); + if (!core.status.replay.pausing) + return core.drawTip('请先暂停录像'); + if ( + core.isMoving() || + core.status.replay.animate || + core.status.event.id + ) + return core.drawTip('请等待当前事件的处理结束'); core.lockControl(); core.status.event.id = 'equipbox'; core.drawEquipbox(); - } + }; core.control._replayAction_item = function (action) { - if (action.indexOf("item:") != 0) return false; + if (action.indexOf('item:') != 0) return false; var itemId = action.substring(5); if (!core.canUseItem(itemId)) return false; - if (core.material.items[itemId].hideInReplay || core.status.replay.speed == 24) { + if ( + core.material.items[itemId].hideInReplay || + core.status.replay.speed == 24 + ) { core.useItem(itemId, false, core.replay); return true; } - core.status.event.id = "toolbox"; + core.status.event.id = 'toolbox'; core.initThisEventInfo(); var info = core.status.thisUIEventInfo; - var items = core.getToolboxItems("all"); + var items = core.getToolboxItems('all'); core.setPageItems(1); var index = items.indexOf(itemId) + 1; info.page = Math.ceil(index / info.maxItem); info.index = index % info.maxItem || info.maxItem; - core.setIndexAndSelect("select"); + core.setIndexAndSelect('select'); core.setPageItems(info.page); core.drawToolbox(); setTimeout(() => { @@ -6537,26 +8296,29 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.useItem(itemId, false, core.replay); }, core.control.__replay_getTimeout()); return true; - } + }; core.control._replayAction_equip = function (action) { - if (action.indexOf("equip:") != 0) return false; + if (action.indexOf('equip:') != 0) return false; var itemId = action.substring(6); var items = core.getToolboxItems('equips'); var index = items.indexOf(itemId) + 1; if (index < 1) return false; core.status.route.push(action); - if (core.material.items[itemId].hideInReplay || core.status.replay.speed == 24) { + if ( + core.material.items[itemId].hideInReplay || + core.status.replay.speed == 24 + ) { core.loadEquip(itemId, core.replay); return true; } - core.status.event.id = "equipbox"; + core.status.event.id = 'equipbox'; core.initThisEventInfo(); var info = core.status.thisUIEventInfo; core.setPageItems(1); info.page = Math.ceil(index / info.maxItem); info.index = index % info.maxItem || info.maxItem; - core.setIndexAndSelect("select"); + core.setIndexAndSelect('select'); core.setPageItems(info.page); core.drawEquipbox(); setTimeout(() => { @@ -6564,10 +8326,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.loadEquip(itemId, core.replay); }, core.control.__replay_getTimeout()); return true; - } + }; core.control._replayAction_unEquip = function (action) { - if (action.indexOf("unEquip:") != 0) return false; + if (action.indexOf('unEquip:') != 0) return false; var equipType = parseInt(action.substring(8)); if (!core.isset(equipType)) return false; core.status.route.push(action); @@ -6575,7 +8337,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.unloadEquip(equipType, core.replay); return true; } - core.status.event.id = "equipbox"; + core.status.event.id = 'equipbox'; core.initThisEventInfo(); var info = core.status.thisUIEventInfo; core.setPageItems(1); @@ -6587,12 +8349,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.unloadEquip(equipType, core.replay); }, core.control.__replay_getTimeout()); return true; - } - core.registerReplayAction("item", core.control._replayAction_item); - core.registerReplayAction("equip", core.control._replayAction_equip); - core.registerReplayAction("unEquip", core.control._replayAction_unEquip); + }; + core.registerReplayAction('item', core.control._replayAction_item); + core.registerReplayAction('equip', core.control._replayAction_equip); + core.registerReplayAction( + 'unEquip', + core.control._replayAction_unEquip + ); }, - "chase": function () { + chase: function () { // 山野追逐战 // 初始变量 // 视野路线 x, y, frame @@ -6625,14 +8390,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { [58, 0, 3600], [47, 0, 3800], [36, 0, 4000], - [0, 0, 4600], + [0, 0, 4600] ]; // 效果函数 - var funcs = [ - [0, wolfRun], - [550, shake1], - [10000000] - ]; + var funcs = [[0, wolfRun], [550, shake1], [10000000]]; var parrallels = [para1, para2]; // 并行脚本 var speed = 0; // 速度 var index = 0; // 当前要到达的索引 @@ -6656,15 +8417,22 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { y = core.getHeroLoc('y'); // 勇士坐标 // 循环删除 for (var i = 13; i < 16; i++) { - var floorId = "MT" + i; + var floorId = 'MT' + i; // 不可瞬移 core.status.maps[floorId].cannotMoveDirectly = true; core.extractBlocks(floorId); - for (var j = 0; j < core.status.maps[floorId].blocks.length; j++) { + for ( + var j = 0; + j < core.status.maps[floorId].blocks.length; + j++ + ) { var block = core.status.maps[floorId].blocks[j]; var cls = block.event.cls, id = block.event.id; - if ((cls == "animates" || cls == "items") && !id.endsWith("Portal")) { + if ( + (cls == 'animates' || cls == 'items') && + !id.endsWith('Portal') + ) { core.removeBlock(block.x, block.y, floorId); j--; } @@ -6672,79 +8440,106 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } }; // 函数们 - function wolfRun () { - core.moveBlock(23, 17, ['down', 'down', 'down', 'down', 'down', 'down'], 80); + function wolfRun() { + core.moveBlock( + 23, + 17, + ['down', 'down', 'down', 'down', 'down', 'down'], + 80 + ); setTimeout(() => { core.setBlock(508, 23, 23); - core.moveBlock(23, 23, ['left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', - 'left', 'left', 'left', 'left', 'left', 'left', 'left', - ], 80, true); + core.moveBlock( + 23, + 23, + [ + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left', + 'left' + ], + 80, + true + ); }, 500); } // MT15函数1 - function shake1 () { - core.vibrate("vertical", 1000, 25, 2); + function shake1() { + core.vibrate('vertical', 1000, 25, 2); for (var tx = 53; tx < 58; tx++) { for (var ty = 3; ty < 8; ty++) { core.setBlock(336, tx, ty); } } - core.drawAnimate("explosion3", 55, 5); - core.drawAnimate("stone", 55, 5); + core.drawAnimate('explosion3', 55, 5); + core.drawAnimate('stone', 55, 5); setTimeout(() => { core.setBlock(336, 58, 9); core.setBlock(336, 59, 9); - core.drawAnimate("explosion1", 58, 9); - core.drawAnimate("explosion1", 59, 9); + core.drawAnimate('explosion1', 58, 9); + core.drawAnimate('explosion1', 59, 9); }, 250); setTimeout(() => { core.setBlock(336, 53, 8); core.setBlock(336, 52, 8); - core.drawAnimate("explosion1", 53, 8); - core.drawAnimate("explosion1", 52, 8); + core.drawAnimate('explosion1', 53, 8); + core.drawAnimate('explosion1', 52, 8); }, 360); setTimeout(() => { core.setBlock(336, 51, 7); - core.drawAnimate("explosion1", 51, 7); + core.drawAnimate('explosion1', 51, 7); }, 750); setTimeout(() => { - core.vibrate("vertical", 6000, 25, 1); + core.vibrate('vertical', 6000, 25, 1); core.setBlock(336, 47, 7); core.setBlock(336, 49, 9); - core.drawAnimate("explosion1", 49, 9); - core.drawAnimate("explosion1", 47, 7); + core.drawAnimate('explosion1', 49, 9); + core.drawAnimate('explosion1', 47, 7); }, 1000); } // 并行1 - function para1 () { - if (core.status.floorId != "MT15") return; + function para1() { + if (core.status.floorId != 'MT15') return; if (x == 45 && y == 8 && !flags.p11) { core.setBlock(336, 45, 9); - core.drawAnimate("explosion1", 45, 9); + core.drawAnimate('explosion1', 45, 9); flags.p11 = true; } if (x == 45 && y == 6 && !flags.p12) { core.setBlock(336, 44, 6); - core.drawAnimate("explosion1", 44, 6); + core.drawAnimate('explosion1', 44, 6); flags.p12 = true; } if (x == 45 && y == 4 && !flags.p13) { core.setBlock(336, 44, 4); - core.drawAnimate("explosion1", 44, 4); - core.drawAnimate("explosion1", 48, 6); + core.drawAnimate('explosion1', 44, 4); + core.drawAnimate('explosion1', 48, 6); core.removeBlock(48, 6); flags.p13 = true; } if (x == 41 && y == 3 && !flags.p14) { core.setBlock(336, 41, 4); core.setBlock(336, 32, 6); - core.drawAnimate("explosion1", 41, 4); - core.drawAnimate("explosion1", 32, 6); + core.drawAnimate('explosion1', 41, 4); + core.drawAnimate('explosion1', 32, 6); flags.p14 = true; } if (x == 35 && y == 3 && !flags.p15) { - core.drawAnimate("explosion3", 37, 7); - core.vibrate("vertical", 1000, 25, 10); + core.drawAnimate('explosion3', 37, 7); + core.vibrate('vertical', 1000, 25, 10); for (var tx = 36; tx < 42; tx++) { for (var ty = 4; ty < 11; ty++) { core.setBlock(336, tx, ty); @@ -6753,74 +8548,78 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { flags.p15 = true; } if (x == 31 && y == 5 && !flags.p16) { - core.vibrate("vertical", 10000, 25, 1); + core.vibrate('vertical', 10000, 25, 1); core.removeBlock(34, 8); core.removeBlock(33, 8); - core.drawAnimate("explosion1", 34, 8); - core.drawAnimate("explosion1", 33, 8); + core.drawAnimate('explosion1', 34, 8); + core.drawAnimate('explosion1', 33, 8); flags.p16 = true; } if (x == 33 && y == 7 && !flags.p17) { core.setBlock(336, 32, 9); - core.drawAnimate("explosion1", 32, 9); + core.drawAnimate('explosion1', 32, 9); flags.p17 = true; } if ((x == 33 || x == 34 || x == 35) && y == 9 && !flags.p18) { core.removeBlock(32, 9); - core.drawAnimate("explosion1", 32, 9); + core.drawAnimate('explosion1', 32, 9); flags.p18 = true; } - if (x > 18 && x < 31 && y == 11 && !flags["p19" + x]) { + if (x > 18 && x < 31 && y == 11 && !flags['p19' + x]) { core.setBlock(336, x + 1, 11); - core.drawAnimate("explosion1", x + 1, 11); - flags["p19" + x] = true; + core.drawAnimate('explosion1', x + 1, 11); + flags['p19' + x] = true; } } // 并行2 - function para2 () { - if (core.status.floorId != "MT14") return; + function para2() { + if (core.status.floorId != 'MT14') return; if (x == 126 && y == 7 && !flags.p21) { core.setBlock(336, 126, 6); core.setBlock(336, 124, 6); core.setBlock(336, 124, 9); core.setBlock(336, 126, 9); - core.drawAnimate("explosion1", 126, 6); - core.drawAnimate("explosion1", 124, 6); - core.drawAnimate("explosion1", 124, 9); - core.drawAnimate("explosion1", 126, 9); + core.drawAnimate('explosion1', 126, 6); + core.drawAnimate('explosion1', 124, 6); + core.drawAnimate('explosion1', 124, 9); + core.drawAnimate('explosion1', 126, 9); flags.p21 = true; } if (x == 123 && y == 7 && !flags.p22) { core.setBlock(508, 127, 7); core.jumpBlock(127, 7, 112, 7, 500, true); - setTimeout(() => { core.setBlock(509, 112, 7); }, 520); - core.drawHeroAnimate("amazed"); + setTimeout(() => { + core.setBlock(509, 112, 7); + }, 520); + core.drawHeroAnimate('amazed'); core.setBlock(336, 121, 6); core.setBlock(336, 122, 6); core.setBlock(336, 120, 8); core.setBlock(336, 121, 8); core.setBlock(336, 122, 8); - core.drawAnimate("explosion1", 121, 6); - core.drawAnimate("explosion1", 122, 6); - core.drawAnimate("explosion1", 120, 8); - core.drawAnimate("explosion1", 121, 8); - core.drawAnimate("explosion1", 122, 8); + core.drawAnimate('explosion1', 121, 6); + core.drawAnimate('explosion1', 122, 6); + core.drawAnimate('explosion1', 120, 8); + core.drawAnimate('explosion1', 121, 8); + core.drawAnimate('explosion1', 122, 8); flags.p22 = true; } if (x == 110 && y == 10 && !flags.p23) { core.setBlock(336, 109, 11); core.removeBlock(112, 8); - core.drawAnimate("explosion1", 109, 11); - core.drawAnimate("explosion1", 112, 8); + core.drawAnimate('explosion1', 109, 11); + core.drawAnimate('explosion1', 112, 8); core.insertAction([ - { "type": "moveHero", "time": 400, "steps": ["backward:1"] }, + { type: 'moveHero', time: 400, steps: ['backward:1'] } ]); flags.p23 = true; } if (x == 112 && y == 8 && !flags.p24 && flags.p23) { core.jumpBlock(112, 7, 110, 4, 500, true); - core.drawHeroAnimate("amazed"); - setTimeout(() => { core.setBlock(506, 110, 4); }, 540); + core.drawHeroAnimate('amazed'); + setTimeout(() => { + core.setBlock(506, 110, 4); + }, 540); flags.p24 = true; } if (x == 118 && y == 7 && !flags.p25) { @@ -6830,28 +8629,28 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.setBlock(336, 114, 6); core.setBlock(336, 117, 8); core.setBlock(336, 116, 8); - core.drawAnimate("explosion1", 117, 6); - core.drawAnimate("explosion1", 116, 6); - core.drawAnimate("explosion1", 115, 6); - core.drawAnimate("explosion1", 114, 6); - core.drawAnimate("explosion1", 116, 8); - core.drawAnimate("explosion1", 117, 8); + core.drawAnimate('explosion1', 117, 6); + core.drawAnimate('explosion1', 116, 6); + core.drawAnimate('explosion1', 115, 6); + core.drawAnimate('explosion1', 114, 6); + core.drawAnimate('explosion1', 116, 8); + core.drawAnimate('explosion1', 117, 8); flags.p25 = true; } if (x == 112 && y == 7 && !flags.p26) { core.setBlock(336, 112, 8); core.setBlock(336, 113, 7); - core.drawAnimate("explosion1", 112, 8); - core.drawAnimate("explosion1", 113, 7); + core.drawAnimate('explosion1', 112, 8); + core.drawAnimate('explosion1', 113, 7); flags.p26 = true; } if (x == 115 && y == 7 && !flags.p39) { for (var tx = 111; tx <= 115; tx++) { core.setBlock(336, tx, 10); - core.drawAnimate("explosion1", tx, 10); + core.drawAnimate('explosion1', tx, 10); } core.setBlock(336, 112, 8); - core.drawAnimate("explosion1", 112, 8); + core.drawAnimate('explosion1', 112, 8); flags.p39 = true; } if (x == 110 && y == 7 && !flags.p27) { @@ -6862,49 +8661,54 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.setBlock(336, tx, ty); } } - core.vibrate("vertical", 3000, 25, 10); - core.drawAnimate("explosion2", 119, 7); - core.insertAction( - [{ "type": "autoText", "text": "\t[原始人]\b[down,hero]卧槽!!吓死我了!!", "time": 600 },]); + core.vibrate('vertical', 3000, 25, 10); + core.drawAnimate('explosion2', 119, 7); + core.insertAction([ + { + type: 'autoText', + text: '\t[原始人]\b[down,hero]卧槽!!吓死我了!!', + time: 600 + } + ]); core.removeBlock(105, 7); - core.drawAnimate("explosion1", 105, 7); + core.drawAnimate('explosion1', 105, 7); flags.p27 = true; } if (x == 97 && y == 3 && !flags.p28) { core.setBlock(336, 95, 3); core.setBlock(336, 93, 6); - core.drawAnimate("explosion1", 95, 3); - core.drawAnimate("explosion1", 93, 6); + core.drawAnimate('explosion1', 95, 3); + core.drawAnimate('explosion1', 93, 6); flags.p28 = true; } if (x == 88 && y == 6 && !flags.p29) { core.setBlock(336, 87, 4); core.setBlock(336, 88, 5); - core.drawAnimate("explosion1", 87, 4); - core.drawAnimate("explosion1", 88, 5); + core.drawAnimate('explosion1', 87, 4); + core.drawAnimate('explosion1', 88, 5); flags.p29 = true; } if (x == 86 && y == 6 && !flags.p30) { core.setBlock(336, 84, 6); core.setBlock(336, 85, 5); core.setBlock(336, 86, 8); - core.drawAnimate("explosion1", 84, 6); - core.drawAnimate("explosion1", 85, 5); - core.drawAnimate("explosion1", 86, 8); + core.drawAnimate('explosion1', 84, 6); + core.drawAnimate('explosion1', 85, 5); + core.drawAnimate('explosion1', 86, 8); flags.p30 = true; } if (x == 81 && y == 9 && !flags.p31) { core.setBlock(336, 81, 8); core.setBlock(336, 82, 11); - core.drawAnimate("explosion1", 81, 8); - core.drawAnimate("explosion1", 82, 11); + core.drawAnimate('explosion1', 81, 8); + core.drawAnimate('explosion1', 82, 11); flags.p31 = true; } if (x == 72 && y == 11 && !flags.p32) { core.setBlock(336, 73, 8); core.setBlock(336, 72, 4); - core.drawAnimate("explosion1", 73, 8); - core.drawAnimate("explosion1", 72, 4); + core.drawAnimate('explosion1', 73, 8); + core.drawAnimate('explosion1', 72, 4); flags.p32 = true; } if (x == 72 && y == 7 && !flags.p33) { @@ -6913,16 +8717,18 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.setBlock(336, tx, ty); } } - core.drawAnimate("explosion2", 79, 7); - core.vibrate("vertical", 4000, 25, 15); - setTimeout(() => { core.vibrate(10000, null, 4) }); + core.drawAnimate('explosion2', 79, 7); + core.vibrate('vertical', 4000, 25, 15); + setTimeout(() => { + core.vibrate(10000, null, 4); + }); flags.p33 = true; } if (x == 68 && y == 5 && !flags.p34) { core.setBlock(336, 68, 4); core.setBlock(336, 67, 6); - core.drawAnimate("explosion1", 68, 4); - core.drawAnimate("explosion1", 67, 6); + core.drawAnimate('explosion1', 68, 4); + core.drawAnimate('explosion1', 67, 6); flags.p34 = true; } if (x == 67 && y == 10 && !flags.p35) { @@ -6933,17 +8739,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } core.setBlock(336, 72, 10); core.setBlock(336, 72, 11); - core.drawAnimate("explosion3", 69, 5); - core.vibrate("vertical", 2000, 25, 7); + core.drawAnimate('explosion3', 69, 5); + core.vibrate('vertical', 2000, 25, 7); flags.p35 = true; } if (x == 64 && y == 11 && !flags.p36) { core.setBlock(336, 63, 9); core.setBlock(336, 60, 8); core.setBlock(336, 56, 11); - core.drawAnimate("explosion1", 63, 9); - core.drawAnimate("explosion1", 60, 8); - core.drawAnimate("explosion1", 56, 11); + core.drawAnimate('explosion1', 63, 9); + core.drawAnimate('explosion1', 60, 8); + core.drawAnimate('explosion1', 56, 11); flags.p36 = true; } if (x == 57 && y == 9 && !flags.p37) { @@ -6952,17 +8758,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.setBlock(336, tx, ty); } } - core.drawAnimate("explosion2", 61, 7); - core.vibrate("vertical", 3000, 25, 12); - setTimeout(() => { core.vibrate(20000, null, 4); }, 3000); + core.drawAnimate('explosion2', 61, 7); + core.vibrate('vertical', 3000, 25, 12); + setTimeout(() => { + core.vibrate(20000, null, 4); + }, 3000); flags.p37 = true; } - if (x <= 48 && !flags["p38" + x] && x >= 21) { + if (x <= 48 && !flags['p38' + x] && x >= 21) { for (var ty = 3; ty <= 11; ty++) { core.setBlock(336, x + 4, ty); - core.drawAnimate("explosion1", x + 4, ty); + core.drawAnimate('explosion1', x + 4, ty); } - flags["p38" + x] = true; + flags['p38' + x] = true; } if (x == 21 && flags.p37) { core.endChase(); @@ -6982,11 +8790,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { x = core.getHeroLoc('x'); y = core.getHeroLoc('y'); // 勇士坐标 core.values.moveSpeed = 100; - core.loadOneSound("quake.mp3"); + core.loadOneSound('quake.mp3'); core.drawHero(); core.pauseBgm(); - core.playBgm("escape.mp3", 43.5); - + core.playBgm('escape.mp3', 43.5); }; // 视野变化 useAcc:是否匀变速 this.changeChaseView = function (useAcc) { @@ -6994,7 +8801,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var floorId = core.status.floorId; if (frame >= 3600) useAcc = false; // 刚进MT15时 - if (floorId === "MT15" && !inBlack) { + if (floorId === 'MT15' && !inBlack) { frame = 500; index = 3; fIndex = 1; @@ -7002,42 +8809,48 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { acc = 0; currX = 32 * 49; inBlack = true; - core.setGameCanvasTranslate("hero", 224, 0); + core.setGameCanvasTranslate('hero', 224, 0); flags.startShake = true; - core.playSound("地震"); - core.insertAction([ - { "type": "sleep", "time": 500, "noSkip": true }, - ]); + core.playSound('地震'); + core.insertAction([{ type: 'sleep', time: 500, noSkip: true }]); var interval = setInterval(() => { - core.playSound("地震"); + core.playSound('地震'); if (index >= route.length - 1) clearInterval(interval); }, 15000); - core.vibrate("vertical", 1000, 25); + core.vibrate('vertical', 1000, 25); setTimeout(() => { core.blackEdge(); - core.insertAction( - [{ "type": "autoText", "text": "\t[原始人]\b[down,hero]糟糕,还地震了!", "time": 1500 }, - { "type": "autoText", "text": "\t[原始人]\b[down,hero]快跑!", "time": 1000 }, - ]); + core.insertAction([ + { + type: 'autoText', + text: '\t[原始人]\b[down,hero]糟糕,还地震了!', + time: 1500 + }, + { + type: 'autoText', + text: '\t[原始人]\b[down,hero]快跑!', + time: 1000 + } + ]); flags.startShake = false; }, 500); } // 超范围失败 if (x * 32 > currX + 480 + 64) { flags.haveLost = true; - core.lose("逃跑失败"); + core.lose('逃跑失败'); return; } // 刚进MT14 - if (floorId == "MT14" && !flags.first14) { + if (floorId == 'MT14' && !flags.first14) { frame = 2500; index = 17; fIndex = 2; speed = 0; acc = 0; currX = 117 * 32; - core.vibrate("vertical", 10000, 25, 2); - core.setGameCanvasTranslate("hero", 224, 0); + core.vibrate('vertical', 10000, 25, 2); + core.setGameCanvasTranslate('hero', 224, 0); flags.first14 = true; } // 停止运行 @@ -7045,8 +8858,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { // 切换索引 if (frame > route[index][2]) { index++; - if (index == 3 && floorId == "MT16") { - core.lose("逃跑失败"); + if (index == 3 && floorId == 'MT16') { + core.lose('逃跑失败'); } if (index >= route.length) { return; @@ -7054,11 +8867,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.changeChaseIndex(useAcc); } // 碰到狼就死 - if (floorId == "MT16") { + if (floorId == 'MT16') { if (x >= 6) { if (x > 25 - (frame - 29) / 5) { flags.haveLost = true; - core.lose("逃跑失败"); + core.lose('逃跑失败'); return; } } @@ -7074,7 +8887,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { } if (useAcc) speed += acc; currX += speed; - if (floorId == "MT16") core.setViewport(currX, 320); + if (floorId == 'MT16') core.setViewport(currX, 320); else core.setViewport(currX, 0); x = core.getHeroLoc('x'); y = core.getHeroLoc('y'); @@ -7098,15 +8911,15 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }; // 黑边 this.blackEdge = function () { - core.createCanvas("edge", 0, 0, 480, 480, 100); + core.createCanvas('edge', 0, 0, 480, 480, 100); var f = 0; var h = 0, s = 2.56; // 初始动画 - function start () { - core.clearMap("edge"); - core.fillRect("edge", 0, 0, 480, h); - core.fillRect("edge", 0, 480, 480, -h); + function start() { + core.clearMap('edge'); + core.fillRect('edge', 0, 0, 480, h); + core.fillRect('edge', 0, 480, 480, -h); f++; s -= 0.0512; h += s; @@ -7125,18 +8938,254 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { var h = 64, s = 0; var interval = setInterval(() => { - core.clearMap("edge"); - core.fillRect("edge", 0, 0, 480, h); - core.fillRect("edge", 0, 480, 480, -h); + core.clearMap('edge'); + core.fillRect('edge', 0, 0, 480, h); + core.fillRect('edge', 0, 480, 480, -h); f++; s += 0.0512; h -= s; if (f == 50) { clearInterval(interval); - core.deleteCanvas("edge"); + core.deleteCanvas('edge'); flags.finishChase = true; } }); + }; + }, + hotReload: function () { + if (main.mode !== 'play' || main.replayChecking) return; + + /** + * 发送请求 + * @param {string} url + * @param {string} type + * @param {string} data + * @returns {Promise} + */ + async function post(url, type, data) { + const xhr = new XMLHttpRequest(); + xhr.open(type, url); + xhr.send(data); + const res = await new Promise(res => { + xhr.onload = e => { + if (xhr.status !== 200) { + console.error(`hot reload: http ${xhr.status}`); + res('@error'); + } else res('success'); + }; + xhr.onerror = e => { + res('@error'); + console.error(`hot reload: error on connection`); + }; + }); + if (res === 'success') return xhr.response; + else return '@error'; } + + /** + * 热重载css + * @param {string} data + */ + function reloadCss(data) { + const all = Array.from(document.getElementsByTagName('link')); + all.forEach(v => { + if (v.rel !== 'stylesheet') return; + if (v.href === `http://127.0.0.1:3000/${data}`) { + v.remove(); + const link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = data; + document.head.appendChild(link); + console.log(`hot reload css: ${data}`); + } + }); + } + + /** + * 热重载楼层 + * @param {string} data + */ + async function reloadFloor(data) { + // 首先重新加载main.floors对应的楼层 + await import(`/project/floors/${data}.js?v=${Date.now()}`); + // 然后写入core.floors并解析 + core.floors[data] = main.floors[data]; + const floor = core.loadFloor(data); + if (core.isPlaying()) { + core.status.maps[data] = floor; + delete core.status.mapBlockObjs[data]; + core.extractBlocks(data); + core.drawMap(data); + core.setWeather( + core.animateFrame.weather.type, + core.animateFrame.weather.level + ); + core.updateStatusBar(true, true); + } + console.log(`hot reload floor: ${data}`); + } + + /** + * 热重载脚本编辑及插件编写 + * @param {string} data + */ + async function reloadScript(data) { + if (data === 'plugins') { + // 插件编写比较好办 + const before = plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1; + // 这里不能用动态导入,因为动态导入会变成模块,变量就不是全局的了 + const script = document.createElement('script'); + script.src = `/project/plugins.js?v=${Date.now()}`; + document.body.appendChild(script); + await new Promise(res => { + script.onload = () => res('success'); + }); + const after = plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1; + // 找到差异的函数 + for (const id in before) { + const fn = before[id]; + if (typeof fn !== 'function') continue; + if (fn.toString() !== after[id]?.toString()) { + try { + core.plugin[id] = after[id]; + core.plugin[id].call(core.plugin); + core.updateStatusBar(true, true); + console.log(`plugin hot reload: ${id}`); + } catch (e) { + console.error(e); + } + } + } + } else if (data === 'functions') { + // 脚本编辑略微麻烦点 + const before = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; + // 这里不能用动态导入,因为动态导入会变成模块,变量就不是全局的了 + const script = document.createElement('script'); + script.src = `/project/functions.js?v=${Date.now()}`; + document.body.appendChild(script); + await new Promise(res => { + script.onload = () => res('success'); + }); + const after = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; + // 找到差异的函数 + for (const mod in before) { + const fns = before[mod]; + for (const id in fns) { + const fn = fns[id]; + if (typeof fn !== 'function' || id === 'hasSpecial') + continue; + const now = after[mod][id]; + if (fn.toString() !== now.toString()) { + try { + if (mod === 'events') { + core.events.eventdata[id] = now; + } else if (mod === 'enemys') { + core.enemys.enemydata[id] = now; + } else if (mod === 'actions') { + core.actions.actionsdata[id] = now; + } else if (mod === 'control') { + core.control.controldata[id] = now; + } else if (mod === 'ui') { + core.ui.uidata[id] = now; + } + core.updateStatusBar(true, true); + console.log( + `function hot reload: ${mod}.${id}` + ); + } catch (e) { + console.error(e); + } + } + } + } + } + } + + /** + * 属性热重载,包括全塔属性等 + * @param {string} data + */ + async function reloadData(data) { + const script = document.createElement('script'); + script.src = `/project/${data}.js?v=${Date.now()}`; + document.body.appendChild(script); + await new Promise(res => { + script.onload = () => res('success'); + }); + + let after; + if (data === 'data') + after = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d; + if (data === 'enemys') + after = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80; + if (data === 'icons') + after = icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1; + if (data === 'items') + after = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a; + if (data === 'maps') + after = maps_90f36752_8815_4be8_b32b_d7fad1d0542e; + if (data === 'events') + after = events_c12a15a8_c380_4b28_8144_256cba95f760; + + if (data === 'enemys') { + core.enemys.enemys = after; + core.material.enemys = core.getEnemys(); + } else if (data === 'icons') { + core.icons.icons = after; + core.material.icons = core.getIcons(); + } else if (data === 'items') { + core.items.items = after; + core.material.items = core.getItems(); + } else if (data === 'maps') { + core.maps.blocksInfo = after; + core.status.mapBlockObjs = {}; + core.status.number2block = {}; + Object.values(core.status.maps).forEach(v => delete v.blocks); + core.extractBlocks(); + core.setWeather( + core.animateFrame.weather.type, + core.animateFrame.weather.level + ); + core.drawMap(); + } else if (data === 'events') { + core.events.commonEvent = after.commonEvent; + } else if (data === 'data') { + location.reload(); + } + core.updateStatusBar(true, true); + console.log(`data hot reload: ${data}`); + } + + // 初始化 + (async function () { + const data = await post('/reload', 'POST', 'test'); + if (data === '@error') { + console.log(`未检测到node服务,热重载插件将无法使用`); + } else { + console.log(`热重载插件加载成功`); + // reload + setInterval(async () => { + const res = await post('/reload', 'POST'); + if (res === '@error') return; + if (res === 'true') location.reload(); + else return; + }, 1000); + + // hot reload + setInterval(async () => { + const res = await post('/hotReload', 'POST'); + const data = res.split('@@'); + data.forEach(v => { + if (v === '') return; + const [type, file] = v.split(':'); + if (type === 'css') reloadCss(file); + if (type === 'data') reloadData(file); + if (type === 'floor') reloadFloor(file); + if (type === 'script') reloadScript(file); + }); + }, 1000); + } + })(); } -} \ No newline at end of file +}; diff --git a/public/想法.md b/public/想法.md deleted file mode 100644 index f70a665..0000000 --- a/public/想法.md +++ /dev/null @@ -1,46 +0,0 @@ -## 怪物 - -### 第二章 智慧 - -- 怪物拥有火、水等属性,在不同天气下属性不同 - -- 同化 -- 同化+阻击 -- 电摇嘲讽:到同行或同列直接怼过去,门和墙撞碎,不消耗钥匙,攻击怪物,捡道具,改变bgm,可吃补给用 -- 抢夺:抢夺你的装备并使用(简单难度中,怪物使用时属性降低) -- 抢夺2.0:抢夺你的道具(怪物手册和楼传除外),并按照左上、右上、右下、左下的顺序依次放到地图的四角(简单无效) -- 抢夺3.0:抢夺装备,但每过10回合便按照2.0方法扔至地图四角(因为怪物觉得装备不好使),然后重新抢夺你的装备(简单无效) -- 天气之子:控制天气,包括下雨、下雪、晴天、阴天等, - -#### Boss - -音游,音乐为一个被遗忘的夜晚,可选简单与困难,困难可获得成就冰与火之舞 - -玩法:一个会转动的圆盘,带有一个伸出去的把手,boss从四面八方射子弹,当子弹恰好落到把手前端时,点击按键或屏幕,可以抵挡子弹,简单难度3条命,困难1条。简单难度音符密度低。困难难度为冰与火之舞的节奏。简单难度判定时间为前后各150ms,困难为75ms - -## 主角 - -- 反抢夺:1级反1.0,2级反2.0,3级反3.0,用智慧点点 -- 学习:学习选定怪物的选定技能(不能学光环),消耗智慧点,初始400,但每次消耗点数+100,持续3场战斗 -- 铸剑为盾:主动技能,减少攻击,增加防御 -- 血之代偿:消耗一定血量,战前对怪物造成同等数值的伤害 - -## 机制 - -### 通用 - -- 实时天气 -- 成就系统 -- 装备合成、装备(孔)强化 - -### 第二章 智慧 - -- 按下一个开关,所有红门变黄门,黄门变蓝门,蓝门变红门 - -## 成就 - -- 学坏了:学习电摇嘲讽 -- 我就是傻子:不学习反抢夺通过第二章 -- 真能刷:勇气之路的刷血怪刷到15w以上的血 -- 满腹经纶:把所有技能都学一遍 -- 冰与火之舞:通过第二章特殊战的困难难度 \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 82b6920..95af9c0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,39 +1,22 @@ - - - - diff --git a/src/components/bookOne.vue b/src/components/bookOne.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/components/boxAnimate.vue b/src/components/boxAnimate.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/components/scroll.vue b/src/components/scroll.vue new file mode 100644 index 0000000..eafcdd0 --- /dev/null +++ b/src/components/scroll.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/src/initPlugin.ts b/src/initPlugin.ts index ba26bf6..b570cd1 100644 --- a/src/initPlugin.ts +++ b/src/initPlugin.ts @@ -1,9 +1,10 @@ // 需要引入所有的插件 -import pop from './plugin/template'; +import pop from './plugin/pop'; +import ui from './plugin/uiController'; window.addEventListener('load', () => { // 每个引入的插件都要在这里执行,否则不会被转发 - const toForward = [pop()]; + const toForward: any[] = [pop(), ui()]; // 初始化所有插件,并转发到core上 (async function () { diff --git a/src/main.ts b/src/main.ts index 84c0113..3b6df23 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,5 @@ import { createApp } from 'vue'; import App from './App.vue'; +import './styles.less'; createApp(App).mount('#root'); diff --git a/src/plugin/template.ts b/src/plugin/pop.ts similarity index 100% rename from src/plugin/template.ts rename to src/plugin/pop.ts diff --git a/src/plugin/uiController.ts b/src/plugin/uiController.ts new file mode 100644 index 0000000..c53f1c3 --- /dev/null +++ b/src/plugin/uiController.ts @@ -0,0 +1,46 @@ +import { Component, markRaw, ref, Ref, watch } from 'vue'; +import Book from '../ui/book.vue'; +import BookDetail from '../ui/bookDetail.vue'; + +export const bookOpened = ref(false); +export const bookDetail = ref(false); + +let app: HTMLDivElement; + +/** ui声明列表 */ +const UI_LIST: [Ref, Component][] = [ + [bookOpened, Book], + [bookDetail, BookDetail] +]; + +/** ui栈 */ +export const uiStack = ref([]); + +export default function init() { + app = document.getElementById('root') as HTMLDivElement; + UI_LIST.forEach(([ref, com]) => { + watch(ref, n => { + if (n === true) { + uiStack.value.push(markRaw(com)); + showApp(); + } else { + const index = uiStack.value.findIndex(v => v === com); + uiStack.value.splice(index); + if (uiStack.value.length === 0) { + hideApp(); + } + } + }); + }); + return { uiStack, bookDetail, bookOpened }; +} + +function showApp() { + app.style.display = 'flex'; + core.lockControl(); +} + +function hideApp() { + app.style.display = 'none'; + core.unlockControl(); +} diff --git a/src/plugin/use.ts b/src/plugin/use.ts new file mode 100644 index 0000000..c071fc1 --- /dev/null +++ b/src/plugin/use.ts @@ -0,0 +1,57 @@ +export default function init() { + return { useDrag, useWheel }; +} + +/** + * 向一个元素添加拖拽事件 + * @param ele 目标元素 + * @param fn 推拽时触发的函数,传入x y和鼠标事件或点击事件 + * @param ondown 鼠标按下时执行的函数 + * @param global 是否全局拖拽,即拖拽后鼠标或手指离开元素后是否依然视为正在拖拽 + */ +export function useDrag( + ele: HTMLElement, + fn: (x: number, y: number, e: MouseEvent | TouchEvent) => void, + ondown?: (x: number, y: number, e: MouseEvent | TouchEvent) => void, + global: boolean = false +) { + let down = false; + ele.addEventListener('mousedown', e => { + down = true; + if (ondown) ondown(e.clientX, e.clientY, e); + }); + ele.addEventListener('touchstart', e => { + down = true; + if (ondown) ondown(e.touches[0].clientX, e.touches[0].clientY, e); + }); + + document.addEventListener('mouseup', () => (down = false)); + document.addEventListener('touchend', () => (down = false)); + + const target = global ? document : ele; + + target.addEventListener('mousemove', e => { + if (!down) return; + const ee = e as MouseEvent; + fn(ee.clientX, ee.clientY, ee); + }); + target.addEventListener('touchmove', e => { + if (!down) return; + const ee = e as TouchEvent; + fn(ee.touches[0].clientX, ee.touches[0].clientY, ee); + }); +} + +/** + * 当触发滚轮时执行函数 + * @param ele 目标元素 + * @param fn 当滚轮触发时执行的函数 + */ +export function useWheel( + ele: HTMLElement, + fn: (x: number, y: number, z: number, e: WheelEvent) => void +): void { + ele.addEventListener('wheel', e => { + fn(e.deltaX, e.deltaY, e.deltaZ, e); + }); +} diff --git a/src/styles.less b/src/styles.less new file mode 100644 index 0000000..8293b1a --- /dev/null +++ b/src/styles.less @@ -0,0 +1,10 @@ +#root { + position: absolute; + display: none; + width: 100%; + height: 100%; + z-index: 9999; + justify-content: center; + align-items: center; + overflow: hidden; +} diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 2b9d1e8..0339b17 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -1,4 +1,4 @@ -type core = { +type Core = { /** 地图的格子宽度 */ readonly _WIDTH_: number; /** 地图的格子高度 */ @@ -186,10 +186,10 @@ type core = { actions & Forward; -type main = { +type Main = { /** 是否在录像验证中 */ readonly replayChecking: boolean; - readonly core: core; + readonly core: Core; readonly dom: { [key: string]: HTMLElement }; /** 游戏版本,发布后会被随机,请勿使用该属性 */ readonly version: string; @@ -313,7 +313,7 @@ declare class Sprite { removeEventListenr: HTMLCanvasElement['addEventListener']; } -declare let main: main; -declare let core: core; -declare let flags: { [x: string]: any }; -declare let hero: HeroStatus; +declare const main: main; +declare const core: Core; +declare const flags: { [x: string]: any }; +declare const hero: HeroStatus; diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index e393480..760f4fb 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -1,5 +1,9 @@ // 这里包含所有插件导出的函数及变量声明,声明的函数会在类型标注中标注到core上 +type Ref = { + value: T; +}; + interface PluginDeclaration { /** * 添加函数 例:添加弹出文字,像这个就可以使用core.addPop或core.plugin.addPop调用 @@ -11,6 +15,39 @@ interface PluginDeclaration { /** 添加变量 例:所有的正在弹出的文字,像这个就可以使用core.plugin.pop获取 */ pop: any[]; + + /** 手册是否打开 */ + readonly bookOpened: Ref; + + /** 手册详细信息 */ + readonly bookDetail: Ref; + + /** ui栈 */ + readonly uiStack: Ref; + + /** + * 向一个元素添加拖拽事件 + * @param ele 目标元素 + * @param fn 推拽时触发的函数,传入x y和鼠标事件或点击事件 + * @param ondown 鼠标按下时执行的函数 + * @param global 是否全局拖拽,即拖拽后鼠标或手指离开元素后是否依然视为正在拖拽 + */ + useDrag( + ele: HTMLElement, + fn: (x: number, y: number, e: MouseEvent | TouchEvent) => void, + ondown?: (x: number, y: number, e: MouseEvent | TouchEvent) => void, + global: boolean = false + ): void; + + /** + * 当触发滚轮时执行函数 + * @param ele 目标元素 + * @param fn 当滚轮触发时执行的函数 + */ + useWheel( + ele: HTMLElement, + fn: (x: number, y: number, z: number, e: WheelEvent) => void + ): void; } type Forward = { diff --git a/src/ui/book.vue b/src/ui/book.vue new file mode 100644 index 0000000..51bc1f6 --- /dev/null +++ b/src/ui/book.vue @@ -0,0 +1,20 @@ + + + + + + + diff --git a/src/ui/bookDetail.vue b/src/ui/bookDetail.vue new file mode 100644 index 0000000..c1888bd --- /dev/null +++ b/src/ui/bookDetail.vue @@ -0,0 +1,7 @@ + + + + + + +