流程完善

This commit is contained in:
kron
2025-07-15 17:10:41 +08:00
parent 95426ffd07
commit 0edf259fb0
7 changed files with 76 additions and 31 deletions

View File

@@ -2,6 +2,10 @@
import { ref, watch, onMounted, onUnmounted } from "vue";
import audioManager from "@/audioManager";
import { MESSAGETYPES } from "@/constants";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const props = defineProps({
start: {
type: Boolean,
@@ -27,6 +31,10 @@ const props = defineProps({
type: String,
default: "",
},
melee: {
type: Boolean,
default: false,
},
});
const barColor = ref("#fed847");
@@ -36,6 +44,7 @@ const sound = ref(true);
const currentSound = ref("");
const currentRound = ref(props.currentRound);
const currentRoundEnded = ref(!props.battleId);
const halfTimeTip = ref(false);
watch(
() => props.tips,
@@ -125,6 +134,7 @@ async function onReceiveMessage(messages = []) {
(props.battleId && msg.constructor === MESSAGETYPES.ShootResult) ||
(!props.battleId && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID)
) {
if (props.melee && msg.userId !== user.value.id) return;
if (msg.target) {
currentSound.value = msg.target.ring
? `${msg.target.ring}`
@@ -134,10 +144,11 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.AllReady) {
audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
audioManager.play("比赛开始");
if (!halfTimeTip.value) audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentRoundEnded.value = true;
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
halfTimeTip.value = true;
audioManager.play("中场休息");
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
audioManager.play("比赛结束");