2022-11-14 17:11:23 +08:00
|
|
|
|
<!-- 怪物手册ui -->
|
|
|
|
|
<template>
|
2022-11-16 23:01:23 +08:00
|
|
|
|
<div id="book">
|
|
|
|
|
<div v-if="enemy.length === 0" id="none">
|
|
|
|
|
<div>本层无怪物</div>
|
|
|
|
|
</div>
|
2022-11-19 11:30:14 +08:00
|
|
|
|
<Scroll
|
|
|
|
|
v-else
|
|
|
|
|
style="width: 100%; height: 100%; font-family: normal"
|
|
|
|
|
v-model:now="scroll"
|
|
|
|
|
v-model:drag="drag"
|
|
|
|
|
>
|
|
|
|
|
<div v-for="(e, i) of enemy" class="enemy">
|
|
|
|
|
<EnemyOne :enemy="e" @select="select(e, i)"></EnemyOne>
|
2022-11-16 23:01:23 +08:00
|
|
|
|
<a-divider
|
|
|
|
|
dashed
|
|
|
|
|
style="width: 100%; border-color: #ddd4"
|
|
|
|
|
></a-divider>
|
|
|
|
|
</div>
|
|
|
|
|
</Scroll>
|
|
|
|
|
</div>
|
2022-11-19 11:30:14 +08:00
|
|
|
|
<BookDetail v-if="detail" @close="closeDetail()"></BookDetail>
|
2022-11-14 17:11:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="tsx">
|
2022-11-16 23:01:23 +08:00
|
|
|
|
import { cloneDeep } from 'lodash';
|
2022-11-19 11:30:14 +08:00
|
|
|
|
import { sleep } from 'mutate-animate';
|
|
|
|
|
import { onMounted, ref } from 'vue';
|
2022-11-16 23:01:23 +08:00
|
|
|
|
import EnemyOne from '../components/enemyOne.vue';
|
2022-11-14 17:11:23 +08:00
|
|
|
|
import Scroll from '../components/scroll.vue';
|
2022-11-16 23:01:23 +08:00
|
|
|
|
import { getDamageColor } from '../plugin/utils';
|
2022-11-19 11:30:14 +08:00
|
|
|
|
import BookDetail from './bookDetail.vue';
|
2022-11-14 17:11:23 +08:00
|
|
|
|
|
|
|
|
|
const floorId = core.floorIds[core.status.event?.ui] ?? core.status.floorId;
|
|
|
|
|
const enemy = core.getCurrentEnemys(floorId);
|
2022-11-16 23:01:23 +08:00
|
|
|
|
|
2022-11-19 11:30:14 +08:00
|
|
|
|
const scroll = ref(0);
|
|
|
|
|
const drag = ref(false);
|
|
|
|
|
const detail = ref(false);
|
|
|
|
|
|
2022-11-16 23:01:23 +08:00
|
|
|
|
// 解析
|
|
|
|
|
enemy.forEach(v => {
|
|
|
|
|
const l = v.specialText.length;
|
|
|
|
|
v.toShowSpecial = cloneDeep(v.specialText);
|
|
|
|
|
v.toShowColor = cloneDeep(v.specialColor);
|
|
|
|
|
if (l >= 3) {
|
|
|
|
|
v.toShowSpecial = v.specialText.slice(0, 2).concat(['...']);
|
|
|
|
|
v.toShowColor = v.specialColor.slice(0, 2).concat(['#fff']);
|
|
|
|
|
}
|
|
|
|
|
v.toShowColor = v.toShowColor.map(v => {
|
|
|
|
|
if (typeof v === 'string') return v;
|
|
|
|
|
else return core.arrayToRGBA(v);
|
|
|
|
|
});
|
|
|
|
|
v.damageColor = getDamageColor(v.damage);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
const div = document.getElementById('book') as HTMLDivElement;
|
|
|
|
|
div.style.opacity = '1';
|
|
|
|
|
});
|
2022-11-19 11:30:14 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 选择怪物,展示详细信息
|
|
|
|
|
* @param enemy 选择的怪物
|
|
|
|
|
* @param index 选择的怪物索引
|
|
|
|
|
*/
|
|
|
|
|
function select(enemy: Enemy & DetailedEnemy, index: number) {
|
|
|
|
|
if (drag.value) return;
|
|
|
|
|
const h = window.innerHeight;
|
|
|
|
|
const y = index * h * 0.2 - scroll.value;
|
|
|
|
|
core.plugin.bookDetailEnemy = enemy;
|
|
|
|
|
core.plugin.bookDetailPos = y;
|
|
|
|
|
detail.value = true;
|
|
|
|
|
hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function hide() {
|
|
|
|
|
const div = document.getElementById('book') as HTMLDivElement;
|
|
|
|
|
div.style.opacity = '0';
|
|
|
|
|
await sleep(600);
|
|
|
|
|
div.style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function closeDetail() {
|
|
|
|
|
show();
|
|
|
|
|
await sleep(600);
|
|
|
|
|
detail.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function show() {
|
|
|
|
|
const div = document.getElementById('book') as HTMLDivElement;
|
|
|
|
|
div.style.display = 'block';
|
|
|
|
|
await sleep(50);
|
|
|
|
|
div.style.opacity = '1';
|
|
|
|
|
}
|
2022-11-14 17:11:23 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
2022-11-16 23:01:23 +08:00
|
|
|
|
#book {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
user-select: none;
|
|
|
|
|
width: 80%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-family: 'normal';
|
|
|
|
|
overflow: hidden;
|
2022-11-19 11:30:14 +08:00
|
|
|
|
transition: opacity 0.6s linear;
|
2022-11-16 23:01:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 600px) {
|
|
|
|
|
#book {
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 5% 0 5% 5%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#none {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 10vw;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
font-family: 'normal';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.enemy {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 20vh;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 0 1% 0 1%;
|
2022-11-14 17:11:23 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|