完成打乱斗数据调试
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { getDirectionText } from "@/util";
|
||||
|
||||
import useStore from "@/store";
|
||||
@@ -116,62 +116,77 @@ const updateSound = () => {
|
||||
audioManager.setMuted(!sound.value);
|
||||
};
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
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;
|
||||
async function onReceiveMessage(msg) {
|
||||
if (Array.isArray(msg)) return;
|
||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||
audioManager.play("比赛开始");
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
audioManager.play("比赛结束");
|
||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
if (msg.shootData.playerId !== user.value.id) return;
|
||||
if (msg.shootData) {
|
||||
let key = [];
|
||||
key.push(msg.shootData.ring ? `${msg.shootData.ring}环` : "未上靶");
|
||||
if (!msg.shootData.ring)
|
||||
key.push(`向${getDirectionText(msg.shootData.angle)}调整`);
|
||||
audioManager.play(key, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 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) => {
|
||||
|
||||
Reference in New Issue
Block a user