feat & fix: 小地图显示剩余怪物 & id优化

This commit is contained in:
unanmed 2024-04-21 15:45:06 +08:00
parent 020551bd90
commit 59c3b46cfc
15 changed files with 93 additions and 13 deletions

1
components.d.ts vendored
View File

@ -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']
}
}

View File

@ -40,7 +40,7 @@ main.floors.MT22=
"第二章的加点已开启,可以在技能树的前置技能下方选择",
"如果你玩过上个版本,直接跳到了本章,记得查看背包里面的各种道具,尤其是百科全书,同时注意左边是你来的方向,那里还有些怪物",
"从现在开始,跳跃技能不再消耗生命值,别忘了你还有跳跃技能",
"为了确保平衡与可玩性从现在开始无上之盾第一章终极技能效果变为1/10"
"为了确保平衡与可玩性从现在开始无上之盾第一章终极技能效果变为1/10,同时每个怪物的最大吸血量限制为攻防和"
],
"7,9": [
"百科全书中已解锁第二章需要特别说明的怪物属性,你可以在百科全书中查看",

View File

@ -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],

View File

@ -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;

View File

@ -9,9 +9,9 @@
<script lang="tsx" setup>
import { onMounted, onUnmounted, onUpdated, ref } from 'vue';
import { addAnimate, removeAnimate } from '../plugin/animateController';
import { has } from '../plugin/utils';
import { has, requireUniqueSymbol } from '../plugin/utils';
const id = (Math.random() * 1e8).toFixed(0);
const id = requireUniqueSymbol().toFixed(0);
const props = defineProps<{
id: AllIds | 'hero' | 'none';

View File

@ -27,7 +27,7 @@ import { onMounted, onUnmounted, onUpdated, ref } from 'vue';
import { LeftOutlined } from '@ant-design/icons-vue';
import Scroll from './scroll.vue';
import { isMobile } from '../plugin/use';
import { has } from '../plugin/utils';
import { has, requireUniqueSymbol } from '../plugin/utils';
const emits = defineEmits<{
(e: 'close'): void;
@ -40,7 +40,7 @@ const props = defineProps<{
right?: number;
}>();
const id = (1e8 * Math.random()).toFixed(0);
const id = requireUniqueSymbol().toFixed(0);
let main: HTMLDivElement;
let left: HTMLDivElement;

View File

@ -0,0 +1,33 @@
<template>
<canvas :id="`minimap-${id}`"></canvas>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import { requireUniqueSymbol } from '../plugin/utils';
import { MinimapDrawer } from '../plugin/ui/fly';
const props = defineProps<{
action?: boolean;
scale?: number;
noBorder?: boolean;
showInfo?: boolean;
autoLocate?: boolean;
}>();
const id = requireUniqueSymbol().toFixed(0);
let canvas: HTMLCanvasElement;
let drawer: MinimapDrawer;
onMounted(() => {
canvas = document.getElementById(`minimap-${id}`) as HTMLCanvasElement;
drawer = new MinimapDrawer(canvas);
drawer.scale = props.scale ?? 3;
drawer.noBorder = props.noBorder ?? false;
drawer.showInfo = props.showInfo ?? false;
});
</script>
<style lang="less" scoped></style>

View File

@ -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;

View File

@ -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 {

View File

@ -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 (
<div>
<Minimap></Minimap>
</div>
);
}
function DefaultToolEditor(props: CustomToolbarProps) {
return <span></span>;
}

View File

@ -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);

View File

@ -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;
// 定义于游戏进程,渲染进程依然可用

View File

@ -214,6 +214,7 @@ export class MinimapDrawer {
ox: number = 0;
oy: number = 0;
noBorder: boolean = false;
showInfo: boolean = false;
// cache
drawedThumbnail: Partial<Record<FloorIds, boolean>> = {};
@ -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();
}
}
/**

View File

@ -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++;
}

View File

@ -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);