From 59c3b46cfc8f5a2783a4e45e8a93692c0dd5a461 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sun, 21 Apr 2024 15:45:06 +0800 Subject: [PATCH] =?UTF-8?q?feat=20&=20fix:=20=E5=B0=8F=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=89=A9=E4=BD=99=E6=80=AA=E7=89=A9=20&=20id?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 1 + public/project/floors/MT22.js | 2 +- public/project/floors/MT42.js | 2 +- src/components/box.vue | 4 ++-- src/components/boxAnimate.vue | 4 ++-- src/components/colomn.vue | 4 ++-- src/components/minimap.vue | 33 +++++++++++++++++++++++++++++++++ src/components/scroll.vue | 3 ++- src/core/main/custom/toolbar.ts | 9 +++++++++ src/core/main/init/toolbar.tsx | 11 +++++++++++ src/game/index.ts | 7 ++++--- src/game/system.ts | 4 +++- src/plugin/ui/fly.ts | 16 ++++++++++++++++ src/plugin/utils.ts | 5 +++++ src/ui/fly.vue | 1 + 15 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 src/components/minimap.vue diff --git a/components.d.ts b/components.d.ts index 1b525e2..49dd79b 100644 --- a/components.d.ts +++ b/components.d.ts @@ -19,6 +19,7 @@ declare module '@vue/runtime-core' { BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default'] Colomn: typeof import('./src/components/colomn.vue')['default'] EnemyOne: typeof import('./src/components/enemyOne.vue')['default'] + Minimap: typeof import('./src/components/minimap.vue')['default'] Scroll: typeof import('./src/components/scroll.vue')['default'] } } diff --git a/public/project/floors/MT22.js b/public/project/floors/MT22.js index 44c5739..6628806 100644 --- a/public/project/floors/MT22.js +++ b/public/project/floors/MT22.js @@ -40,7 +40,7 @@ main.floors.MT22= "第二章的加点已开启,可以在技能树的前置技能下方选择", "如果你玩过上个版本,直接跳到了本章,记得查看背包里面的各种道具,尤其是百科全书,同时注意左边是你来的方向,那里还有些怪物", "从现在开始,跳跃技能不再消耗生命值,别忘了你还有跳跃技能", - "为了确保平衡与可玩性,从现在开始,无上之盾(第一章终极技能)效果变为1/10" + "为了确保平衡与可玩性,从现在开始,无上之盾(第一章终极技能)效果变为1/10,同时每个怪物的最大吸血量限制为攻防和" ], "7,9": [ "百科全书中已解锁第二章需要特别说明的怪物属性,你可以在百科全书中查看", diff --git a/public/project/floors/MT42.js b/public/project/floors/MT42.js index 393219c..28b6b83 100644 --- a/public/project/floors/MT42.js +++ b/public/project/floors/MT42.js @@ -135,7 +135,7 @@ main.floors.MT42= [584,584,584,584,420,491,430,584,602, 0,492,604,604,643,586], [584, 0, 0,584,584,468,585,585, 0, 28,604, 27,604,441,586], [ 0, 0, 0,584,584,497,585,585, 0, 0,600,403,494, 0, 94], - [ 0, 0, 0,584,584, 93,585,585, 93,584,584,584,584,584,584] + [ 0, 0, 0,584, 0, 93, 0,585, 93,584,584,584,584,584,584] ], "bgmap": [ [70073,70073, 0,70073,70073,70073,70073,70073,70073,70073,70073,70073,70073,70097,70073], diff --git a/src/components/box.vue b/src/components/box.vue index 01844f6..bfc8704 100644 --- a/src/components/box.vue +++ b/src/components/box.vue @@ -46,7 +46,7 @@ import { onMounted, onUnmounted, onUpdated, ref, watch } from 'vue'; import { DragOutlined } from '@ant-design/icons-vue'; import { isMobile, useDrag, cancelGlobalDrag } from '../plugin/use'; -import { has } from '../plugin/utils'; +import { has, requireUniqueSymbol } from '../plugin/utils'; import { sleep } from 'mutate-animate'; const props = defineProps<{ @@ -65,7 +65,7 @@ const emits = defineEmits<{ (e: 'update:height', data: number): void; }>(); -const id = (1e8 * Math.random()).toFixed(0); +const id = requireUniqueSymbol().toFixed(0); const moveSelected = ref(false); let moveTimeout = 0; diff --git a/src/components/boxAnimate.vue b/src/components/boxAnimate.vue index ebe1e4c..26a68cc 100644 --- a/src/components/boxAnimate.vue +++ b/src/components/boxAnimate.vue @@ -9,9 +9,9 @@ + + diff --git a/src/components/scroll.vue b/src/components/scroll.vue index 3ad37e5..d33a0fd 100644 --- a/src/components/scroll.vue +++ b/src/components/scroll.vue @@ -13,6 +13,7 @@ import { sleep } from 'mutate-animate'; import { onMounted, onUnmounted, onUpdated } from 'vue'; import { cancelGlobalDrag, useDrag, useWheel } from '../plugin/use'; +import { requireUniqueSymbol } from '@/plugin/utils'; let main: HTMLDivElement; @@ -34,7 +35,7 @@ const emits = defineEmits<{ let now = 0; let total = 0; -const id = (1e8 * Math.random()).toFixed(0); +const id = requireUniqueSymbol().toFixed(0); const scale = window.devicePixelRatio; const width = props.width ?? 20; diff --git a/src/core/main/custom/toolbar.ts b/src/core/main/custom/toolbar.ts index 745d318..64212a8 100644 --- a/src/core/main/custom/toolbar.ts +++ b/src/core/main/custom/toolbar.ts @@ -46,10 +46,19 @@ interface AssistKeyToolbarItem extends ToolbarItemBase<'assistKey'> { assist: KeyCode.Ctrl | KeyCode.Shift | KeyCode.Alt; } +interface MinimatToolbar extends ToolbarItemBase<'minimap'> { + action: boolean; + scale: number; + noBorder: boolean; + showInfo: boolean; + autoLocate: boolean; +} + interface ToolbarItemMap { hotkey: HotkeyToolbarItem; item: ItemToolbarItem; assistKey: AssistKeyToolbarItem; + minimap: MinimatToolbar; } interface ToolbarSaveData { diff --git a/src/core/main/init/toolbar.tsx b/src/core/main/init/toolbar.tsx index fa918ae..c620640 100644 --- a/src/core/main/init/toolbar.tsx +++ b/src/core/main/init/toolbar.tsx @@ -9,6 +9,7 @@ import { getVitualKeyOnce } from '@/plugin/utils'; import { cloneDeep } from 'lodash-es'; import { Select, SelectOption } from 'ant-design-vue'; import { mainSetting } from '../setting'; +import Minimap from '@/components/minimap.vue'; // todo: 新增更改设置的ToolItem @@ -88,6 +89,16 @@ function AssistKeyTool(props: CustomToolbarProps<'assistKey'>) { ); } +function MinimapToolbar(props: CustomToolbarProps<'minimap'>) { + const { item, toolbar } = props; + + return ( +
+ +
+ ); +} + function DefaultToolEditor(props: CustomToolbarProps) { return ; } diff --git a/src/game/index.ts b/src/game/index.ts index 44a2aff..509314a 100644 --- a/src/game/index.ts +++ b/src/game/index.ts @@ -1,6 +1,6 @@ import './system'; import '../plugin/game/index'; -import { DamageEnemy, EnemyCollection } from './enemy/damage'; +import * as damage from './enemy/damage'; import { EventEmitter, IndexedEventEmitter } from '@/core/common/eventEmitter'; import { Range } from '@/plugin/game/range'; import { specials } from './enemy/special'; @@ -9,8 +9,8 @@ import * as battle from './enemy/battle'; import * as hero from './hero'; // ----- 类注册 -Mota.register('class', 'DamageEnemy', DamageEnemy); -Mota.register('class', 'EnemyCollection', EnemyCollection); +Mota.register('class', 'DamageEnemy', damage.DamageEnemy); +Mota.register('class', 'EnemyCollection', damage.EnemyCollection); Mota.register('class', 'EventEmitter', EventEmitter); Mota.register('class', 'IndexedEventEmitter', IndexedEventEmitter); Mota.register('class', 'Range', Range); @@ -18,6 +18,7 @@ Mota.register('class', 'Range', Range); Mota.register('fn', 'getEnemy', battle.getEnemy); Mota.register('fn', 'getHeroStatusOn', hero.getHeroStatusOn); Mota.register('fn', 'getHeroStatusOf', hero.getHeroStatusOf); +Mota.register('fn', 'ensureFloorDamage', damage.ensureFloorDamage); // ----- 变量注册 Mota.register('var', 'enemySpecials', specials); Mota.register('var', 'hook', hook); diff --git a/src/game/system.ts b/src/game/system.ts index 9bb32b2..223e720 100644 --- a/src/game/system.ts +++ b/src/game/system.ts @@ -21,6 +21,7 @@ import type { KeyCode } from '@/plugin/keyCodes'; import type { Ref } from 'vue'; import type * as battle from './enemy/battle'; import type * as hero from './hero'; +import type * as damage from './enemy/damage'; import type { Logger } from '@/core/common/logger'; interface ClassInterface { @@ -51,8 +52,9 @@ interface ClassInterface { type _IBattle = typeof battle; type _IHero = typeof hero; +type _IDamage = typeof damage; -interface FunctionInterface extends _IBattle, _IHero { +interface FunctionInterface extends _IBattle, _IHero, _IDamage { // 定义于渲染进程,录像中会进行polyfill,但是不执行任何内容 readyAllResource(): void; // 定义于游戏进程,渲染进程依然可用 diff --git a/src/plugin/ui/fly.ts b/src/plugin/ui/fly.ts index 9c5fca7..a2f6552 100644 --- a/src/plugin/ui/fly.ts +++ b/src/plugin/ui/fly.ts @@ -214,6 +214,7 @@ export class MinimapDrawer { ox: number = 0; oy: number = 0; noBorder: boolean = false; + showInfo: boolean = false; // cache drawedThumbnail: Partial> = {}; @@ -437,6 +438,21 @@ export class MinimapDrawer { ctx.fillStyle = '#000'; } } + if (this.scale > 2) { + ctx.save(); + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + ctx.font = `3px "normal"`; + ctx.strokeStyle = 'black'; + Mota.require('fn', 'ensureFloorDamage')(floorId); + const enemyNum = core.status.maps[floorId].enemy.list.length; + ctx.fillStyle = 'rgba(0, 0, 0, 0.6)'; + ctx.fillRect(x - 6, y - 2, 12, 4); + ctx.fillStyle = 'white'; + ctx.strokeText(`${enemyNum}怪物`, x, y); + ctx.fillText(`${enemyNum}怪物`, x, y); + ctx.restore(); + } } /** diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts index ac29e19..7a44f7e 100644 --- a/src/plugin/utils.ts +++ b/src/plugin/utils.ts @@ -396,3 +396,8 @@ export function formatSize(size: number) { ? `${(size / (1 << 20)).toFixed(2)}MB` : `${(size / (1 << 30)).toFixed(2)}GB`; } + +let num = 0; +export function requireUniqueSymbol() { + return num++; +} diff --git a/src/ui/fly.vue b/src/ui/fly.vue index 8bb9380..94150cc 100644 --- a/src/ui/fly.vue +++ b/src/ui/fly.vue @@ -401,6 +401,7 @@ onMounted(async () => { drawer = new MinimapDrawer(map); drawer.scale = scale; drawer.noBorder = noBorder.value; + drawer.showInfo = true; const mapStyle = getComputedStyle(map); const thumbStyle = getComputedStyle(thumb);