From d35ff9335fb53cfef97c1dce610d2aa1757caa03 Mon Sep 17 00:00:00 2001 From: kron Date: Sat, 7 Feb 2026 15:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeaderProgress.vue | 2 +- src/components/ShootProgress.vue | 59 +++---------------------------- src/components/TestDistance.vue | 23 +++++------- src/constants.js | 1 + src/pages/melee-battle.vue | 6 +--- src/pages/team-battle.vue | 6 +--- 6 files changed, 16 insertions(+), 81 deletions(-) diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue index 77cf3ac..791aa88 100644 --- a/src/components/HeaderProgress.vue +++ b/src/components/HeaderProgress.vue @@ -50,7 +50,7 @@ async function onReceiveMessage(message) { if (ended.value) return; if (Array.isArray(message)) return; if (message.type === MESSAGETYPESV2.BattleStart) { - melee.value = Boolean(message.mode); + melee.value = Boolean(message.mode > 3); totalShot.value = message.mode === 1 ? 3 : 2; currentRoundEnded.value = true; audioManager.play("比赛开始"); diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue index 0f41712..9173021 100644 --- a/src/components/ShootProgress.vue +++ b/src/components/ShootProgress.vue @@ -123,6 +123,7 @@ const updateSound = () => { async function onReceiveMessage(msg) { if (Array.isArray(msg)) return; if (msg.type === MESSAGETYPESV2.BattleStart) { + halfTime.value = false; audioManager.play("比赛开始"); } else if (msg.type === MESSAGETYPESV2.BattleEnd) { audioManager.play("比赛结束"); @@ -135,62 +136,10 @@ async function onReceiveMessage(msg) { key.push(`向${getDirectionText(msg.shootData.angle)}调整`); audioManager.play(key, false); } + } else if (msg.type === MESSAGETYPESV2.HalfRest) { + halfTime.value = true; + audioManager.play("中场休息"); } - // if (ended.value) return; - // messages.forEach((msg) => { - // if ( - // (props.battleId && msg.constructor === MESSAGETYPES.ShootResult) || - // (!props.battleId && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) - // ) { - // if (props.melee && msg.userId !== user.value.id) return; - // if (!halfTime.value && msg.target) { - // let key = []; - // key.push(msg.target.ring ? `${msg.target.ring}环` : "未上靶"); - // if (!msg.target.ring) - // key.push(`向${getDirectionText(msg.target.angle)}调整`); - // audioManager.play(key); - // } - // } else if (msg.constructor === MESSAGETYPES.InvalidShot) { - // if (msg.userId === user.value.id) { - // uni.showToast({ - // title: "距离不足,无效", - // icon: "none", - // }); - // audioManager.play("射击无效"); - // } - // } else if (msg.constructor === MESSAGETYPES.AllReady) { - // audioManager.play("比赛开始"); - // } else if (msg.constructor === MESSAGETYPES.MeleeAllReady) { - // halfTime.value = false; - // audioManager.play("比赛开始"); - // } else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { - // currentRoundEnded.value = true; - // } else if (msg.constructor === MESSAGETYPES.HalfTimeOver) { - // if (props.battleId) { - // halfTime.value = true; - // audioManager.play("中场休息"); - // return; - // } - // if (wait.value !== msg.wait) { - // setTimeout(() => { - // wait.value = msg.wait; - // if (msg.wait === 20) { - // halfTime.value = true; - // audioManager.play("中场休息", false); - // } - // if (msg.wait === 0) { - // halfTime.value = false; - // } - // }, 200); - // } - // } else if (msg.constructor === MESSAGETYPES.MatchOver) { - // audioManager.play("比赛结束"); - // } else if (msg.constructor === MESSAGETYPES.FinalShoot) { - // audioManager.play("决金箭轮"); - // } else if (msg.constructor === MESSAGETYPES.MatchOver) { - // ended.value = true; - // } - // }); } const playSound = (key) => { diff --git a/src/components/TestDistance.vue b/src/components/TestDistance.vue index 8d7fce3..02391c1 100644 --- a/src/components/TestDistance.vue +++ b/src/components/TestDistance.vue @@ -5,7 +5,7 @@ import BowPower from "@/components/BowPower.vue"; import Avatar from "@/components/Avatar.vue"; import audioManager from "@/audioManager"; import { simulShootAPI } from "@/apis"; -import { MESSAGETYPES } from "@/constants"; +import { MESSAGETYPESV2 } from "@/constants"; import useStore from "@/store"; import { storeToRefs } from "pinia"; const store = useStore(); @@ -26,7 +26,6 @@ const props = defineProps({ }); const arrow = ref({}); const distance = ref(0); -const debugInfo = ref(""); const showsimul = ref(false); const count = ref(props.count); const timer = ref(null); @@ -49,19 +48,13 @@ onBeforeUnmount(() => { uni.$off("update-timer", updateTimer); }); -async function onReceiveMessage(messages = []) { - if (!Array.isArray(messages)) return; - messages.forEach((msg) => { - if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) { - arrow.value = msg.target; - distance.value = Number((msg.target.dst / 100).toFixed(2)); - debugInfo.value = msg.target; - audioManager.play("距离合格"); - } else if (msg.constructor === MESSAGETYPES.InvalidShot) { - distance.value = Number((msg.target.dst / 100).toFixed(2)); - audioManager.play("距离不足"); - } - }); +async function onReceiveMessage(msg) { + if (Array.isArray(msg)) return; + if (msg.type === MESSAGETYPESV2.TestDistance) { + distance.value = Number((msg.shootData.distance / 100).toFixed(2)); + if (distance.value >= 5) audioManager.play("距离合格"); + else audioManager.play("距离不足"); + } } const simulShoot = async () => { diff --git a/src/constants.js b/src/constants.js index 0763077..93b459f 100644 --- a/src/constants.js +++ b/src/constants.js @@ -38,6 +38,7 @@ export const MESSAGETYPESV2 = { NewRound: 5, BattleEnd: 6, HalfRest: 7, + TestDistance: 8, }; export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"]; diff --git a/src/pages/melee-battle.vue b/src/pages/melee-battle.vue index 4c861ad..10cb3ff 100644 --- a/src/pages/melee-battle.vue +++ b/src/pages/melee-battle.vue @@ -71,11 +71,7 @@ function recoverData(battleInfo, { force = false } = {}) { } if (force) { const remain = (Date.now() - battleInfo.current.startTime) / 1000; - console.log( - `当前轮已进行${remain}秒,${Date.now()},${ - battleInfo.current.startTimeText - }` - ); + console.log(`当前轮已进行${remain}秒`); if (remain > 0 && remain < 90) { setTimeout(() => { uni.$emit("update-remain", 90 - remain - 0.2); diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index 2719aab..12088a0 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -71,11 +71,7 @@ const recoverData = (battleInfo, { force = false, arrowOnly = false } = {}) => { uni.$emit("update-tips", nextTips); if (force) { const remain = (Date.now() - battleInfo.current.startTime) / 1000; - console.log( - `当前轮已进行${remain}秒,${Date.now()},${ - battleInfo.current.startTimeText - }` - ); + console.log(`当前轮已进行${remain}秒`); if (remain > 0 && remain < 15) { setTimeout(() => { uni.$emit("update-remain", 15 - remain - 0.2);