逻辑完善
This commit is contained in:
@@ -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("比赛开始");
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -38,6 +38,7 @@ export const MESSAGETYPESV2 = {
|
||||
NewRound: 5,
|
||||
BattleEnd: 6,
|
||||
HalfRest: 7,
|
||||
TestDistance: 8,
|
||||
};
|
||||
|
||||
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user