diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue index b8a671c..e17fda9 100644 --- a/src/components/ShootProgress.vue +++ b/src/components/ShootProgress.vue @@ -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 diff --git a/src/pages/battle-room.vue b/src/pages/battle-room.vue index 51977b8..efacd4e 100644 --- a/src/pages/battle-room.vue +++ b/src/pages/battle-room.vue @@ -510,6 +510,8 @@ onUnmounted(() => { :seq="seq" :start="start && startCount" :total="total" + :currentRound="currentRound" + :battleId="battleId" /> { :blueTeam="blueTeam" /> - +