From c18057e9274df5e6cb1e33d46d1174e3ca9f4aac Mon Sep 17 00:00:00 2001 From: strawberry42271 <2806566736@qq.com> Date: Thu, 6 Mar 2025 23:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=98=E6=96=97=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/functions.js | 24 +- project/plugins.js | 3572 +++++++++++++++++++++--------------------- 2 files changed, 1799 insertions(+), 1797 deletions(-) diff --git a/project/functions.js b/project/functions.js index 32d9a29..afd7785 100644 --- a/project/functions.js +++ b/project/functions.js @@ -282,7 +282,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return true; }, - "afterBattle": function (enemyId, x, y) { + "afterBattle": async function (enemyId, x, y) { // 战斗结束后触发的事件 var enemy = core.getEnemyInfo(enemyId, hero, x, y) var special = enemy.special; @@ -295,21 +295,21 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = animate = core.material.items[equipId].equip.animate; // 你也可以在这里根据自己的需要,比如enemyId或special或flag来修改播放的动画效果 // if (enemyId == '...') animate = '...'; + if (core.getFlag('noAnimate')) { + // 检查该动画是否存在SE,如果不存在则使用默认音效 + if (!(core.material.animates[animate] || {}).se) + core.playSound('attack.mp3'); - // 检查该动画是否存在SE,如果不存在则使用默认音效 - if (!(core.material.animates[animate] || {}).se) - 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) || {}; - if (!core.getFlag("noAnimate")) core.attackAnimate( + if (!core.getFlag("noAnimate")) await core.attackAnimate( enemyId, damageInfo.start[0], damageInfo.start[1], diff --git a/project/plugins.js b/project/plugins.js index 40962b4..52a7c11 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -4666,12 +4666,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.events.battle = function () { var hpBeforeBattle = core.status.hero.hp; Dove.MorePerform.ShowDamagePop.OnBattle.apply(core.events, arguments); - Dove.MorePerform.ShowDamagePop.PopDamage( - 'ui', // 默认画布名称 + if (core.getFlag('noAnimate')) Dove.MorePerform.ShowDamagePop.PopDamage( + "ui", // 默认画布名称 core.getHeroLoc('x') * 32, // 英雄位置 x core.getHeroLoc('y') * 32, // 英雄位置 y Math.floor(core.status.hero.hp - hpBeforeBattle), // 伤害值 16, // 默认字体大小 + "Arial", //默认字体 null, // 默认颜色 null, // 默认描边颜色 null, // 默认水平速度 @@ -4679,6 +4680,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = null, // 默认重力 90 // 默认显示时长(帧数) ); + }; let time = 0 // 注册每帧事件 @@ -4716,9 +4718,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = this._font = font ?? "Arial" this._fontColor = fontColor ?? (damage > 0 ? '#22FF44' : 'lightcoral'); // 默认颜色 this._outlineColor = outlineColor ?? '#FFFFFF'; // 默认描边颜色 - this._speedX = speedX ?? (-2 + Math.random() * 3); // 水平速度,默认随机 + this._speedX = speedX ?? (-1 + Math.random() * 2); // 水平速度,默认随机 this._speedY = speedY ?? (-3 - Math.random() * 4); // 垂直速度,默认随机 - this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.5 + this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.3 this._duration = duration ?? 180; // 显示时长(帧数),默认 180 帧 this.initAllMembers(); this.requestCanvas(); @@ -4745,7 +4747,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = // 申请并描绘canvas PopSprite.prototype.requestCanvas = function () { - core.createCanvas(this._symbol, this._x, this._y, this._width, this._height, this._z); + core.createCanvas(this._symbol, this._x, this._y, this._width + 4, this._height + 4, this._z); var canvas = core.getContextByName(this._symbol) canvas.font = this._fontSize + 'px ' + this._font; // 动态设置字体大小 @@ -4762,7 +4764,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = uiContext.font = this._fontSize + 'px ' + this._font; // 动态设置字体大小 var textRect = uiContext.measureText(this._text); this._width = textRect.width + 4; - this._height = this._fontSize * 1.4 + 4; // 动态设置高度 + this._height = this._fontSize + 4; // 动态设置高度 this._z = uiContext.canvas.style.zIndex ? Number(uiContext.canvas.style.zIndex) + PopSprite._count : PopSprite._baseZOrder + PopSprite._count; this._symbol = 'popSprite' + PopSprite._count++; this._alive = true; @@ -13288,1130 +13290,1130 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "楼传": function () { - // 在此增加新插件 + // 在此增加新插件 - core.canMoveFloor = function () { - let canmove = false; - core.status.thisMap.blocks.forEach((block) => { - if ( - !block.disable && - (block.event.id == "upFloor" || block.event.id == "downFloor") - ) { - let automaticRoute = core.automaticRoute(block.x, block.y); - if (!core.flags.flyNearStair || automaticRoute.length > 0) { - let loc = automaticRoute.pop(); - loc = automaticRoute.pop(); - if (core.canMoveDirectly(loc?.x, loc?.y) >= 0 || !loc) { - canmove = true; - } - } - } - }); - return canmove; - }; - ui.prototype._drawViewMaps_drawHint = function () { - core.playSound("打开界面"); - }; + core.canMoveFloor = function () { + let canmove = false; + core.status.thisMap.blocks.forEach((block) => { + if ( + !block.disable && + (block.event.id == "upFloor" || block.event.id == "downFloor") + ) { + let automaticRoute = core.automaticRoute(block.x, block.y); + if (!core.flags.flyNearStair || automaticRoute.length > 0) { + let loc = automaticRoute.pop(); + loc = automaticRoute.pop(); + if (core.canMoveDirectly(loc?.x, loc?.y) >= 0 || !loc) { + canmove = true; + } + } + } + }); + return canmove; + }; + ui.prototype._drawViewMaps_drawHint = function () { + core.playSound("打开界面"); + }; - ////// 绘制浏览地图界面 ////// - ui.prototype._drawViewMaps = function (index, x, y) { - core.lockControl(); + ////// 绘制浏览地图界面 ////// + ui.prototype._drawViewMaps = function (index, x, y) { + core.lockControl(); - core.clearMap("data"); - core.status.event.id = "viewMaps"; - this.clearUI(); - //console.log(index) - if (index == null) index = core.floorIds.indexOf(core.status.floorId); - core.animateFrame.tip = null; - core.status.checkBlock.cache = {}; - let data = this._drawViewMaps_buildData(index, x, y); - core.drawWindowSkin("winskin1.webp", "ui", 0, 0, 416, 416); - let page = core.status.event.data.index; - let floorId = core.status.event.data.floorId; - core.ui.statusBar._update_map(floorId); - const bfs = core.plugin.bfsSearch(floorId, 1, true); - const mapdir = bfs.mapdir[floorId]; - core.setTextAlign("ui", "center"); - let size = (core.__PIXELS__ * 3) / 4; //312 - const areas = core.getFlag("areas"); + core.clearMap("data"); + core.status.event.id = "viewMaps"; + this.clearUI(); + //console.log(index) + if (index == null) index = core.floorIds.indexOf(core.status.floorId); + core.animateFrame.tip = null; + core.status.checkBlock.cache = {}; + let data = this._drawViewMaps_buildData(index, x, y); + core.drawWindowSkin("winskin1.webp", "ui", 0, 0, 416, 416); + let page = core.status.event.data.index; + let floorId = core.status.event.data.floorId; + core.ui.statusBar._update_map(floorId); + const bfs = core.plugin.bfsSearch(floorId, 1, true); + const mapdir = bfs.mapdir[floorId]; + core.setTextAlign("ui", "center"); + let size = (core.__PIXELS__ * 3) / 4; //312 + const areas = core.getFlag("areas"); - let i = areas.findIndex((v) => v.maps.includes(floorId)); - core.fillRoundRect("ui", 15 - 2, 15 - 2, 35 + 4, 35 + 4, 4, "#444444"); - core.strokeRoundRect( - "ui", - 15 - 4, - 15 - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - "当前", - 13 + 20, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); + let i = areas.findIndex((v) => v.maps.includes(floorId)); + core.fillRoundRect("ui", 15 - 2, 15 - 2, 35 + 4, 35 + 4, 4, "#444444"); + core.strokeRoundRect( + "ui", + 15 - 4, + 15 - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + "当前", + 13 + 20, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); - core.fillRoundRect( - "ui", - 15 - 2, - 15 - 2 + 35 + 8 + size + 8 - 54, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 15 - 4 + 35 + 8 + size + 8 - 54, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if ( - !core.status.maps[core.floorIds[page]].canFlyTo || - !core.hasVisitedFloor(core.floorIds[page]) - ) { - core.fillBoldText1( - "ui", - "预览", - 13 + 20, - 17 + 20 + 35 + 8 + size + 8 - 54, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "传送", - 13 + 20, - 17 + 20 + 35 + 8 + size + 8 - 54, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 4 + size - 2 + 45, - 15 - 2 + size - 4 + 45, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 45, - 15 - 4 + size - 4 + 45, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - "离开", - 15 - 4 + size - 4 + 45 + 22, - 15 - 4 + size - 4 + 45 + 26, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); + core.fillRoundRect( + "ui", + 15 - 2, + 15 - 2 + 35 + 8 + size + 8 - 54, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 15 - 4 + 35 + 8 + size + 8 - 54, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if ( + !core.status.maps[core.floorIds[page]].canFlyTo || + !core.hasVisitedFloor(core.floorIds[page]) + ) { + core.fillBoldText1( + "ui", + "预览", + 13 + 20, + 17 + 20 + 35 + 8 + size + 8 - 54, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "传送", + 13 + 20, + 17 + 20 + 35 + 8 + size + 8 - 54, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 4 + size - 2 + 45, + 15 - 2 + size - 4 + 45, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 45, + 15 - 4 + size - 4 + 45, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + "离开", + 15 - 4 + size - 4 + 45 + 22, + 15 - 4 + size - 4 + 45 + 26, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 15 - 2, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 15 - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("up")) { - core.fillBoldText1( - "ui", - "北▲", - 30 + 145 + 10, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "北▲", - 30 + 145 + 10, - 17 + 20, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 15 - 2, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 15 - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("up")) { + core.fillBoldText1( + "ui", + "北▲", + 30 + 145 + 10, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "北▲", + 30 + 145 + 10, + 17 + 20, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2, - 59 - 2, - 35 + 4, - size + 4 - 58, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 59 - 4, - 35 + 8, - size + 8 - 58, - 4, - "#444444", - 1 - ); - if (mapdir.includes("left")) { - core.fillBoldText1( - "ui", - "西", - 15 + 17, - 25 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "◀", - 15 + 17, - 45 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "西", - 15 + 17, - 25 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "◀", - 15 + 17, - 45 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 15 - 2 + size - 4, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 15 - 4 + size - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("down")) { - core.fillBoldText1( - "ui", - "南▼", - 30 + 145 + 10, - 17 + 20 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "南▼", - 30 + 145 + 10, - 17 + 20 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 - 2, + 59 - 2, + 35 + 4, + size + 4 - 58, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 59 - 4, + 35 + 8, + size + 8 - 58, + 4, + "#444444", + 1 + ); + if (mapdir.includes("left")) { + core.fillBoldText1( + "ui", + "西", + 15 + 17, + 25 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "◀", + 15 + 17, + 45 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "西", + 15 + 17, + 25 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "◀", + 15 + 17, + 45 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 15 - 2 + size - 4, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 15 - 4 + size - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("down")) { + core.fillBoldText1( + "ui", + "南▼", + 30 + 145 + 10, + 17 + 20 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "南▼", + 30 + 145 + 10, + 17 + 20 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 59 - 2, - 35 + 4, - size + 4 - 58, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 59 - 4, - 35 + 8, - size + 8 - 58, - 4, - "#444444", - 1 - ); - if (mapdir.includes("right")) { - core.fillBoldText1( - "ui", - "东", - 15 + 17 + size - 4, - 25 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "▶", - 15 + 17 + size - 4, - 45 + 150, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "东", - 15 + 17 + size - 4, - 25 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillBoldText1( - "ui", - "▶", - 15 + 17 + size - 4, - 45 + 150, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 60 - 2, - 60 - 2, - size - 58 + 4, - size - 58 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 60 - 4, - 60 - 4, - size - 58 + 8, - size - 58 + 8, - 4, - "#444444", - 1 - ); - core.drawThumbnail(floorId, null, { - damage: data.damage, - ctx: "ui", - x: 58, - y: 58, - size: 0.62, - all: data.all, - }); - if ( - !core.status.maps[core.floorIds[page]].canFlyTo || - !core.hasVisitedFloor(core.floorIds[page]) - ) { - /*core.fillRect("ui", 58, + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 59 - 2, + 35 + 4, + size + 4 - 58, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 59 - 4, + 35 + 8, + size + 8 - 58, + 4, + "#444444", + 1 + ); + if (mapdir.includes("right")) { + core.fillBoldText1( + "ui", + "东", + 15 + 17 + size - 4, + 25 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "▶", + 15 + 17 + size - 4, + 45 + 150, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "东", + 15 + 17 + size - 4, + 25 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillBoldText1( + "ui", + "▶", + 15 + 17 + size - 4, + 45 + 150, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 60 - 2, + 60 - 2, + size - 58 + 4, + size - 58 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 60 - 4, + 60 - 4, + size - 58 + 8, + size - 58 + 8, + 4, + "#444444", + 1 + ); + core.drawThumbnail(floorId, null, { + damage: data.damage, + ctx: "ui", + x: 58, + y: 58, + size: 0.62, + all: data.all, + }); + if ( + !core.status.maps[core.floorIds[page]].canFlyTo || + !core.hasVisitedFloor(core.floorIds[page]) + ) { + /*core.fillRect("ui", 58, 58, size - 50, size - 50, "rgba(0,0,0,0.5)")*/ - core.getContextByName("ui").globalAlpha = 0.7; + core.getContextByName("ui").globalAlpha = 0.7; - core.drawImage( - "ui", - "miwu.webp", - 0, - 0, - size, - size, - 58, - 58, - size - 50, - size - 50 - ); - core.getContextByName("ui").globalAlpha = 1; - /*core.fillText("ui", '?', 188, + core.drawImage( + "ui", + "miwu.webp", + 0, + 0, + size, + size, + 58, + 58, + size - 50, + size - 50 + ); + core.getContextByName("ui").globalAlpha = 1; + /*core.fillText("ui", '?', 188, 278, "rgba(255,255,255,0.2)", this._buildFont(250, true))*/ - } - core.fillRoundRect( - "ui", - 15 + 44 - 2, - 60 - 2 + size - 4, - size + 4 - 58, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 + 44 - 4, - 60 - 4 + size - 4, - size + 8 - 58, - 35 + 8, - 4, - "#444444", - 1 - ); - core.fillBoldText1( - "ui", - core.status.maps[floorId].areas, - 30 + 145 + 10, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - core.fillRoundRect( - "ui", - 15 - 2, - 60 - 2 + size - 4, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4, - 60 - 4 + size - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (i === 0) { - core.fillBoldText1( - "ui", - "◀", - 30, - 17 + 65 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "◀", - 30, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 60 - 2 + size - 4, - 35 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 60 - 4 + size - 4, - 35 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (i === areas.length - 1) { - core.fillBoldText1( - "ui", - "▶", - 30 + 300 + 10, - 17 + 65 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "▶", - 30 + 300 + 10, - 17 + 65 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } + } + core.fillRoundRect( + "ui", + 15 + 44 - 2, + 60 - 2 + size - 4, + size + 4 - 58, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 + 44 - 4, + 60 - 4 + size - 4, + size + 8 - 58, + 35 + 8, + 4, + "#444444", + 1 + ); + core.fillBoldText1( + "ui", + core.status.maps[floorId].areas, + 30 + 145 + 10, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + core.fillRoundRect( + "ui", + 15 - 2, + 60 - 2 + size - 4, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4, + 60 - 4 + size - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (i === 0) { + core.fillBoldText1( + "ui", + "◀", + 30, + 17 + 65 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "◀", + 30, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 60 - 2 + size - 4, + 35 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 60 - 4 + size - 4, + 35 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (i === areas.length - 1) { + core.fillBoldText1( + "ui", + "▶", + 30 + 300 + 10, + 17 + 65 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "▶", + 30 + 300 + 10, + 17 + 65 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 15 - 2, - 80 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 15 - 4, - 80 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("upFloor")) { - core.fillBoldText1( - "ui", - "上楼", - 30 + 320 + 10, - 17 + 20, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "上楼", - 30 + 320 + 10, - 17 + 20, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4, - 15 - 2 + size - 4, - 80 + 4, - 35 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4, - 15 - 4 + size - 4, - 80 + 8, - 35 + 8, - 4, - "#444444", - 1 - ); - if (mapdir.includes("downFloor")) { - core.fillBoldText1( - "ui", - "下楼", - 30 + 320 + 10, - 17 + 20 + size - 4, - "#FFFFFF", - "#000000", - 2, - this._buildFont(18, true) - ); - } else { - core.fillBoldText1( - "ui", - "下楼", - 30 + 320 + 10, - 17 + 20 + size - 4, - "#909090", - "#000000", - 2, - this._buildFont(18, true) - ); - } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 15 - 2, + 80 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 15 - 4, + 80 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("upFloor")) { + core.fillBoldText1( + "ui", + "上楼", + 30 + 320 + 10, + 17 + 20, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "上楼", + 30 + 320 + 10, + 17 + 20, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4, + 15 - 2 + size - 4, + 80 + 4, + 35 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4, + 15 - 4 + size - 4, + 80 + 8, + 35 + 8, + 4, + "#444444", + 1 + ); + if (mapdir.includes("downFloor")) { + core.fillBoldText1( + "ui", + "下楼", + 30 + 320 + 10, + 17 + 20 + size - 4, + "#FFFFFF", + "#000000", + 2, + this._buildFont(18, true) + ); + } else { + core.fillBoldText1( + "ui", + "下楼", + 30 + 320 + 10, + 17 + 20 + size - 4, + "#909090", + "#000000", + 2, + this._buildFont(18, true) + ); + } - core.fillRoundRect( - "ui", - 15 - 2 + size - 4 + 35 + 8, - 59 - 2, - 37 + 4, - (size - 58) / 2 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 35 + 8, - 59 - 4, - 37 + 8, - (size - 58) / 2 + 8, - 4, - "#444444", - 1 - ); - const title = core.status.maps[floorId].title; - //const length = title.length - fillTextVertical( - "ui", - title, - 15 - 4 + size - 4 + 45, - 85, - core.hasVisitedFloor(floorId) ? "#FFFFFF" : "#444444", - "#000000", - 18 - ); - //const uictx = main.dom.gameCanvas.ui.getContext('2d') - core.fillRoundRect( - "ui", - 15 - 2 + size - 4 + 35 + 8, - 59 - 2 + (size - 58) / 2 + 8, - 37 + 4, - 119 + 4, - 4, - "#444444" - ); - core.strokeRoundRect( - "ui", - 15 - 4 + size - 4 + 35 + 8, - 59 - 4 + (size - 58) / 2 + 8, - 37 + 8, - 119 + 8, - 4, - "#444444", - 1 - ); - if (core.getFlag("showEnemy")) { - fillTextVertical( - "ui", - "关闭漏怪检测", - 15 - 4 + size - 4 + 45, - 220, - "#FFFFFF", - "#000000", - 18 - ); - } else { - fillTextVertical( - "ui", - "开启漏怪检测", - 15 - 4 + size - 4 + 45, - 220, - "#FFFFFF", - "#000000", - 18 - ); - } + core.fillRoundRect( + "ui", + 15 - 2 + size - 4 + 35 + 8, + 59 - 2, + 37 + 4, + (size - 58) / 2 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 35 + 8, + 59 - 4, + 37 + 8, + (size - 58) / 2 + 8, + 4, + "#444444", + 1 + ); + const title = core.status.maps[floorId].title; + //const length = title.length + fillTextVertical( + "ui", + title, + 15 - 4 + size - 4 + 45, + 85, + core.hasVisitedFloor(floorId) ? "#FFFFFF" : "#444444", + "#000000", + 18 + ); + //const uictx = main.dom.gameCanvas.ui.getContext('2d') + core.fillRoundRect( + "ui", + 15 - 2 + size - 4 + 35 + 8, + 59 - 2 + (size - 58) / 2 + 8, + 37 + 4, + 119 + 4, + 4, + "#444444" + ); + core.strokeRoundRect( + "ui", + 15 - 4 + size - 4 + 35 + 8, + 59 - 4 + (size - 58) / 2 + 8, + 37 + 8, + 119 + 8, + 4, + "#444444", + 1 + ); + if (core.getFlag("showEnemy")) { + fillTextVertical( + "ui", + "关闭漏怪检测", + 15 - 4 + size - 4 + 45, + 220, + "#FFFFFF", + "#000000", + 18 + ); + } else { + fillTextVertical( + "ui", + "开启漏怪检测", + 15 - 4 + size - 4 + 45, + 220, + "#FFFFFF", + "#000000", + 18 + ); + } - //uictx.fillTextVertical(title, 15 - 4 + size - 4 + 35 + 29, 25 + 150) - //fillTextVertical('ui', title, 15 - 4 + size - 4 + 35 + 29, 25 + 150, '#FFFFFF', this._buildFont(18, true)) - }; + //uictx.fillTextVertical(title, 15 - 4 + size - 4 + 35 + 29, 25 + 150) + //fillTextVertical('ui', title, 15 - 4 + size - 4 + 35 + 29, 25 + 150, '#FFFFFF', this._buildFont(18, true)) + }; - function fillTextVertical(name, text, x, y, style, boldstyle, fontsize) { - //竖向文字绘制 + function fillTextVertical(name, text, x, y, style, boldstyle, fontsize) { + //竖向文字绘制 - const ctx = core.ui.getContextByName(name); - if (!ctx) return; - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - fontsize *= 3; - const length = text.length; - canvas.width = fontsize * 2; - canvas.height = fontsize * length * 2; - if (style) context.fillStyle = core.arrayToRGBA(style); - if (boldstyle) context.strokeStyle = core.arrayToRGBA(boldstyle); - context.lineWidth = 2; - if (fontsize) context.font = core.ui._buildFont(fontsize, true); - let arrText = text.split(""); + const ctx = core.ui.getContextByName(name); + if (!ctx) return; + const canvas = document.createElement("canvas"); + const context = canvas.getContext("2d"); + fontsize *= 3; + const length = text.length; + canvas.width = fontsize * 2; + canvas.height = fontsize * length * 2; + if (style) context.fillStyle = core.arrayToRGBA(style); + if (boldstyle) context.strokeStyle = core.arrayToRGBA(boldstyle); + context.lineWidth = 2; + if (fontsize) context.font = core.ui._buildFont(fontsize, true); + let arrText = text.split(""); - let arrWidth = arrText.map(function (letter) { - return context.measureText(letter).width; - }); + let arrWidth = arrText.map(function (letter) { + return context.measureText(letter).width; + }); - let align = context.textAlign; + let align = context.textAlign; - let baseline = context.textBaseline; - let sx = fontsize, - sy = fontsize * length; - if (align == "left") { - sx = sx + Math.max.apply(null, arrWidth) / 2; - } else if (align == "right") { - sx = sx - Math.max.apply(null, arrWidth) / 2; - } + let baseline = context.textBaseline; + let sx = fontsize, + sy = fontsize * length; + if (align == "left") { + sx = sx + Math.max.apply(null, arrWidth) / 2; + } else if (align == "right") { + sx = sx - Math.max.apply(null, arrWidth) / 2; + } - if ( - baseline == "bottom" || - baseline == "alphabetic" || - baseline == "ideographic" - ) { - sy = sy - arrWidth[0] / 2; - } else if (baseline == "top" || baseline == "hanging") { - sy = sy + arrWidth[0] / 2; - } + if ( + baseline == "bottom" || + baseline == "alphabetic" || + baseline == "ideographic" + ) { + sy = sy - arrWidth[0] / 2; + } else if (baseline == "top" || baseline == "hanging") { + sy = sy + arrWidth[0] / 2; + } - context.textAlign = "center"; + context.textAlign = "center"; - context.textBaseline = "middle"; - context.lineWidth = 6; + context.textBaseline = "middle"; + context.lineWidth = 6; - // 开始逐字绘制 + // 开始逐字绘制 - arrText.forEach(function (letter, index) { - // 确定下一个字符的纵坐标位置 + arrText.forEach(function (letter, index) { + // 确定下一个字符的纵坐标位置 - context.strokeText(letter, sx, sy); - context.fillText(letter, sx, sy); - // 旋转坐标系还原成初始态 + context.strokeText(letter, sx, sy); + context.fillText(letter, sx, sy); + // 旋转坐标系还原成初始态 - context.setTransform(1, 0, 0, 1, 0, 0); + context.setTransform(1, 0, 0, 1, 0, 0); - // 确定下一个字符的纵坐标位置 + // 确定下一个字符的纵坐标位置 - var letterWidth = 54; + var letterWidth = 54; - sy = sy + letterWidth; - }); + sy = sy + letterWidth; + }); - // 水平垂直对齐方式还原 + // 水平垂直对齐方式还原 - context.textAlign = align; + context.textAlign = align; - context.textBaseline = baseline; + context.textBaseline = baseline; - //绘制到目标位置 - ctx.drawImage( - canvas, - x, - y - (fontsize / 3) * length, - canvas.width / 3, - canvas.height / 3 - ); - } + //绘制到目标位置 + ctx.drawImage( + canvas, + x, + y - (fontsize / 3) * length, + canvas.width / 3, + canvas.height / 3 + ); + } - ////// 点击楼层传送器时的打开操作 ////// - events.prototype.useFly = function (fromUserAction) { - if (!core.isPlaying()) return; - if (!core.status.maps[core.status.floorId].canFlyFrom) { - core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); - return; - } - // 从“浏览地图”页面:尝试直接传送到该层 - if (core.status.event.id == "viewMaps") { - if (!core.hasItem("fly")) { - core.playSound("操作失败"); - core.drawTip("你没有" + core.material.items["fly"].name, "fly"); - } else if ( - core.flags.flyNearStair && - !core.nearStair() && - !flags.canMoveFloor - ) { - core.playSound("操作失败"); - core.drawTip( - "无法到达楼梯边使用" + core.material.items["fly"].name, - "fly" - ); - } else { - core.flyTo(core.status.event.data.floorId); - core.updateStatusBar(); - } - return; - } + ////// 点击楼层传送器时的打开操作 ////// + events.prototype.useFly = function (fromUserAction) { + if (!core.isPlaying()) return; + if (!core.status.maps[core.status.floorId].canFlyFrom) { + core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); + return; + } + // 从“浏览地图”页面:尝试直接传送到该层 + if (core.status.event.id == "viewMaps") { + if (!core.hasItem("fly")) { + core.playSound("操作失败"); + core.drawTip("你没有" + core.material.items["fly"].name, "fly"); + } else if ( + core.flags.flyNearStair && + !core.nearStair() && + !flags.canMoveFloor + ) { + core.playSound("操作失败"); + core.drawTip( + "无法到达楼梯边使用" + core.material.items["fly"].name, + "fly" + ); + } else { + core.flyTo(core.status.event.data.floorId); + core.updateStatusBar(); + } + return; + } - if (!this._checkStatus("fly", fromUserAction, true)) return; - //if (core.flags.flyNearStair && !core.nearStair()) + if (!this._checkStatus("fly", fromUserAction, true)) return; + //if (core.flags.flyNearStair && !core.nearStair()) - if ( - (core.flags.flyNearStair && !core.nearStair()) || - !flags.canMoveFloor - ) { - core.playSound("操作失败"); - core.drawTip( - "无法到达楼梯边使用" + core.material.items["fly"].name, - "fly" - ); - core.unlockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - if (!core.canUseItem("fly")) { - core.playSound("操作失败"); - core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); - core.unlockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - core.playSound("打开界面"); - core.useItem("fly", true); - core.updateStatusBar(); - return; - }; - ////// 系统菜单栏界面时的点击操作 ////// - actions.prototype._clickSettings = function (x, y) { - if (this._out(x)) return; - var choices = core.status.event.ui.choices; - var topIndex = this._getChoicesTopIndex(choices.length); - if (y >= topIndex && y < topIndex + choices.length) { - var selection = y - topIndex; - core.status.event.selection = selection; - switch (selection) { - case 0: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawSwitchs(); - break; - case 1: - // core.playSound('确定'); - core.ui._drawKeyBoard(); - break; - case 2: - // core.playSound('确定'); - core.clearUI(); - core.useItem("fly"); - break; - case 3: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawNotes(); - break; - case 4: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawSyncSave(); - break; - case 5: - core.status.event.selection = 0; - core.playSound("确定"); - core.ui._drawGameInfo(); - break; - case 6: - return core.confirmRestart(); - case 7: - core.playSound("取消"); - core.ui.closePanel(); - break; - } - } - return; - }; - ////// 查看地图界面时的点击操作 ////// - actions.prototype._clickViewMaps = function (x, y, px, py) { - if (core.status.event.data == null) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - return; - } - let now = core.floorIds.indexOf(core.status.floorId); - let index = core.status.event.data.index; - let cx = core.status.event.data.x, - cy = core.status.event.data.y; - let floorId = core.floorIds[index], - mw = core.floors[floorId].width, - mh = core.floors[floorId].height; - let perpx = core.__PIXELS__ / 5, - cornerpx = (perpx * 3) / 4; - const bfs = core.plugin.bfsSearch(floorId, 1, true); - const mapdir = bfs.mapdir[floorId]; - const res = bfs.res; - const formto = {}; - for (let from in res) { - const to = res[from]; - const [fromfloorId, fromsx, fromsy, dir] = from.split("_"); - const [tofloorId, tosx, tosy] = to.split("_"); - if (!formto[fromfloorId]) formto[fromfloorId] = {}; - if (!formto[fromfloorId][dir]) formto[fromfloorId][dir] = tofloorId; - } - const areas = core.getFlag("areas"); - let i = areas.findIndex((v) => v.maps.includes(floorId)); + if ( + (core.flags.flyNearStair && !core.nearStair()) || + !flags.canMoveFloor + ) { + core.playSound("操作失败"); + core.drawTip( + "无法到达楼梯边使用" + core.material.items["fly"].name, + "fly" + ); + core.unlockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + if (!core.canUseItem("fly")) { + core.playSound("操作失败"); + core.drawTip(core.material.items["fly"].name + "好像失效了", "fly"); + core.unlockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + core.playSound("打开界面"); + core.useItem("fly", true); + core.updateStatusBar(); + return; + }; + ////// 系统菜单栏界面时的点击操作 ////// + actions.prototype._clickSettings = function (x, y) { + if (this._out(x)) return; + var choices = core.status.event.ui.choices; + var topIndex = this._getChoicesTopIndex(choices.length); + if (y >= topIndex && y < topIndex + choices.length) { + var selection = y - topIndex; + core.status.event.selection = selection; + switch (selection) { + case 0: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawSwitchs(); + break; + case 1: + // core.playSound('确定'); + core.ui._drawKeyBoard(); + break; + case 2: + // core.playSound('确定'); + core.clearUI(); + core.useItem("fly"); + break; + case 3: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawNotes(); + break; + case 4: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawSyncSave(); + break; + case 5: + core.status.event.selection = 0; + core.playSound("确定"); + core.ui._drawGameInfo(); + break; + case 6: + return core.confirmRestart(); + case 7: + core.playSound("取消"); + core.ui.closePanel(); + break; + } + } + return; + }; + ////// 查看地图界面时的点击操作 ////// + actions.prototype._clickViewMaps = function (x, y, px, py) { + if (core.status.event.data == null) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + return; + } + let now = core.floorIds.indexOf(core.status.floorId); + let index = core.status.event.data.index; + let cx = core.status.event.data.x, + cy = core.status.event.data.y; + let floorId = core.floorIds[index], + mw = core.floors[floorId].width, + mh = core.floors[floorId].height; + let perpx = core.__PIXELS__ / 5, + cornerpx = (perpx * 3) / 4; + const bfs = core.plugin.bfsSearch(floorId, 1, true); + const mapdir = bfs.mapdir[floorId]; + const res = bfs.res; + const formto = {}; + for (let from in res) { + const to = res[from]; + const [fromfloorId, fromsx, fromsy, dir] = from.split("_"); + const [tofloorId, tosx, tosy] = to.split("_"); + if (!formto[fromfloorId]) formto[fromfloorId] = {}; + if (!formto[fromfloorId][dir]) formto[fromfloorId][dir] = tofloorId; + } + const areas = core.getFlag("areas"); + let i = areas.findIndex((v) => v.maps.includes(floorId)); - if (px >= 11 && px <= 54 && py >= 11 && py <= 54) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - } else if (px >= 362 && px <= 407 && py >= 191 && py <= 318) { - flags.showEnemy = !flags.showEnemy; - core.ui._drawViewMaps(index); - } else if (px >= 364 && px <= 407 && py >= 364 && py <= 407) { - core.clearMap("data"); - core.playSound("取消"); - core.ui.closePanel(); - core.getItemDetail(); - core.redrawMap(); - core.updateStatusBar(); - core.ui.statusBar._update_map(); - return; - } else if (px >= 55 && px <= 317 && py >= 11 && py <= 54) { - if (mapdir.includes("up")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].up)); - } else if (px >= 55 && px <= 317 && py >= 319 && py <= 362) { - if (mapdir.includes("down")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].down)); - } else if (px >= 11 && px <= 54 && py >= 55 && py <= 317) { - if (mapdir.includes("left")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].left)); - } else if (px >= 319 && px <= 362 && py >= 55 && py <= 317) { - if (mapdir.includes("right")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].right)); - } else if (px >= 319 && px <= 407 && py >= 11 && py <= 54) { - if (mapdir.includes("upFloor")) - core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].upFloor)); - } else if (px >= 319 && px <= 407 && py >= 319 && py <= 362) { - if (mapdir.includes("downFloor")) - core.ui._drawViewMaps( - core.floorIds.indexOf(formto[floorId].downFloor) - ); - } else if ( - px >= 55 && - px <= 317 && - py >= 55 && - py <= 317 && - core.isPlaying() - ) { - core.useFly(false); - return; - } else if (px >= 11 && px <= 54 && py >= 364 && py <= 407) { - if (i > 0) { - i -= 1; - core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); - } - } else if (px >= 319 && px <= 362 && py >= 364 && py <= 407) { - if (i < areas.length - 1) { - i += 1; - core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); - } - } - }; - const replayAction_fly = function (action) { - //楼层传送的录像操作 - if (action.indexOf("fly:") != 0) return false; - var floorId = action.substring(4); - var toIndex = core.floorIds.indexOf(floorId); - if ( - !core.canUseItem("fly") || - (core.flags.flyNearStair && !core.nearStair() && !flags.canMoveFloor) - ) - return false; - core.ui._drawViewMaps(toIndex); - if (core.status.replay.speed == 24) { - if (!core.flyTo(floorId, core.replay)) - core.control._replay_error(action); - return true; - } - setTimeout(function () { - if (!core.flyTo(floorId, core.replay)) - core.control._replay_error(action); - }, core.control.__replay_getTimeout()); - return true; - }; - core.registerReplayAction("fly", replayAction_fly); - ////// 查看地图界面时,放开某个键的操作 ////// + if (px >= 11 && px <= 54 && py >= 11 && py <= 54) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + } else if (px >= 362 && px <= 407 && py >= 191 && py <= 318) { + flags.showEnemy = !flags.showEnemy; + core.ui._drawViewMaps(index); + } else if (px >= 364 && px <= 407 && py >= 364 && py <= 407) { + core.clearMap("data"); + core.playSound("取消"); + core.ui.closePanel(); + core.getItemDetail(); + core.redrawMap(); + core.updateStatusBar(); + core.ui.statusBar._update_map(); + return; + } else if (px >= 55 && px <= 317 && py >= 11 && py <= 54) { + if (mapdir.includes("up")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].up)); + } else if (px >= 55 && px <= 317 && py >= 319 && py <= 362) { + if (mapdir.includes("down")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].down)); + } else if (px >= 11 && px <= 54 && py >= 55 && py <= 317) { + if (mapdir.includes("left")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].left)); + } else if (px >= 319 && px <= 362 && py >= 55 && py <= 317) { + if (mapdir.includes("right")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].right)); + } else if (px >= 319 && px <= 407 && py >= 11 && py <= 54) { + if (mapdir.includes("upFloor")) + core.ui._drawViewMaps(core.floorIds.indexOf(formto[floorId].upFloor)); + } else if (px >= 319 && px <= 407 && py >= 319 && py <= 362) { + if (mapdir.includes("downFloor")) + core.ui._drawViewMaps( + core.floorIds.indexOf(formto[floorId].downFloor) + ); + } else if ( + px >= 55 && + px <= 317 && + py >= 55 && + py <= 317 && + core.isPlaying() + ) { + core.useFly(false); + return; + } else if (px >= 11 && px <= 54 && py >= 364 && py <= 407) { + if (i > 0) { + i -= 1; + core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); + } + } else if (px >= 319 && px <= 362 && py >= 364 && py <= 407) { + if (i < areas.length - 1) { + i += 1; + core.ui._drawViewMaps(core.floorIds.indexOf(areas[i].maps[0])); + } + } + }; + const replayAction_fly = function (action) { + //楼层传送的录像操作 + if (action.indexOf("fly:") != 0) return false; + var floorId = action.substring(4); + var toIndex = core.floorIds.indexOf(floorId); + if ( + !core.canUseItem("fly") || + (core.flags.flyNearStair && !core.nearStair() && !flags.canMoveFloor) + ) + return false; + core.ui._drawViewMaps(toIndex); + if (core.status.replay.speed == 24) { + if (!core.flyTo(floorId, core.replay)) + core.control._replay_error(action); + return true; + } + setTimeout(function () { + if (!core.flyTo(floorId, core.replay)) + core.control._replay_error(action); + }, core.control.__replay_getTimeout()); + return true; + }; + core.registerReplayAction("fly", replayAction_fly); + ////// 查看地图界面时,放开某个键的操作 ////// - actions.prototype._keyUpViewMaps = function (keycode) { - if (core.status.event.data == null) { - core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); - return; - } - var floorId = core.floorIds[core.status.event.data.index]; + actions.prototype._keyUpViewMaps = function (keycode) { + if (core.status.event.data == null) { + core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId)); + return; + } + var floorId = core.floorIds[core.status.event.data.index]; - if (keycode == 27 || keycode == 71) { - core.clearMap("data"); - core.playSound("取消"); - core.ui.closePanel(); - core.getItemDetail(); - core.redrawMap(); - core.ui.statusBar._update_map(); - core.updateStatusBar(); - return; - } + if (keycode == 27 || keycode == 71) { + core.clearMap("data"); + core.playSound("取消"); + core.ui.closePanel(); + core.getItemDetail(); + core.redrawMap(); + core.ui.statusBar._update_map(); + core.updateStatusBar(); + return; + } - if (keycode == 86) { - core.status.event.data.damage = !core.status.event.data.damage; - core.playSound("光标移动"); - core.ui._drawViewMaps(core.status.event.data); - return; - } - if (keycode == 66 || keycode == 88) { - if (core.isReplaying()) { - core.control._replay_book(); - } else { - core.openBook(false); - } - return; - } - if ( - (keycode == 13 || keycode == 32 || keycode == 67) && - !core.isReplaying() - ) { - core.useFly(false); - return; - } - return; - }; - actions.prototype._keyDownViewMaps = function (keycode) { - if (core.status.event.data == null) return; + if (keycode == 86) { + core.status.event.data.damage = !core.status.event.data.damage; + core.playSound("光标移动"); + core.ui._drawViewMaps(core.status.event.data); + return; + } + if (keycode == 66 || keycode == 88) { + if (core.isReplaying()) { + core.control._replay_book(); + } else { + core.openBook(false); + } + return; + } + if ( + (keycode == 13 || keycode == 32 || keycode == 67) && + !core.isReplaying() + ) { + core.useFly(false); + return; + } + return; + }; + actions.prototype._keyDownViewMaps = function (keycode) { + if (core.status.event.data == null) return; - var floorId = core.floorIds[core.status.event.data.index], - mh = core.floors[floorId].height; + var floorId = core.floorIds[core.status.event.data.index], + mh = core.floors[floorId].height; - if (keycode == 39) this._clickViewMaps(9, 1, 330, 250); - if (keycode == 37) this._clickViewMaps(9, 8, 25, 200); - if (keycode == 40) this._clickViewMaps(9, 6, 250, 330); - if (keycode == 38) this._clickViewMaps(9, 3, 200, 25); - if (keycode == 34) this._clickViewMaps(9, 3, 350, 330); - if (keycode == 33) this._clickViewMaps(9, 3, 350, 25); - return; - }; + if (keycode == 39) this._clickViewMaps(9, 1, 330, 250); + if (keycode == 37) this._clickViewMaps(9, 8, 25, 200); + if (keycode == 40) this._clickViewMaps(9, 6, 250, 330); + if (keycode == 38) this._clickViewMaps(9, 3, 200, 25); + if (keycode == 34) this._clickViewMaps(9, 3, 350, 330); + if (keycode == 33) this._clickViewMaps(9, 3, 350, 25); + return; + }; - actions.prototype._sys_onmousewheel = function (direct) { - // 向下滚动是 -1 ,向上是 1 + actions.prototype._sys_onmousewheel = function (direct) { + // 向下滚动是 -1 ,向上是 1 - if (this._checkReplaying()) { - // 滚轮控制速度 - if (direct == 1) core.speedUpReplay(); - if (direct == -1) core.speedDownReplay(); - return; - } + if (this._checkReplaying()) { + // 滚轮控制速度 + if (direct == 1) core.speedUpReplay(); + if (direct == -1) core.speedDownReplay(); + return; + } - // 楼层飞行器 - if (core.status.lockControl && core.status.event.id == "fly") { - if (direct == 1) core.ui.drawFly(this._getNextFlyFloor(1)); - if (direct == -1) core.ui.drawFly(this._getNextFlyFloor(-1)); - return; - } + // 楼层飞行器 + if (core.status.lockControl && core.status.event.id == "fly") { + if (direct == 1) core.ui.drawFly(this._getNextFlyFloor(1)); + if (direct == -1) core.ui.drawFly(this._getNextFlyFloor(-1)); + return; + } - // 怪物手册 - if (core.status.lockControl && core.status.event.id == "book") { - var pageinfo = core.ui._drawBook_pageinfo(); - if (direct == 1) - core.ui.drawBook(core.status.event.data - pageinfo.per_page); - if (direct == -1) - core.ui.drawBook(core.status.event.data + pageinfo.per_page); - return; - } + // 怪物手册 + if (core.status.lockControl && core.status.event.id == "book") { + var pageinfo = core.ui._drawBook_pageinfo(); + if (direct == 1) + core.ui.drawBook(core.status.event.data - pageinfo.per_page); + if (direct == -1) + core.ui.drawBook(core.status.event.data + pageinfo.per_page); + return; + } - // 存读档 - if ( - core.status.lockControl && - (core.status.event.id == "save" || core.status.event.id == "load") - ) { - var index = - core.status.event.data.page * 10 + core.status.event.data.offset; - if (direct == 1) core.ui._drawSLPanel(index - 10); - if (direct == -1) core.ui._drawSLPanel(index + 10); - return; - } + // 存读档 + if ( + core.status.lockControl && + (core.status.event.id == "save" || core.status.event.id == "load") + ) { + var index = + core.status.event.data.page * 10 + core.status.event.data.offset; + if (direct == 1) core.ui._drawSLPanel(index - 10); + if (direct == -1) core.ui._drawSLPanel(index + 10); + return; + } - // 浏览地图 - if (core.status.lockControl && core.status.event.id == "viewMaps") { - let floorId = core.floorIds[core.status.event.data.index]; - if (!flags.__visited__[floorId]) floorId = core.status.floorId; - const visit = Object.keys(flags.__visited__); - let index = visit.indexOf(floorId); - if (direct == 1) { - if (index > 0) - core.ui._drawViewMaps(core.floorIds.indexOf(visit[index - 1])); - } - if (direct == -1) { - if (index < visit.length - 1) - core.ui._drawViewMaps(core.floorIds.indexOf(visit[index + 1])); - } - return; - } + // 浏览地图 + if (core.status.lockControl && core.status.event.id == "viewMaps") { + let floorId = core.floorIds[core.status.event.data.index]; + if (!flags.__visited__[floorId]) floorId = core.status.floorId; + const visit = Object.keys(flags.__visited__); + let index = visit.indexOf(floorId); + if (direct == 1) { + if (index > 0) + core.ui._drawViewMaps(core.floorIds.indexOf(visit[index - 1])); + } + if (direct == -1) { + if (index < visit.length - 1) + core.ui._drawViewMaps(core.floorIds.indexOf(visit[index + 1])); + } + return; + } - // wait事件 - if ( - core.status.lockControl && - core.status.event.id == "action" && - core.status.event.data.type == "wait" - ) { - var timeout = - Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; - core.setFlag("type", 0); - var keycode = direct == 1 ? 33 : 34; - core.setFlag("keycode", keycode); - core.setFlag("timeout", timeout); - var executed = core.events.__action_wait_afterGet( - core.status.event.data.current - ); - if (executed || !core.status.event.data.current.forceChild) { - core.status.route.push("input:" + (1e8 * timeout + keycode)); - clearTimeout(core.status.event.interval); - delete core.status.event.timeout; - core.doAction(); - } - return; - } - }; - core.registerAction( - "onmousewheel", - "_sys_onmousewheel", - actions.prototype._sys_onmousewheel, - 0 - ); - }, + // wait事件 + if ( + core.status.lockControl && + core.status.event.id == "action" && + core.status.event.data.type == "wait" + ) { + var timeout = + Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; + core.setFlag("type", 0); + var keycode = direct == 1 ? 33 : 34; + core.setFlag("keycode", keycode); + core.setFlag("timeout", timeout); + var executed = core.events.__action_wait_afterGet( + core.status.event.data.current + ); + if (executed || !core.status.event.data.current.forceChild) { + core.status.route.push("input:" + (1e8 * timeout + keycode)); + clearTimeout(core.status.event.interval); + delete core.status.event.timeout; + core.doAction(); + } + return; + } + }; + core.registerAction( + "onmousewheel", + "_sys_onmousewheel", + actions.prototype._sys_onmousewheel, + 0 + ); +}, "CG回廊": function () { // 在此增加新插件 const CGUI = document.createElement("canvas"); //CGui画布设置 @@ -20861,699 +20863,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }) } - core.plugin.battle_onclick = function (x, y, px, py) { - const makeBox = ([x, y], [w, h]) => { - return [ - [x, y], - [x + w, y + h], - ]; - }; - const inRect = ([x, y], [ - [sx, sy], - [dx, dy] - ]) => { - return sx <= x && x <= dx && sy <= y && y <= dy; - }; - const pos = [px, py]; - const easybox = makeBox([90, 212], [80, 22]), - easyclosebox = makeBox([290, 212], [40, 22]), - uneasybox = makeBox([265, 310], [65, 20]), - uneasyclosebox = makeBox([290, 330], [40, 20]); - if (inRect(pos, easybox) && easy) { - easy = false - } else if (inRect(pos, uneasybox) && !easy) { - easy = true - } else if ((inRect(pos, easyclosebox) && easy) || (inRect(pos, uneasyclosebox) && !easy)) { - core.status.event.id = '' - core.unregisterAnimationFrame("attackAnimate") - core.clearMap(ctx) - core.closePanel() - } - } - let turn = 0 + main.dom.gameDraw.appendChild(animateAttack); const { lcm, gcd } = core.plugin.utils - this.drawAttackAnimate = async function ( - heroInfo, - oneTurn, - enemyInfo, - equipInfo, - farme, - onegcd, - heroDiffList, - enemyDiffList, - heroanimateList, - enemyanimateList, - - ) { - core.lockControl() - core.status.event.id = 'battle' - - let attack = false; - if (heroInfo.isAttack) attack = true; - if (enemyInfo.isAttack) attack = true; - equipInfo.forEach(function (v) { - if (v.isAttack) attack = true; - }); - let onattack = false; - if (heroInfo.onAttack) onattack = true; - if (enemyInfo.onAttack) onattack = true; - equipInfo.forEach(function (v) { - if (v.onAttack) onattack = true; - }); - core.clearMap(ctx); - let animate = Math.floor(farme / 30); - if (easy) { - core.fillRect(ctx, 64, 64, 288, 180, "rgba(0,0,0,0.5)"); - core.strokeRect(ctx, 64, 64, 288, 180, "rgba(255,255,255,0.5)", 4); - core.setTextAlign(ctx, "center"); - core.fillBoldText( - ctx, - hero.name, - 127, - 128, - "#FFFFFF", - "#000000", - "bold 14px Verdana" - ); - core.setTextAlign(ctx, "left"); - core.drawIcon(ctx, "hp", 70, 190, 16, 16); - core.fillBoldText( - ctx, - "生命 " + core.formatBigNumber(heroInfo.hp, true), - 90, - 205, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - - core.fillBoldText( - ctx, - "详细模式", - 90, - 230, - "#FFFF60", - "#000000", - "bold 18px Verdana" - ); - - - core.strokeRect(ctx, 112, 139, 32, 48, "rgba(255,255,255,1)", 1); - let img = attack && (heroDiffList[turn].hp < 0) ? imagelighter(core.material.images.images["hero.webp"]) : attack && (heroDiffList[turn].hp > 0) ? imagelighter(core.material.images.images["hero.webp"], 'rgba(0, 255, 0, 0.5)') : core.material.images.images["hero.webp"] - core.drawImage( - ctx, - img, - 32 * (animate % 4), - 0, - 32, - 48, - 112, - 139, - 32, - 48 - ); - - core.setTextAlign(ctx, "center"); - core.fillBoldText( - ctx, - enemyInfo.name, - 289, - 128, - "#FFFFFF", - "#000000", - "bold 14px Verdana" - ); - - core.setTextAlign(ctx, "right"); - if (enemyInfo.cls === "enemys") { - core.strokeRect(ctx, 272, 155, 32, 32, "rgba(255,255,255,1)", 1); - let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image - core.drawImage( - ctx, - img, - 32 * (animate % 2), - core.getBlockInfo(enemyInfo.id).posY * 32, - 32, - 32, - 272, - 155, - 32, - 32 - ); - } else { - core.strokeRect(ctx, 272, 139, 32, 48, "rgba(255,255,255,1)", 1); - let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image - core.drawImage( - ctx, - img, - 32 * (animate % 4), - core.getBlockInfo(enemyInfo.id).posY * 48, - 32, - 48, - 272, - 139, - 32, - 48 - ); - } - core.drawIcon(ctx, "hp", 330, 190, 16, 16); - - core.fillBoldText( - ctx, - core.formatBigNumber(enemyInfo.hp, true) + " 生命", - 330, - 205, - "#FFFFFF", - "#000000", - "bold 14px Verdana" - ); - core.fillBoldText( - ctx, - "跳过", - 330, - 230, - "#FFFF60", - "#000000", - "bold 18px Verdana" - ); - - core.fillBoldText( - ctx, - "V", - 219, - 163, - "#FFFFFF", - "#000000", - "bold 48px pala" - ); - core.fillBoldText( - ctx, - "s", - 231, - 163, - "#FFFFFF", - "#000000", - "bold 36px pala" - ); - - if (!attack && !onattack) enemyInfo.now += enemyInfo.speed / onegcd; - let enemynow = Math.min(100 + enemyInfo.now / oneTurn * 215, 315); - ctx.fillStyle = "#FFFFFF"; - ctx.beginPath(); - ctx.moveTo(enemynow, 100); - ctx.lineTo(enemynow + 5, 90); - ctx.lineTo(enemynow - 5, 90); - ctx.closePath(); - ctx.fill(); - - if (enemyInfo.cls === "enemys") { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 32, - 32, - 32, - enemynow - 16, - 64, - 32, - 32 - ); - } else { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 48, - 32, - 19, - enemynow - 16, - 70, - 32, - 19 - ); - } - core.drawLine(ctx, 100, 105, 315, 105, "#FFFFFF", 5); - equipInfo.forEach(function (v) { - if (!attack && !onattack) v.now += v.speed / onegcd; - let vnow = Math.min(100 + v.now / oneTurn * 215, 315); - ctx.beginPath(); - ctx.moveTo(vnow, 100); - ctx.lineTo(vnow + 5, 90); - ctx.lineTo(vnow - 5, 90); - ctx.closePath(); - - ctx.fill(); - - core.drawIcon(ctx, v.id, vnow - 16, 64, 32, 32); - }); - if (!attack && !onattack) heroInfo.now += hero.speed / onegcd; - let heronow = Math.min(100 + heroInfo.now / oneTurn * 215, 315); - ctx.beginPath(); - ctx.moveTo(heronow, 100); - ctx.lineTo(heronow + 5, 90); - ctx.lineTo(heronow - 5, 90); - ctx.closePath(); - - ctx.fill(); - core.drawImage(ctx, "hero.webp", 0, 0, 32, 19, heronow - 16, 70, 32, 19); - } else { - core.fillRect(ctx, 64, 64, 288, 288, "rgba(0,0,0,0.5)"); - core.strokeRect(ctx, 64, 64, 288, 288, "rgba(255,255,255,0.5)", 4); - core.setTextAlign(ctx, "center"); - core.fillBoldText( - ctx, - hero.name, - 127, - 128, - "#FFFFFF", - "#000000", - "bold 14px Verdana" - ); - core.setTextAlign(ctx, "left"); - core.drawIcon(ctx, "hp", 70, 190, 16, 16); - core.drawIcon(ctx, "atk", 70, 210, 16, 16); - core.drawIcon(ctx, "def", 70, 230, 16, 16); - core.drawIcon(ctx, "I374", 70, 250, 16, 16); - core.drawIcon(ctx, "I375", 70, 270, 16, 16); - core.drawIcon(ctx, "mdef", 70, 290, 16, 16); - core.drawIcon(ctx, "amulet", 70, 310, 16, 16); - core.drawIcon(ctx, "jumpShoes", 70, 330, 16, 16); - core.fillBoldText( - ctx, - "生命 " + core.formatBigNumber(heroInfo.hp, true), - 90, - 205, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - - core.fillBoldText( - ctx, - "攻击 " + core.formatBigNumber(heroInfo.atk), - 90, - 225, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "防御 " + core.formatBigNumber(heroInfo.def), - 90, - 245, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "法强 " + core.formatBigNumber(heroInfo.spell), - 90, - 265, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "法攻 " + - core.formatBigNumber(heroInfo.matk), - 90, - 285, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "护盾 " + - core.formatBigNumber(heroInfo.mhp), - 90, - 305, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "法抗 " + heroInfo.mdef + "%", - 90, - 325, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "速度 " + core.formatBigNumber(heroInfo.speed), - 90, - 345, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - - core.strokeRect(ctx, 112, 139, 32, 48, "rgba(255,255,255,1)", 1); - let img = attack && (heroDiffList[turn].hp < 0) ? imagelighter(core.material.images.images["hero.webp"]) : attack && (heroDiffList[turn].hp > 0) ? imagelighter(core.material.images.images["hero.webp"], 'rgba(0, 255, 0, 0.5)') : core.material.images.images["hero.webp"] - core.drawImage( - ctx, - img, - 32 * (animate % 4), - 0, - 32, - 48, - 112, - 139, - 32, - 48 - ); - - core.setTextAlign(ctx, "center"); - core.fillBoldText( - ctx, - enemyInfo.name, - 289, - 128, - "#FFFFFF", - "#000000", - "bold 14px Verdana" - ); - - core.setTextAlign(ctx, "right"); - if (enemyInfo.cls === "enemys") { - core.strokeRect(ctx, 272, 155, 32, 32, "rgba(255,255,255,1)", 1); - let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image - core.drawImage( - ctx, - img, - 32 * (animate % 2), - core.getBlockInfo(enemyInfo.id).posY * 32, - 32, - 32, - 272, - 155, - 32, - 32 - ); - } else { - core.strokeRect(ctx, 272, 139, 32, 48, "rgba(255,255,255,1)", 1); - let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image - core.drawImage( - ctx, - img, - 32 * (animate % 4), - core.getBlockInfo(enemyInfo.id).posY * 48, - 32, - 48, - 272, - 139, - 32, - 48 - ); - } - core.drawIcon(ctx, "hp", 330, 190, 16, 16); - core.drawIcon(ctx, "atk", 330, 210, 16, 16); - core.drawIcon(ctx, "def", 330, 230, 16, 16); - core.drawIcon(ctx, "I374", 330, 250, 16, 16); - core.drawIcon(ctx, "amulet", 330, 270, 16, 16); - core.drawIcon(ctx, "jumpShoes", 330, 290, 16, 16); - core.fillBoldText( - ctx, - core.formatBigNumber(enemyInfo.hp, true) + " 生命", - 330, - 205, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - core.formatBigNumber(enemyInfo.atk) + " 攻击", - 330, - 225, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - core.formatBigNumber(enemyInfo.def) + " 防御", - 330, - 245, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - (enemyInfo.spell ?? 0) + " 法qi强", - 330, - 265, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - (enemyInfo.mdef ?? 0) * 100 + "% 法抗", - 330, - 285, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - core.formatBigNumber(enemyInfo.speed) + " 速度", - 330, - 305, - "#FFFFFF", - "#000000", - "bold 14px Arial" - ); - core.fillBoldText( - ctx, - "简易模式", - 330, - 325, - "#FFFF60", - "#000000", - "bold 16px Verdana" - ); - core.fillBoldText( - ctx, - "跳过", - 330, - 345, - "#FFFF60", - "#000000", - "bold 16px Verdana" - ); - - core.fillBoldText( - ctx, - "V", - 219, - 163, - "#FFFFFF", - "#000000", - "bold 48px pala" - ); - core.fillBoldText( - ctx, - "s", - 231, - 163, - "#FFFFFF", - "#000000", - "bold 36px pala" - ); - - if (!attack && !onattack) enemyInfo.now += enemyInfo.speed / onegcd; - let enemynow = Math.min(100 + enemyInfo.now / oneTurn * 215, 315); - ctx.fillStyle = "#FFFFFF"; - ctx.beginPath(); - ctx.moveTo(enemynow, 100); - ctx.lineTo(enemynow + 5, 90); - ctx.lineTo(enemynow - 5, 90); - ctx.closePath(); - ctx.fill(); - - if (enemyInfo.cls === "enemys") { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 32, - 32, - 32, - enemynow - 16, - 64, - 32, - 32 - ); - } else { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 48, - 32, - 19, - enemynow - 16, - 70, - 32, - 19 - ); - } - core.drawLine(ctx, 100, 105, 315, 105, "#FFFFFF", 5); - equipInfo.forEach(function (v) { - if (!attack && !onattack) v.now += v.speed / onegcd; - let vnow = Math.min(100 + v.now / oneTurn * 215, 315); - ctx.beginPath(); - ctx.moveTo(vnow, 100); - ctx.lineTo(vnow + 5, 90); - ctx.lineTo(vnow - 5, 90); - ctx.closePath(); - - ctx.fill(); - - core.drawIcon(ctx, v.id, vnow - 16, 64, 32, 32); - }); - if (!attack && !onattack) heroInfo.now += hero.speed / onegcd; - let heronow = Math.min(100 + heroInfo.now / oneTurn * 215, 315); - ctx.beginPath(); - ctx.moveTo(heronow, 100); - ctx.lineTo(heronow + 5, 90); - ctx.lineTo(heronow - 5, 90); - ctx.closePath(); - - ctx.fill(); - core.drawImage(ctx, "hero.webp", 0, 0, 32, 19, heronow - 16, 70, 32, 19); - } - let nowattacking = false - if (heroInfo.now >= oneTurn && !heroInfo.isAttack) { - heroInfo.onattack = false - heroInfo.isAttack = true; - nowattacking = true - - } - if (enemyInfo.now >= oneTurn && !enemyInfo.isAttack) { - enemyInfo.onattack = false - enemyInfo.isAttack = true; - nowattacking = true - - } - const equipanimate = [] - equipInfo.forEach(v => { - if (v.now >= oneTurn && !v.isAttack) { - v.isAttack = true; - v.onattack = false - nowattacking = true - equipanimate.push(v) - - } - }); - if (!attack && nowattacking) { - - let herodamage = enemyDiffList[turn].hp - let text = herodamage === 0 ? "抵抗" : herodamage - if (enemyDiffList[turn].attack) Dove.MorePerform.ShowDamagePop.PopDamage( - ctx, // 默认画布名称 - 270, // 英雄位置 x - 140, // 英雄位置 y - text, // 伤害值 - 18, // 默认字体大小 - "Arial", //默认字体 - null, // 默认颜色 - null, // 默认描边颜色 - 0, // 默认水平速度 - -1, // 默认垂直速度 - 0, // 默认重力 - 90 // 默认显示时长(帧数) - ); - for (const v in enemyDiffList[turn]) { - enemyInfo[v] += enemyDiffList[turn][v] - } - enemyanimateList[turn].forEach(v => animateOnAttack(v, true)) - const enemydamage = heroDiffList[turn].hp - text = enemydamage === 0 ? "抵抗" : enemydamage - if (heroDiffList[turn].attack) Dove.MorePerform.ShowDamagePop.PopDamage( - ctx, // 默认画布名称 - 110, // 英雄位置 x - 140, // 英雄位置 y - text, // 伤害值 - 18, // 默认字体大小 - "Arial", //默认字体 - null, // 默认颜色 - null, // 默认描边颜色 - 0, // 默认水平速度 - -1, // 默认垂直速度 - 0, // 默认重力 - 90 // 默认显示时长(帧数) - ); - for (const v in heroDiffList[turn]) { - heroInfo[v] += heroDiffList[turn][v] - } - heroanimateList[turn].forEach(v => animateOnAttack(v, false)) - - if (enemyDiffList[turn] < 0) enemyInfo.inAttack = true - if (heroDiffList[turn] < 0) heroInfo.inAttack = true - if (heroInfo.hp < 0) heroInfo.hp = 0 - if (enemyInfo.hp < 0) enemyInfo.hp = 0 - await Promise.all([await playinganimate(), - new Promise(resolve => { - if (heroInfo.isAttack) { - heroInfo.now = 0; - heroInfo.isAttack = false; - } - resolve() - }), - new Promise(resolve => { - if (enemyInfo.isAttack) { - enemyInfo.now = 0; - enemyInfo.isAttack = false; - } - resolve() - }), - new Promise(resolve => { - if (equipanimate.length > 0) { - equipanimate.forEach(v => { - v.now = 0; - v.isAttack = false; - }) - } - resolve() - }), - new Promise(resolve => { - turn++ - resolve() - }) - ]) - - - - if (heroInfo.hp <= 0 || enemyInfo.hp <= 0) { - core.status.event.id = '' - core.unregisterAnimationFrame("attackAnimate") - core.clearMap(ctx) - core.closePanel() - - } - } - } - - function animateOnAttack(name, onenemy) { if (onenemy) { - playanimate(name, 290, 160); + playanimate(name, 290, 180); } else { - playanimate(name, 130, 160); + playanimate(name, 130, 180); } } @@ -21573,7 +20892,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.lockControl(); core.clearMap(ctx); core.status.event.id = "attackAnimate"; - turn = 0 + let turn = 0 enemyInfo.id = enemyId; enemyInfo.cls = core.getClsFromId(enemyId); enemyInfo.name = core.material.enemys[enemyId].name; @@ -21581,28 +20900,711 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (oneTurn < 120) oneTurn *= Math.round(120 / oneTurn) let time = 0, farme = 0; - - core.registerAnimationFrame("attackAnimate", true, (temptime) => { - if (temptime - time > 1000 / 60) { - time = temptime; - this.drawAttackAnimate( - heroInfo, - oneTurn, - enemyInfo, - equipInfo, - farme, - onegcd, - heroDiffList, - enemyDiffList, - heroanimateList, - enemyanimateList - ); - - - farme++; + return new Promise(res => { + core.plugin.battle_onclick = function (x, y, px, py) { + const makeBox = ([x, y], [w, h]) => { + return [ + [x, y], + [x + w, y + h], + ]; + }; + const inRect = ([x, y], [ + [sx, sy], + [dx, dy] + ]) => { + return sx <= x && x <= dx && sy <= y && y <= dy; + }; + const pos = [px, py]; + const easybox = makeBox([90, 232], [80, 22]), + easyclosebox = makeBox([290, 232], [40, 22]), + uneasybox = makeBox([265, 330], [65, 20]), + uneasyclosebox = makeBox([290, 350], [40, 20]); + if (inRect(pos, easybox) && easy) { + easy = false + } else if (inRect(pos, uneasybox) && !easy) { + easy = true + } else if ((inRect(pos, easyclosebox) && easy) || (inRect(pos, uneasyclosebox) && !easy)) { + core.status.event.id = '' + core.unregisterAnimationFrame("attackAnimate") + core.clearMap(ctx) + core.closePanel() + res() + } } - }); + async function drawAttackAnimate( + heroInfo, + oneTurn, + enemyInfo, + equipInfo, + farme, + onegcd, + heroDiffList, + enemyDiffList, + heroanimateList, + enemyanimateList, + ) { + core.lockControl() + core.status.event.id = 'battle' + + let attack = false; + if (heroInfo.isAttack) attack = true; + if (enemyInfo.isAttack) attack = true; + equipInfo.forEach(function (v) { + if (v.isAttack) attack = true; + }); + let onattack = false; + if (heroInfo.onAttack) onattack = true; + if (enemyInfo.onAttack) onattack = true; + equipInfo.forEach(function (v) { + if (v.onAttack) onattack = true; + }); + core.clearMap(ctx); + let animate = Math.floor(farme / 30); + if (easy) { + core.fillRect(ctx, 64, 52, 288, 212, "rgba(0,0,0,0.5)"); + core.strokeRect(ctx, 64, 52, 288, 212, "rgba(255,255,255,0.5)", 4); + core.setTextAlign(ctx, "center"); + core.fillBoldText( + ctx, + hero.name, + 127, + 148, + "#FFFFFF", + "#000000", + "bold 14px Verdana" + ); + core.setTextAlign(ctx, "left"); + core.drawIcon(ctx, "hp", 70, 210, 16, 16); + core.fillBoldText( + ctx, + "生命 " + core.formatBigNumber(heroInfo.hp, true), + 90, + 225, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + + core.fillBoldText( + ctx, + "详细模式", + 90, + 250, + "#FFFF60", + "#000000", + "bold 18px Verdana" + ); + + + core.strokeRect(ctx, 112, 159, 32, 48, "rgba(255,255,255,1)", 1); + let img = attack && (heroDiffList[turn].hp < 0) ? imagelighter(core.material.images.images["hero.webp"]) : attack && (heroDiffList[turn].hp > 0) ? imagelighter(core.material.images.images["hero.webp"], 'rgba(0, 255, 0, 0.5)') : core.material.images.images["hero.webp"] + core.drawImage( + ctx, + img, + 32 * (animate % 4), + 0, + 32, + 48, + 112, + 159, + 32, + 48 + ); + + core.setTextAlign(ctx, "center"); + core.fillBoldText( + ctx, + enemyInfo.name, + 289, + 148, + "#FFFFFF", + "#000000", + "bold 14px Verdana" + ); + + core.setTextAlign(ctx, "right"); + if (enemyInfo.cls === "enemys") { + core.strokeRect(ctx, 272, 175, 32, 32, "rgba(255,255,255,1)", 1); + let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image + core.drawImage( + ctx, + img, + 32 * (animate % 2), + core.getBlockInfo(enemyInfo.id).posY * 32, + 32, + 32, + 272, + 175, + 32, + 32 + ); + } else { + core.strokeRect(ctx, 272, 159, 32, 48, "rgba(255,255,255,1)", 1); + let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image + core.drawImage( + ctx, + img, + 32 * (animate % 4), + core.getBlockInfo(enemyInfo.id).posY * 48, + 32, + 48, + 272, + 159, + 32, + 48 + ); + } + core.drawIcon(ctx, "hp", 330, 210, 16, 16); + + core.fillBoldText( + ctx, + core.formatBigNumber(enemyInfo.hp, true) + " 生命", + 330, + 225, + "#FFFFFF", + "#000000", + "bold 14px Verdana" + ); + core.fillBoldText( + ctx, + "跳过", + 330, + 250, + "#FFFF60", + "#000000", + "bold 18px Verdana" + ); + + core.fillBoldText( + ctx, + "V", + 219, + 183, + "#FFFFFF", + "#000000", + "bold 48px pala" + ); + core.fillBoldText( + ctx, + "s", + 231, + 183, + "#FFFFFF", + "#000000", + "bold 36px pala" + ); + + if (!attack && !onattack) enemyInfo.now += enemyInfo.speed / onegcd; + let enemynow = Math.min(100 + enemyInfo.now / oneTurn * 215, 315); + ctx.fillStyle = "#FFFFFF"; + ctx.beginPath(); + ctx.moveTo(enemynow, 120); + ctx.lineTo(enemynow + 5, 110); + ctx.lineTo(enemynow - 5, 110); + ctx.closePath(); + ctx.fill(); + + if (enemyInfo.cls === "enemys") { + core.drawImage( + ctx, + core.getBlockInfo(enemyInfo.id).image, + 32, + core.getBlockInfo(enemyInfo.id).posY * 32, + 32, + 32, + enemynow - 16, + 74, + 32, + 32 + ); + } else { + core.drawImage( + ctx, + core.getBlockInfo(enemyInfo.id).image, + 32, + core.getBlockInfo(enemyInfo.id).posY * 48, + 32, + 48, + enemynow - 16, + 58, + 32, + 48 + ); + } + core.drawLine(ctx, 100, 125, 315, 125, "#FFFFFF", 5); + equipInfo.forEach(function (v) { + if (!attack && !onattack) v.now += v.speed / onegcd; + let vnow = Math.min(100 + v.now / oneTurn * 215, 315); + ctx.beginPath(); + ctx.moveTo(vnow, 120); + ctx.lineTo(vnow + 5, 110); + ctx.lineTo(vnow - 5, 110); + ctx.closePath(); + + ctx.fill(); + + core.drawIcon(ctx, v.id, vnow - 16, 54, 32, 32); + }); + if (!attack && !onattack) heroInfo.now += hero.speed / onegcd; + let heronow = Math.min(100 + heroInfo.now / oneTurn * 215, 315); + ctx.beginPath(); + ctx.moveTo(heronow, 120); + ctx.lineTo(heronow + 5, 110); + ctx.lineTo(heronow - 5, 110); + ctx.closePath(); + + ctx.fill(); + core.drawImage(ctx, "hero.webp", 0, 0, 32, 48, heronow - 16, 58, 32, 48); + } else { + core.fillRect(ctx, 64, 52, 288, 320, "rgba(0,0,0,0.5)"); + core.strokeRect(ctx, 64, 52, 288, 320, "rgba(255,255,255,0.5)", 4); + core.setTextAlign(ctx, "center"); + core.fillBoldText( + ctx, + hero.name, + 127, + 148, + "#FFFFFF", + "#000000", + "bold 14px Verdana" + ); + core.setTextAlign(ctx, "left"); + core.drawIcon(ctx, "hp", 70, 210, 16, 16); + core.drawIcon(ctx, "atk", 70, 230, 16, 16); + core.drawIcon(ctx, "def", 70, 250, 16, 16); + core.drawIcon(ctx, "I374", 70, 270, 16, 16); + core.drawIcon(ctx, "I375", 70, 290, 16, 16); + core.drawIcon(ctx, "mdef", 70, 310, 16, 16); + core.drawIcon(ctx, "amulet", 70, 330, 16, 16); + core.drawIcon(ctx, "jumpShoes", 70, 350, 16, 16); + core.fillBoldText( + ctx, + "生命 " + core.formatBigNumber(heroInfo.hp, true), + 90, + 225, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + + core.fillBoldText( + ctx, + "攻击 " + core.formatBigNumber(heroInfo.atk), + 90, + 245, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "防御 " + core.formatBigNumber(heroInfo.def), + 90, + 265, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "法强 " + core.formatBigNumber(heroInfo.spell), + 90, + 285, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "法攻 " + + core.formatBigNumber(heroInfo.matk), + 90, + 305, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "护盾 " + + core.formatBigNumber(heroInfo.mhp), + 90, + 325, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "法抗 " + heroInfo.mdef + "%", + 90, + 345, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "速度 " + core.formatBigNumber(heroInfo.speed), + 90, + 365, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + + core.strokeRect(ctx, 112, 159, 32, 48, "rgba(255,255,255,1)", 1); + let img = attack && (heroDiffList[turn].hp < 0) ? imagelighter(core.material.images.images["hero.webp"]) : attack && (heroDiffList[turn].hp > 0) ? imagelighter(core.material.images.images["hero.webp"], 'rgba(0, 255, 0, 0.5)') : core.material.images.images["hero.webp"] + core.drawImage( + ctx, + img, + 32 * (animate % 4), + 0, + 32, + 48, + 112, + 159, + 32, + 48 + ); + + core.setTextAlign(ctx, "center"); + core.fillBoldText( + ctx, + enemyInfo.name, + 289, + 148, + "#FFFFFF", + "#000000", + "bold 14px Verdana" + ); + + core.setTextAlign(ctx, "right"); + if (enemyInfo.cls === "enemys") { + core.strokeRect(ctx, 272, 175, 32, 32, "rgba(255,255,255,1)", 1); + let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image + core.drawImage( + ctx, + img, + 32 * (animate % 2), + core.getBlockInfo(enemyInfo.id).posY * 32, + 32, + 32, + 272, + 175, + 32, + 32 + ); + } else { + core.strokeRect(ctx, 272, 159, 32, 48, "rgba(255,255,255,1)", 1); + let img = attack && (enemyDiffList[turn].hp < 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image) : attack && (enemyDiffList[turn].hp > 0) ? imagelighter(core.getBlockInfo(enemyInfo.id).image, 'rgba(0, 255, 0, 0.5)') : core.getBlockInfo(enemyInfo.id).image + core.drawImage( + ctx, + img, + 32 * (animate % 4), + core.getBlockInfo(enemyInfo.id).posY * 48, + 32, + 48, + 272, + 159, + 32, + 48 + ); + } + core.drawIcon(ctx, "hp", 330, 210, 16, 16); + core.drawIcon(ctx, "atk", 330, 230, 16, 16); + core.drawIcon(ctx, "def", 330, 250, 16, 16); + core.drawIcon(ctx, "I374", 330, 270, 16, 16); + core.drawIcon(ctx, "amulet", 330, 290, 16, 16); + core.drawIcon(ctx, "jumpShoes", 330, 310, 16, 16); + core.fillBoldText( + ctx, + core.formatBigNumber(enemyInfo.hp, true) + " 生命", + 330, + 225, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + core.formatBigNumber(enemyInfo.atk) + " 攻击", + 330, + 245, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + core.formatBigNumber(enemyInfo.def) + " 防御", + 330, + 265, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + (enemyInfo.spell ?? 0) + " 法qi强", + 330, + 285, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + (enemyInfo.mdef ?? 0) * 100 + "% 法抗", + 330, + 305, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + core.formatBigNumber(enemyInfo.speed) + " 速度", + 330, + 325, + "#FFFFFF", + "#000000", + "bold 14px Arial" + ); + core.fillBoldText( + ctx, + "简易模式", + 330, + 345, + "#FFFF60", + "#000000", + "bold 16px Verdana" + ); + core.fillBoldText( + ctx, + "跳过", + 330, + 365, + "#FFFF60", + "#000000", + "bold 16px Verdana" + ); + + core.fillBoldText( + ctx, + "V", + 219, + 183, + "#FFFFFF", + "#000000", + "bold 48px pala" + ); + core.fillBoldText( + ctx, + "s", + 231, + 183, + "#FFFFFF", + "#000000", + "bold 36px pala" + ); + + if (!attack && !onattack) enemyInfo.now += enemyInfo.speed / onegcd; + let enemynow = Math.min(100 + enemyInfo.now / oneTurn * 215, 315); + ctx.fillStyle = "#FFFFFF"; + ctx.beginPath(); + ctx.moveTo(enemynow, 120); + ctx.lineTo(enemynow + 5, 110); + ctx.lineTo(enemynow - 5, 110); + ctx.closePath(); + ctx.fill(); + + if (enemyInfo.cls === "enemys") { + core.drawImage( + ctx, + core.getBlockInfo(enemyInfo.id).image, + 32, + core.getBlockInfo(enemyInfo.id).posY * 32, + 32, + 32, + enemynow - 16, + 74, + 32, + 32 + ); + } else { + core.drawImage( + ctx, + core.getBlockInfo(enemyInfo.id).image, + 32, + core.getBlockInfo(enemyInfo.id).posY * 48, + 32, + 19, + enemynow - 16, + 58, + 32, + 48 + ); + } + core.drawLine(ctx, 100, 125, 315, 125, "#FFFFFF", 5); + equipInfo.forEach(function (v) { + if (!attack && !onattack) v.now += v.speed / onegcd; + let vnow = Math.min(100 + v.now / oneTurn * 215, 315); + ctx.beginPath(); + ctx.moveTo(vnow, 120); + ctx.lineTo(vnow + 5, 110); + ctx.lineTo(vnow - 5, 110); + ctx.closePath(); + + ctx.fill(); + + core.drawIcon(ctx, v.id, vnow - 16, 54, 32, 32); + }); + if (!attack && !onattack) heroInfo.now += hero.speed / onegcd; + let heronow = Math.min(100 + heroInfo.now / oneTurn * 215, 315); + ctx.beginPath(); + ctx.moveTo(heronow, 120); + ctx.lineTo(heronow + 5, 110); + ctx.lineTo(heronow - 5, 110); + ctx.closePath(); + + ctx.fill(); + core.drawImage(ctx, "hero.webp", 0, 0, 32, 48, heronow - 16, 58, 32, 48); + } + let nowattacking = false + if (heroInfo.now >= oneTurn && !heroInfo.isAttack) { + heroInfo.onattack = false + heroInfo.isAttack = true; + nowattacking = true + + } + if (enemyInfo.now >= oneTurn && !enemyInfo.isAttack) { + enemyInfo.onattack = false + enemyInfo.isAttack = true; + nowattacking = true + + } + const equipanimate = [] + equipInfo.forEach(v => { + if (v.now >= oneTurn && !v.isAttack) { + v.isAttack = true; + v.onattack = false + nowattacking = true + equipanimate.push(v) + + } + }); + if (!attack && nowattacking) { + + let herodamage = enemyDiffList[turn].hp + let text = herodamage === 0 ? "抵抗" : herodamage + Dove.MorePerform.ShowDamagePop.PopDamage( + ctx, // 默认画布名称 + 270, // 英雄位置 x + 160, // 英雄位置 y + text, // 伤害值 + 18, // 默认字体大小 + "Arial", //默认字体 + null, // 默认颜色 + null, // 默认描边颜色 + 0, // 默认水平速度 + -1, // 默认垂直速度 + 0, // 默认重力 + 90 // 默认显示时长(帧数) + ); + for (const v in enemyDiffList[turn]) { + enemyInfo[v] += enemyDiffList[turn][v] + } + enemyanimateList[turn].forEach(v => animateOnAttack(v, true)) + const enemydamage = heroDiffList[turn].hp + text = enemydamage === 0 ? "抵抗" : enemydamage + Dove.MorePerform.ShowDamagePop.PopDamage( + ctx, // 默认画布名称 + 110, // 英雄位置 x + 160, // 英雄位置 y + text, // 伤害值 + 18, // 默认字体大小 + "Arial", //默认字体 + null, // 默认颜色 + null, // 默认描边颜色 + 0, // 默认水平速度 + -1, // 默认垂直速度 + 0, // 默认重力 + 90 // 默认显示时长(帧数) + ); + for (const v in heroDiffList[turn]) { + heroInfo[v] += heroDiffList[turn][v] + } + heroanimateList[turn].forEach(v => animateOnAttack(v, false)) + + if (enemyDiffList[turn] < 0) enemyInfo.inAttack = true + if (heroDiffList[turn] < 0) heroInfo.inAttack = true + if (heroInfo.hp < 0) heroInfo.hp = 0 + if (enemyInfo.hp < 0) enemyInfo.hp = 0 + await Promise.all([await playinganimate(), + new Promise(resolve => { + if (heroInfo.isAttack) { + heroInfo.now = 0; + heroInfo.isAttack = false; + } + resolve() + }), + new Promise(resolve => { + if (enemyInfo.isAttack) { + enemyInfo.now = 0; + enemyInfo.isAttack = false; + } + resolve() + }), + new Promise(resolve => { + if (equipanimate.length > 0) { + equipanimate.forEach(v => { + v.now = 0; + v.isAttack = false; + }) + } + resolve() + }), + new Promise(resolve => { + turn++ + resolve() + }) + ]) + + + + if (heroInfo.hp <= 0 || enemyInfo.hp <= 0) { + core.status.event.id = '' + core.unregisterAnimationFrame("attackAnimate") + core.clearMap(ctx) + core.closePanel() + res() + + } + } + } + core.registerAnimationFrame("attackAnimate", true, (temptime) => { + if (temptime - time > 1000 / 60) { + time = temptime; + drawAttackAnimate( + heroInfo, + oneTurn, + enemyInfo, + equipInfo, + farme, + onegcd, + heroDiffList, + enemyDiffList, + heroanimateList, + enemyanimateList + ); + + + farme++; + } + }); + }) } }, "剧情内容": function () {