逻辑完善

This commit is contained in:
kron
2026-02-07 15:12:20 +08:00
parent 715e614f9d
commit d35ff9335f
6 changed files with 16 additions and 81 deletions

View File

@@ -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("比赛开始");

View File

@@ -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) => {

View File

@@ -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 () => {