细节修改
This commit is contained in:
@@ -13,10 +13,11 @@ const timer = ref(null);
|
||||
const sound = ref(true);
|
||||
const currentSound = ref("");
|
||||
const currentRound = ref(1);
|
||||
const totalRound = ref(1);
|
||||
const currentRoundEnded = ref(false);
|
||||
const ended = ref(false);
|
||||
const halfTime = ref(false);
|
||||
const currentShot = ref(0);
|
||||
const totalShot = ref(0);
|
||||
|
||||
watch(
|
||||
() => tips.value,
|
||||
@@ -52,6 +53,7 @@ async function onReceiveMessage(messages = []) {
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
if (melee.value && msg.userId !== user.value.id) return;
|
||||
if (msg.userId === user.value.id) currentShot.value++;
|
||||
if (!halfTime.value && msg.target) {
|
||||
currentSound.value = msg.target.ring
|
||||
? `${msg.target.ring}环`
|
||||
@@ -67,6 +69,10 @@ async function onReceiveMessage(messages = []) {
|
||||
audioManager.play("射击无效");
|
||||
}
|
||||
} else if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||
const { config } = msg.groupUserStatus;
|
||||
if (config && config.mode === 1) {
|
||||
totalShot.value = config.teamSize === 2 ? 3 : 2;
|
||||
}
|
||||
currentRoundEnded.value = true;
|
||||
audioManager.play("比赛开始");
|
||||
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
@@ -74,6 +80,7 @@ async function onReceiveMessage(messages = []) {
|
||||
halfTime.value = false;
|
||||
audioManager.play("比赛开始");
|
||||
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
currentShot.value = 0;
|
||||
if (msg.preRoundResult && msg.preRoundResult.currentRound) {
|
||||
currentRound.value = msg.preRoundResult.currentRound + 1;
|
||||
currentRoundEnded.value = true;
|
||||
@@ -84,6 +91,7 @@ async function onReceiveMessage(messages = []) {
|
||||
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
audioManager.play("比赛结束");
|
||||
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||
totalShot.value = 0;
|
||||
audioManager.play("决金箭轮");
|
||||
tips.value = "即将开始...";
|
||||
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||
@@ -107,14 +115,20 @@ const onUpdateTips = (newVal) => {
|
||||
tips.value = newVal;
|
||||
};
|
||||
|
||||
const onUpdateTotalShot = (newVal) => {
|
||||
currentShot.value = newVal.currentShot;
|
||||
totalShot.value = newVal.totalShot;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("update-shot", onUpdateTotalShot);
|
||||
uni.$on("update-tips", onUpdateTips);
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("play-sound", playSound);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
uni.$off("update-tips", onUpdateTips);
|
||||
uni.$off("update-shot", onUpdateTotalShot);
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("play-sound", playSound);
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
@@ -124,7 +138,7 @@ onBeforeUnmount(() => {
|
||||
<template>
|
||||
<view class="container">
|
||||
<text>{{ tips }}</text>
|
||||
<!-- <text> ({{ currentRound }}/{{ totalRound }}) </text> -->
|
||||
<text v-if="totalShot > 0"> ({{ currentShot }}/{{ totalShot }}) </text>
|
||||
<button v-if="!!tips" hover-class="none" @click="updateSound">
|
||||
<image
|
||||
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
|
||||
|
||||
Reference in New Issue
Block a user