修复声音问题
This commit is contained in:
@@ -19,6 +19,14 @@ const props = defineProps({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
currentRound: {
|
||||
type: Number,
|
||||
default: 90,
|
||||
},
|
||||
battleId: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
});
|
||||
|
||||
const barColor = ref("#fed847");
|
||||
@@ -26,21 +34,15 @@ const remain = ref(props.total);
|
||||
const timer = ref(null);
|
||||
const sound = ref(true);
|
||||
const currentSound = ref("");
|
||||
const currentRound = ref(0);
|
||||
const currentRoundEnded = ref(true);
|
||||
const currentRound = ref(props.currentRound);
|
||||
const currentRoundEnded = ref(!props.battleId);
|
||||
|
||||
watch(
|
||||
() => props.tips,
|
||||
(newVal) => {
|
||||
let key = "";
|
||||
if (newVal.includes("红队")) {
|
||||
barColor.value = "#FF6060";
|
||||
key = "请红方射击";
|
||||
}
|
||||
if (newVal.includes("蓝队")) {
|
||||
barColor.value = "#5FADFF";
|
||||
key = "请蓝方射击";
|
||||
}
|
||||
if (newVal.includes("红队")) key = "请红方射击";
|
||||
if (newVal.includes("蓝队")) key = "请蓝方射击";
|
||||
if (key && sound.value) {
|
||||
if (currentRoundEnded.value) {
|
||||
currentRound.value += 1;
|
||||
@@ -57,6 +59,15 @@ watch(
|
||||
audioManager.play(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.tips,
|
||||
(newVal) => {
|
||||
let key = "";
|
||||
if (newVal.includes("红队")) barColor.value = "#FF6060";
|
||||
if (newVal.includes("蓝队")) barColor.value = "#5FADFF";
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
@@ -111,8 +122,8 @@ async function onReceiveMessage(messages = []) {
|
||||
if (!sound.value) return;
|
||||
messages.forEach((msg) => {
|
||||
if (
|
||||
msg.constructor === MESSAGETYPES.ShootSyncMeArrowID ||
|
||||
msg.constructor === MESSAGETYPES.ShootResult
|
||||
(props.battleId && msg.constructor === MESSAGETYPES.ShootResult) ||
|
||||
(!props.battleId && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID)
|
||||
) {
|
||||
if (msg.target) {
|
||||
currentSound.value = msg.target.ring
|
||||
|
||||
@@ -510,6 +510,8 @@ onUnmounted(() => {
|
||||
:seq="seq"
|
||||
:start="start && startCount"
|
||||
:total="total"
|
||||
:currentRound="currentRound"
|
||||
:battleId="battleId"
|
||||
/>
|
||||
<PlayersRow
|
||||
v-if="room.battleType === 1"
|
||||
|
||||
@@ -248,7 +248,14 @@ onUnmounted(() => {
|
||||
:blueTeam="blueTeam"
|
||||
/>
|
||||
<TestDistance v-if="!start" :guide="false" />
|
||||
<ShootProgress v-if="start" :tips="tips" :seq="seq" :total="15" />
|
||||
<ShootProgress
|
||||
v-if="start"
|
||||
:tips="tips"
|
||||
:seq="seq"
|
||||
:total="15"
|
||||
:currentRound="currentRound"
|
||||
:battleId="battleId"
|
||||
/>
|
||||
<PlayersRow
|
||||
v-if="start"
|
||||
:currentShooterId="currentShooterId"
|
||||
|
||||
Reference in New Issue
Block a user