添加为上靶的方向指示
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import { getDirectionText } from "@/util";
|
||||
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
@@ -11,7 +13,6 @@ const tips = ref("");
|
||||
const melee = ref(false);
|
||||
const timer = ref(null);
|
||||
const sound = ref(true);
|
||||
const currentSound = ref("");
|
||||
const currentRound = ref(0);
|
||||
const currentRoundEnded = ref(false);
|
||||
const ended = ref(false);
|
||||
@@ -22,7 +23,6 @@ const totalShot = ref(0);
|
||||
watch(
|
||||
() => tips.value,
|
||||
(newVal) => {
|
||||
if (!sound.value) return;
|
||||
let key = [];
|
||||
if (newVal.includes("重回")) return;
|
||||
if (currentRoundEnded.value) {
|
||||
@@ -44,11 +44,11 @@ watch(
|
||||
|
||||
const updateSound = () => {
|
||||
sound.value = !sound.value;
|
||||
if (!sound.value) audioManager.stop(currentSound.value);
|
||||
audioManager.setMuted(!sound.value);
|
||||
};
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
if (!sound.value || ended.value) return;
|
||||
if (ended.value) return;
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
if (melee.value && msg.userId !== user.value.id) return;
|
||||
@@ -72,10 +72,11 @@ async function onReceiveMessage(messages = []) {
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!halfTime.value && msg.target) {
|
||||
currentSound.value = msg.target.ring
|
||||
? `${msg.target.ring}环`
|
||||
: "未上靶";
|
||||
audioManager.play(currentSound.value);
|
||||
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) {
|
||||
@@ -123,7 +124,6 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
|
||||
const playSound = (key) => {
|
||||
currentSound.value = key;
|
||||
audioManager.play(key);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user