141 lines
2.5 KiB
Vue
141 lines
2.5 KiB
Vue
<script setup>
|
||
import BowPower from "@/components/BowPower.vue";
|
||
const props = defineProps({
|
||
totalRound: {
|
||
type: Number,
|
||
default: 0,
|
||
},
|
||
currentRound: {
|
||
type: Number,
|
||
default: 0,
|
||
},
|
||
avatar: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
power: {
|
||
type: Number,
|
||
default: 0,
|
||
},
|
||
tips: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
debug: {
|
||
type: Boolean,
|
||
default: false,
|
||
},
|
||
scores: {
|
||
type: Array,
|
||
default: () => [],
|
||
},
|
||
});
|
||
|
||
function calcRealX(num) {
|
||
const len = 20 + num;
|
||
return `calc(${(len / 40) * 100}% - 10px)`;
|
||
}
|
||
function calcRealY(num) {
|
||
const len = num < 0 ? Math.abs(num) + 20 : 20 - num;
|
||
return `calc(${(len / 40) * 100}% - 10px)`;
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<view class="container">
|
||
<view class="header">
|
||
<text v-if="debug" class="header-tips">大人,请射箭</text>
|
||
<text v-if="totalRound > 0" class="round-count">{{
|
||
currentRound + "/" + totalRound
|
||
}}</text>
|
||
<BowPower v-if="power > 0" :power="power" />
|
||
</view>
|
||
<view class="target">
|
||
<image
|
||
v-for="(bow, index) in scores"
|
||
:key="index"
|
||
src="../static/hit-icon.png"
|
||
:class="`hit ${index + 1 === scores.length ? 'pump-in' : ''}`"
|
||
:style="{
|
||
left: calcRealX(bow.x),
|
||
top: calcRealY(bow.y),
|
||
}"
|
||
/>
|
||
<image src="../static/bow-target.png" mode="widthFix" />
|
||
</view>
|
||
<view v-if="avatar" class="footer">
|
||
<image :src="avatar" mode="widthFix" />
|
||
</view>
|
||
<text v-if="tips">{{ tips }}</text>
|
||
</view>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.container {
|
||
width: calc(100% - 30px);
|
||
margin: 15px;
|
||
}
|
||
.target {
|
||
position: relative;
|
||
}
|
||
.target > image:last-child {
|
||
width: 100%;
|
||
}
|
||
@keyframes pumpIn {
|
||
from {
|
||
transform: scale(2);
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
}
|
||
}
|
||
.pump-in {
|
||
animation: pumpIn 0.3s ease-out forwards;
|
||
transform-origin: center center;
|
||
}
|
||
.hit {
|
||
position: absolute;
|
||
width: 20px;
|
||
height: 20px;
|
||
}
|
||
.header {
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 20px;
|
||
}
|
||
.header > image:first-child {
|
||
width: 40px;
|
||
height: 40px;
|
||
}
|
||
.round-count {
|
||
font-size: 20px;
|
||
color: #fed847;
|
||
top: 75px;
|
||
}
|
||
.header-tips {
|
||
font-size: 20px;
|
||
color: #fed847;
|
||
}
|
||
.footer {
|
||
width: calc(100% - 20px);
|
||
padding: 0 10px;
|
||
display: flex;
|
||
margin-top: -40px;
|
||
}
|
||
.footer > image {
|
||
width: 40px;
|
||
height: 40px;
|
||
border-radius: 50%;
|
||
}
|
||
.container > text {
|
||
width: 100%;
|
||
color: #fed847;
|
||
text-align: center;
|
||
line-height: 40px;
|
||
display: block;
|
||
margin-top: 20px;
|
||
}
|
||
</style>
|