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