HumanBreak/src/ui/markedEnemy.vue

159 lines
4.3 KiB
Vue
Raw Normal View History

2022-12-29 00:26:12 +08:00
<template>
<div id="marked-enemy">
<div v-for="v of all">
<Box
2023-01-01 11:56:02 +08:00
:key="v"
2022-12-29 00:26:12 +08:00
v-if="!getBoxPos(v).hidden"
v-model:left="getBoxPos(v).left"
v-model:top="getBoxPos(v).top"
v-model:width="getBoxPos(v).width"
v-model:height="getBoxPos(v).height"
:resizable="true"
2023-01-06 16:21:17 +08:00
:dragable="true"
2022-12-29 00:26:12 +08:00
>
<Scroll class="box-scroll" :no-scroll="true">
<div class="marked-main">
<div class="marked-info">
<BoxAnimate
:id="v"
:width="24"
:height="24"
></BoxAnimate>
<span class="marked-name marked-item">{{
getName(v)
}}</span>
</div>
<span class="marked-damage marked-item"
>伤害{{ getDamage(v) }}</span
>
<span class="marked-critical marked-item"
2022-12-30 14:14:28 +08:00
>临界{{ getCritical(v)[0] }}</span
2022-12-29 00:26:12 +08:00
>
<span class="marked-critical-damage marked-item"
2022-12-30 14:14:28 +08:00
>减伤{{ getCritical(v)[1] }}</span
2022-12-29 00:26:12 +08:00
>
<span class="marked-def marked-item"
2022-12-30 14:14:28 +08:00
>{{ ratio }}{{ getDefDamage(v) }}</span
2022-12-29 00:26:12 +08:00
>
<div class="marked-button">
<span
class="marked-hide button-text"
2023-01-01 11:56:02 +08:00
@click.stop="getBoxPos(v).hidden = true"
2022-12-29 00:26:12 +08:00
>隐藏盒子</span
>
<span
class="marked-cancel button-text"
2023-01-01 11:56:02 +08:00
@click.stop="unmarkEnemy(v)"
2022-12-29 00:26:12 +08:00
>取消标记</span
>
</div>
</div></Scroll
>
</Box>
</div>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { checkMarkedStatus, getMarkedEnemy, unmarkEnemy } from '../plugin/mark';
import { has } from '../plugin/utils';
import Box from '../components/box.vue';
import Scroll from '../components/scroll.vue';
import BoxAnimate from '../components/boxAnimate.vue';
interface BoxPos {
left: number;
top: number;
width: number;
height: number;
hidden: boolean;
}
const ratio = core.status.thisMap?.ratio ?? 1;
let all = getMarkedEnemy();
watch(checkMarkedStatus, update);
const boxPos = reactive<Partial<Record<EnemyIds, BoxPos>>>({});
function update() {
all.push(...all.splice(0, all.length));
for (const id in boxPos) {
if (!all.includes(id as EnemyIds)) delete boxPos[id as EnemyIds];
}
}
function getBoxPos(id: EnemyIds) {
if (has(boxPos[id])) return boxPos[id]!;
boxPos[id] = {
left: window.innerWidth - 300,
top: 100,
width: 200,
height: 150,
hidden: false
};
return boxPos[id]!;
}
function getName(id: EnemyIds) {
return core.material.enemys[id].name;
}
function getDamage(id: EnemyIds) {
return core.formatBigNumber(core.getDamageInfo(id)?.damage) ?? '???';
}
function getCritical(id: EnemyIds) {
return (
core.nextCriticals(id, 1)[0]?.map(v => core.formatBigNumber(v)) ?? [
0, 0
]
);
}
function getDefDamage(id: EnemyIds) {
return core.formatBigNumber(core.getDefDamage(id, ratio));
}
</script>
<style lang="less" scoped>
#marked-enemy {
width: 100%;
height: 100%;
}
.box-scroll {
height: 100%;
width: 100%;
}
.marked-main {
padding: 1vh 0 1vh 0;
background-color: #0009;
display: flex;
flex-direction: column;
overflow: hidden;
}
.marked-info {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.marked-item {
margin-left: 10%;
}
.marked-button {
align-self: center;
width: 80%;
display: flex;
flex-direction: row;
justify-content: space-around;
}
</style>