mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-26 11:34:30 +08:00
怪物手册初步
This commit is contained in:
1 parent
da771dae91
commit
8517dbdabf
34 files changed
+5179
-1858
No files matched your search
@@ -19,4 +19,11 @@ import { uiStack } from './plugin/uiController';
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@media screen and(max-width:600px) {
|
||||
#ui {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Whitespace-only changes.
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<canvas
|
||||
ref="canvas"
|
||||
:width="width ?? 32"
|
||||
:height="height ?? 32"
|
||||
id="canvas"
|
||||
></canvas>
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import { onMounted, onUnmounted, ref } from 'vue';
|
||||
import { addAnimate, removeAnimate } from '../plugin/animateController';
|
||||
|
||||
const props = defineProps<{
|
||||
id: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}>();
|
||||
|
||||
const canvas = ref<HTMLCanvasElement>();
|
||||
|
||||
onMounted(() => {
|
||||
const c = canvas.value!;
|
||||
const ctx = c.getContext('2d')!;
|
||||
const cls = core.getClsFromId(props.id);
|
||||
const frames = core.getAnimateFrames(cls);
|
||||
|
||||
const scale = window.devicePixelRatio;
|
||||
|
||||
c.style.width = `${c.width}px`;
|
||||
c.style.height = `${c.height}px`;
|
||||
c.width *= scale;
|
||||
c.height *= scale;
|
||||
ctx.scale(scale, scale);
|
||||
|
||||
const fn = (time: number) => {
|
||||
core.clearMap(ctx);
|
||||
const frame = core.status.globalAnimateStatus % frames;
|
||||
core.drawIcon(ctx, props.id, 0, 0, props.width, props.height, frame);
|
||||
};
|
||||
|
||||
addAnimate(fn);
|
||||
|
||||
onUnmounted(() => {
|
||||
removeAnimate(fn);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
#canvas {
|
||||
border: 1.5px solid #ddd;
|
||||
background-color: #222;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<div class="enemy-container">
|
||||
<div class="info">
|
||||
<div class="leftbar">
|
||||
<span class="name">{{ enemy.name }}</span>
|
||||
<BoxAnimate
|
||||
:id="enemy.id"
|
||||
:width="isMobile ? 32 : 50"
|
||||
:height="isMobile ? 32 : 50"
|
||||
style="margin: 5%"
|
||||
></BoxAnimate>
|
||||
<div
|
||||
class="special-text"
|
||||
v-if="has(enemy.special) && enemy.special.length > 0"
|
||||
>
|
||||
<span
|
||||
v-for="(text, i) in enemy.toShowSpecial"
|
||||
:style="{ color: enemy.toShowColor![i] }"
|
||||
>{{ text }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="special-text" v-else>无属性</div>
|
||||
</div>
|
||||
<a-divider
|
||||
type="vertical"
|
||||
dashed
|
||||
style="height: 100%; margin: 0 3% 0 3%; border-color: #ddd4"
|
||||
></a-divider>
|
||||
<div class="rightbar">
|
||||
<div class="detail">
|
||||
<div class="detail-info">
|
||||
<span style="color: lightgreen"
|
||||
>生命 {{
|
||||
core.formatBigNumber(enemy.hp)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightcoral"
|
||||
>攻击 {{
|
||||
core.formatBigNumber(enemy.atk)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightblue"
|
||||
>防御 {{
|
||||
core.formatBigNumber(enemy.def)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightyellow"
|
||||
>金币 {{
|
||||
core.formatBigNumber(enemy.money)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lawngreen"
|
||||
>经验 {{
|
||||
core.formatBigNumber(enemy.money)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: cyan"
|
||||
>{{
|
||||
core.status.thisMap.ratio
|
||||
}}防 {{
|
||||
core.formatBigNumber(enemy.money)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightsalmon"
|
||||
>临界 {{
|
||||
core.formatBigNumber(enemy.critical)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightpink"
|
||||
>减伤 <span
|
||||
:style="{
|
||||
color:
|
||||
enemy.criticalDamage < 0
|
||||
? 'gold'
|
||||
: 'lightpink'
|
||||
}"
|
||||
>{{
|
||||
core.formatBigNumber(
|
||||
enemy.criticalDamage,
|
||||
false,
|
||||
enemy.criticalDamage < 0
|
||||
)
|
||||
}}</span
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span :style="{color: enemy.damageColor!}"
|
||||
>伤害 {{
|
||||
core.formatBigNumber(enemy.damage)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { has } from '../plugin/utils';
|
||||
import BoxAnimate from '../components/boxAnimate.vue';
|
||||
import { isMobile } from '../plugin/use';
|
||||
|
||||
const props = defineProps<{
|
||||
enemy: Enemy & DetailedEnemy;
|
||||
}>();
|
||||
|
||||
const core = window.core;
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.enemy-container {
|
||||
border: 1.5px solid transparent;
|
||||
border-radius: 20px;
|
||||
transition: all 0.2s linear;
|
||||
height: 100%;
|
||||
|
||||
.info {
|
||||
flex-basis: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: stretch;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.enemy-container:hover {
|
||||
border: 1.5px solid gold;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.leftbar {
|
||||
width: 10%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.3vw;
|
||||
}
|
||||
|
||||
.name {
|
||||
text-align: center;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.special-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rightbar {
|
||||
font-size: 1.3vw;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 1.5vh 0 1.5vh 0;
|
||||
|
||||
.detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
height: 100%;
|
||||
|
||||
.detail-info {
|
||||
flex-basis: 33%;
|
||||
line-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+83
-31
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div id="scroll">
|
||||
<div>
|
||||
<div :id="`scroll-div-${id}`" class="scroll-main">
|
||||
<div class="main-div">
|
||||
<div :id="`content-${id}`" class="content">
|
||||
<slot></slot>
|
||||
</div>
|
||||
@@ -10,34 +10,57 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUpdated } from 'vue';
|
||||
import { onMounted, onUnmounted, onUpdated } from 'vue';
|
||||
import { useDrag, useWheel } from '../plugin/use';
|
||||
|
||||
const props = defineProps<{
|
||||
type?: 'vertical' | 'horizontal';
|
||||
}>();
|
||||
|
||||
let now = 0;
|
||||
let total = 0;
|
||||
|
||||
const id = (1e8 * Math.random()).toFixed(0);
|
||||
const scale = window.devicePixelRatio;
|
||||
|
||||
const cssTarget = props.type === 'horizontal' ? 'left' : 'top';
|
||||
const canvasAttr = props.type === 'horizontal' ? 'width' : 'height';
|
||||
|
||||
let ctx: CanvasRenderingContext2D;
|
||||
let content: HTMLDivElement;
|
||||
|
||||
const resize = () => {
|
||||
calHeight();
|
||||
draw();
|
||||
};
|
||||
|
||||
/** 绘制 */
|
||||
function draw() {
|
||||
if (total === 0) return;
|
||||
if (now > total - ctx.canvas.height / scale) {
|
||||
now = total - ctx.canvas.height / scale;
|
||||
if (total < ctx.canvas[canvasAttr] / scale) {
|
||||
now = 0;
|
||||
} else if (now > total - ctx.canvas[canvasAttr] / scale) {
|
||||
now = total - ctx.canvas[canvasAttr] / scale;
|
||||
} else if (now < 0) {
|
||||
now = 0;
|
||||
}
|
||||
const length =
|
||||
Math.min(ctx.canvas.height / total / scale, 1) * ctx.canvas.height;
|
||||
const py = (now / total) * ctx.canvas.height;
|
||||
Math.min(ctx.canvas[canvasAttr] / total / scale, 1) *
|
||||
ctx.canvas[canvasAttr];
|
||||
const py = (now / total) * ctx.canvas[canvasAttr];
|
||||
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(20, Math.max(py + 5, 5));
|
||||
ctx.lineTo(20, Math.min(py + length - 5, ctx.canvas.height - 5));
|
||||
if (props.type === 'horizontal') {
|
||||
ctx.moveTo(Math.max(py + 5, 5), 20 * scale);
|
||||
ctx.lineTo(Math.min(py + length - 5, ctx.canvas.width - 5), 20 * scale);
|
||||
} else {
|
||||
ctx.moveTo(20 * scale, Math.max(py + 5, 5));
|
||||
ctx.lineTo(
|
||||
20 * scale,
|
||||
Math.min(py + length - 5, ctx.canvas.height - 5)
|
||||
);
|
||||
}
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineWidth = 6;
|
||||
ctx.strokeStyle = '#fff';
|
||||
@@ -48,15 +71,13 @@ function draw() {
|
||||
* 计算元素总长度
|
||||
*/
|
||||
function calHeight() {
|
||||
const div = document.getElementById(`content-${id}`) as HTMLDivElement;
|
||||
content = div;
|
||||
const style = getComputedStyle(div);
|
||||
total = parseFloat(style.height);
|
||||
const style = getComputedStyle(content);
|
||||
total = parseFloat(style[canvasAttr]);
|
||||
}
|
||||
|
||||
function scroll() {
|
||||
draw();
|
||||
content.style.top = `${-now}px`;
|
||||
content.style[cssTarget] = `${-now}px`;
|
||||
}
|
||||
|
||||
onUpdated(() => {
|
||||
@@ -65,32 +86,47 @@ onUpdated(() => {
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
calHeight();
|
||||
const div = document.getElementById(`scroll-div-${id}`) as HTMLDivElement;
|
||||
const canvas = document.getElementById(`scroll-${id}`) as HTMLCanvasElement;
|
||||
const d = document.getElementById(`content-${id}`) as HTMLDivElement;
|
||||
ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
content = d;
|
||||
calHeight();
|
||||
|
||||
content.addEventListener('resize', resize);
|
||||
|
||||
const style = getComputedStyle(canvas);
|
||||
canvas.width = 40 * scale;
|
||||
canvas.height = parseFloat(style.height) * scale;
|
||||
|
||||
if (props.type === 'horizontal') {
|
||||
div.style.flexDirection = 'column';
|
||||
canvas.style.height = '40px';
|
||||
canvas.style.width = '98%';
|
||||
canvas.style.margin = '0 1% 0 1%';
|
||||
canvas.width = parseFloat(style.width) * scale;
|
||||
canvas.height = 40 * scale;
|
||||
}
|
||||
|
||||
draw();
|
||||
|
||||
let lastY: number;
|
||||
let last: number;
|
||||
let contentLast: number;
|
||||
|
||||
// 绑定滚动条拖拽事件
|
||||
useDrag(
|
||||
canvas,
|
||||
(x, y) => {
|
||||
const dy = y - lastY;
|
||||
lastY = y;
|
||||
if (canvas.height < total * scale)
|
||||
now += ((dy * total) / canvas.height) * scale;
|
||||
const d = props.type === 'horizontal' ? x : y;
|
||||
const dy = d - last;
|
||||
last = d;
|
||||
if (canvas[canvasAttr] < total * scale)
|
||||
now += ((dy * total) / canvas[canvasAttr]) * scale;
|
||||
content.style.transition = '';
|
||||
scroll();
|
||||
},
|
||||
(x, y) => {
|
||||
lastY = y;
|
||||
last = props.type === 'horizontal' ? x : y;
|
||||
},
|
||||
true
|
||||
);
|
||||
@@ -99,28 +135,37 @@ onMounted(() => {
|
||||
useDrag(
|
||||
content,
|
||||
(x, y) => {
|
||||
const dy = y - contentLast;
|
||||
contentLast = y;
|
||||
if (canvas.height < total * scale) now -= dy;
|
||||
const d = props.type === 'horizontal' ? x : y;
|
||||
const dy = d - contentLast;
|
||||
contentLast = d;
|
||||
if (canvas[canvasAttr] < total * scale) now -= dy;
|
||||
content.style.transition = '';
|
||||
scroll();
|
||||
},
|
||||
(x, y) => {
|
||||
contentLast = y;
|
||||
contentLast = props.type === 'horizontal' ? x : y;
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
useWheel(content, (x, y) => {
|
||||
if (!core.domStyle.isVertical && Math.abs(y) > 50) {
|
||||
content.style.transition = 'top 0.2s ease-out';
|
||||
const d = x !== 0 ? x : y;
|
||||
if (!core.domStyle.isVertical) {
|
||||
if (Math.abs(d) > 50) {
|
||||
content.style.transition = `${cssTarget} 0.2s ease-out`;
|
||||
}
|
||||
} else {
|
||||
content.style.transition = '';
|
||||
}
|
||||
now += y;
|
||||
|
||||
now += d;
|
||||
scroll();
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
content.removeEventListener('resize', resize);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@@ -141,14 +186,21 @@ onMounted(() => {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
#scroll {
|
||||
.scroll-main {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
flex-basis: content;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.main-div {
|
||||
flex-basis: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
+4
-1
@@ -1,10 +1,13 @@
|
||||
// 需要引入所有的插件
|
||||
import pop from './plugin/pop';
|
||||
import ui from './plugin/uiController';
|
||||
import use from './plugin/use';
|
||||
import animate from './plugin/animateController';
|
||||
import utils from './plugin/utils';
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
// 每个引入的插件都要在这里执行,否则不会被转发
|
||||
const toForward: any[] = [pop(), ui()];
|
||||
const toForward: any[] = [pop(), ui(), use(), animate(), utils()];
|
||||
|
||||
// 初始化所有插件,并转发到core上
|
||||
(async function () {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
import './styles.less';
|
||||
import 'ant-design-vue/dist/antd.dark.css';
|
||||
|
||||
createApp(App).mount('#root');
|
||||
@@ -0,0 +1,32 @@
|
||||
const animation: ((time: number) => void)[] = [];
|
||||
|
||||
let animateTime = 0;
|
||||
|
||||
export default function init() {
|
||||
core.registerAnimationFrame('animate', true, time => {
|
||||
if (time - animateTime <= core.values.animateSpeed) return;
|
||||
for (const fn of animation) {
|
||||
fn(time);
|
||||
}
|
||||
animateTime = core.animateFrame.animateTime;
|
||||
});
|
||||
return { addAnimate, removeAnimate };
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个动画
|
||||
* @param fn 要添加的函数
|
||||
*/
|
||||
export function addAnimate(fn: (time: number) => void) {
|
||||
animation.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除一个动画
|
||||
* @param fn 要移除的函数
|
||||
*/
|
||||
export function removeAnimate(fn: (time: number) => void) {
|
||||
const index = animation.findIndex(v => v === fn);
|
||||
if (index === -1)
|
||||
throw new ReferenceError('No such function in animation.');
|
||||
}
|
||||
+6
-1
@@ -1,5 +1,5 @@
|
||||
export default function init() {
|
||||
return { useDrag, useWheel };
|
||||
return { useDrag, useWheel, isMobile };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,3 +55,8 @@ export function useWheel(
|
||||
fn(e.deltaX, e.deltaY, e.deltaZ, e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是移动设备
|
||||
*/
|
||||
export const isMobile = matchMedia('(max-width: 600px)').matches;
|
||||
@@ -0,0 +1,27 @@
|
||||
import { isNil } from 'lodash';
|
||||
|
||||
export default function init() {
|
||||
return { has, getDamageColor };
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定一个值是否不是undefined或null
|
||||
* @param value 要判断的值
|
||||
*/
|
||||
export function has<T>(value: T): value is NonNullable<T> {
|
||||
return !isNil(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据伤害大小获取颜色
|
||||
* @param damage 伤害大小
|
||||
*/
|
||||
export function getDamageColor(damage: number): string {
|
||||
if (typeof damage !== 'number') return '#f00';
|
||||
if (damage === 0) return '#2f2';
|
||||
if (damage < 0) return '#7f7';
|
||||
if (damage < core.status.hero.hp / 3) return '#fff';
|
||||
if (damage < (core.status.hero.hp * 2) / 3) return '#ff4';
|
||||
if (damage < core.status.hero.hp) return '#f22';
|
||||
return '#f00';
|
||||
}
|
||||
Vendored
+8
@@ -161,6 +161,10 @@ type Core = {
|
||||
readonly icons: { [x: string]: HTMLImageElement };
|
||||
};
|
||||
|
||||
readonly values: {
|
||||
animateSpeed: number;
|
||||
};
|
||||
|
||||
readonly materials: string[];
|
||||
|
||||
readonly control: control;
|
||||
@@ -317,3 +321,7 @@ declare const main: main;
|
||||
declare const core: Core;
|
||||
declare const flags: { [x: string]: any };
|
||||
declare const hero: HeroStatus;
|
||||
|
||||
interface Window {
|
||||
readonly core: Core;
|
||||
}
|
||||
Vendored
+1
-1
@@ -131,7 +131,7 @@ declare class enemys {
|
||||
* @param floorId 地图id,可选
|
||||
* @returns 敌人集合,按伤害升序排列,支持多朝向怪合并
|
||||
*/
|
||||
getCurrentEnemys(floorId?: string): Enemy[];
|
||||
getCurrentEnemys(floorId?: string): (Enemy & DetailedEnemy)[];
|
||||
|
||||
/**
|
||||
* 检查某些楼层是否还有漏打的(某种)敌人
|
||||
|
||||
Vendored
+7
-1
@@ -4,11 +4,17 @@ declare class icons {
|
||||
getIcons(): void;
|
||||
|
||||
/** 根据ID获得其类型 */
|
||||
getClsFromId(id?: string): string;
|
||||
getClsFromId(id?: string): BlockCls;
|
||||
|
||||
/** 获得所有图标的ID */
|
||||
getAllIconIds(): void;
|
||||
|
||||
/** 根据图块数字或ID获得所在的tileset和坐标信息 */
|
||||
getTilesetOffset(id?: string): void;
|
||||
|
||||
/**
|
||||
* 获取图块的帧数
|
||||
* @param cls 图块类型
|
||||
*/
|
||||
getAnimateFrames(cls: BlockCls): 1 | 2 | 4;
|
||||
}
|
||||
Vendored
+30
-1
@@ -4,7 +4,7 @@ type Ref<T> = {
|
||||
value: T;
|
||||
};
|
||||
|
||||
interface PluginDeclaration {
|
||||
interface PluginDeclaration extends PluginUtils {
|
||||
/**
|
||||
* 添加函数 例:添加弹出文字,像这个就可以使用core.addPop或core.plugin.addPop调用
|
||||
* @param px 弹出的横坐标
|
||||
@@ -25,6 +25,9 @@ interface PluginDeclaration {
|
||||
/** ui栈 */
|
||||
readonly uiStack: Ref<Component[]>;
|
||||
|
||||
/** 是否是移动设备 */
|
||||
readonly isMobile: boolean;
|
||||
|
||||
/**
|
||||
* 向一个元素添加拖拽事件
|
||||
* @param ele 目标元素
|
||||
@@ -48,6 +51,32 @@ interface PluginDeclaration {
|
||||
ele: HTMLElement,
|
||||
fn: (x: number, y: number, z: number, e: WheelEvent) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 添加一个动画
|
||||
* @param fn 要添加的函数
|
||||
*/
|
||||
addAnimate(fn: (time: number) => void);
|
||||
|
||||
/**
|
||||
* 移除一个动画
|
||||
* @param fn 要移除的函数
|
||||
*/
|
||||
removeAnimate(fn: (time: number) => void);
|
||||
}
|
||||
|
||||
interface PluginUtils {
|
||||
/**
|
||||
* 判定一个值是否不是undefined或null
|
||||
* @param value 要判断的值
|
||||
*/
|
||||
has<T>(value: T): value is NonNullable<T>;
|
||||
|
||||
/**
|
||||
* 根据伤害大小获取颜色
|
||||
* @param damage 伤害大小
|
||||
*/
|
||||
getDamageColor(damage: number): string;
|
||||
}
|
||||
|
||||
type Forward<T> = {
|
||||
|
||||
Vendored
+25
-2
@@ -100,7 +100,7 @@ declare class utils {
|
||||
* @param onMap 可选,true表示用于地图显伤,结果总字符数最多为5,否则最多为6
|
||||
* @returns 格式化结果
|
||||
*/
|
||||
formatBigNumber(x: number, onMap?: boolean): string;
|
||||
formatBigNumber(x: number, onMap?: boolean, onCritical?: boolean): string;
|
||||
|
||||
/** 变速移动 */
|
||||
applyEasing(mode?: string): (number) => number;
|
||||
@@ -402,6 +402,16 @@ type direction = 'up' | 'down' | 'left' | 'right';
|
||||
type move = 'forward' | direction;
|
||||
type loc = { direction: direction; x: number; y: number };
|
||||
type rgbarray = [number, number, number, number];
|
||||
type BlockCls =
|
||||
| 'terrain'
|
||||
| 'animate'
|
||||
| 'enemy'
|
||||
| 'item'
|
||||
| 'enemy48'
|
||||
| 'npcs'
|
||||
| 'npc48'
|
||||
| 'autotile'
|
||||
| 'tilesets';
|
||||
|
||||
type Events = MotaAction[] | string;
|
||||
|
||||
@@ -515,7 +525,7 @@ type Enemy = {
|
||||
id: string;
|
||||
name: string;
|
||||
displayIdInBook: string;
|
||||
special: number | number[];
|
||||
special: number[];
|
||||
hp: number;
|
||||
atk: number;
|
||||
def: number;
|
||||
@@ -525,6 +535,19 @@ type Enemy = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
type DetailedEnemy = {
|
||||
name: string;
|
||||
specialText: string[];
|
||||
specialColor: (string | rgbarray)[];
|
||||
damage: number;
|
||||
critical: number;
|
||||
criticalDamage: number;
|
||||
defDamage: number;
|
||||
toShowSpecial?: string[];
|
||||
toShowColor?: any[];
|
||||
damageColor?: string;
|
||||
};
|
||||
|
||||
type Item = {
|
||||
cls: string;
|
||||
[key: string]: any;
|
||||
|
||||
+73
-6
@@ -1,20 +1,87 @@
|
||||
<!-- 怪物手册ui -->
|
||||
|
||||
<template>
|
||||
<Scroll>
|
||||
<div v-for="i of 100" class="test">test{{ i }}</div>
|
||||
</Scroll>
|
||||
<div id="book">
|
||||
<div v-if="enemy.length === 0" id="none">
|
||||
<div>本层无怪物</div>
|
||||
</div>
|
||||
<Scroll v-else style="width: 100%; height: 100%; font-family: normal">
|
||||
<div v-for="e of enemy" class="enemy">
|
||||
<EnemyOne :enemy="e"></EnemyOne>
|
||||
<a-divider
|
||||
dashed
|
||||
style="width: 100%; border-color: #ddd4"
|
||||
></a-divider>
|
||||
</div>
|
||||
</Scroll>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { onMounted } from 'vue';
|
||||
import EnemyOne from '../components/enemyOne.vue';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { getDamageColor } from '../plugin/utils';
|
||||
|
||||
const floorId = core.floorIds[core.status.event?.ui] ?? core.status.floorId;
|
||||
const enemy = core.getCurrentEnemys(floorId);
|
||||
|
||||
// 解析
|
||||
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';
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.test {
|
||||
color: white;
|
||||
#book {
|
||||
opacity: 0;
|
||||
background-color: #000d;
|
||||
transition: opacity 0.6s linear;
|
||||
user-select: none;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
font-family: 'normal';
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@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%;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user