添加为上靶的方向指示
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
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();
|
||||
const { user } = storeToRefs(store);
|
||||
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
@@ -41,7 +44,6 @@ const barColor = ref("#fed847");
|
||||
const remain = ref(props.total);
|
||||
const timer = ref(null);
|
||||
const sound = ref(true);
|
||||
const currentSound = ref("");
|
||||
const currentRound = ref(props.currentRound);
|
||||
const currentRoundEnded = ref(false);
|
||||
const ended = ref(false);
|
||||
@@ -53,7 +55,7 @@ watch(
|
||||
let key = "";
|
||||
if (newVal.includes("红队")) key = "请红方射箭";
|
||||
if (newVal.includes("蓝队")) key = "请蓝方射箭";
|
||||
if (key && sound.value) {
|
||||
if (key) {
|
||||
if (currentRoundEnded.value) {
|
||||
currentRound.value += 1;
|
||||
currentRoundEnded.value = false;
|
||||
@@ -118,11 +120,11 @@ const updateRemain = (value) => {
|
||||
|
||||
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 (
|
||||
(props.battleId && msg.constructor === MESSAGETYPES.ShootResult) ||
|
||||
@@ -130,10 +132,11 @@ async function onReceiveMessage(messages = []) {
|
||||
) {
|
||||
if (props.melee && msg.userId !== user.value.id) return;
|
||||
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) {
|
||||
@@ -164,7 +167,6 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
|
||||
const playSound = (key) => {
|
||||
currentSound.value = key;
|
||||
audioManager.play(key);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user