逻辑完善
This commit is contained in:
@@ -50,7 +50,7 @@ async function onReceiveMessage(message) {
|
|||||||
if (ended.value) return;
|
if (ended.value) return;
|
||||||
if (Array.isArray(message)) return;
|
if (Array.isArray(message)) return;
|
||||||
if (message.type === MESSAGETYPESV2.BattleStart) {
|
if (message.type === MESSAGETYPESV2.BattleStart) {
|
||||||
melee.value = Boolean(message.mode);
|
melee.value = Boolean(message.mode > 3);
|
||||||
totalShot.value = message.mode === 1 ? 3 : 2;
|
totalShot.value = message.mode === 1 ? 3 : 2;
|
||||||
currentRoundEnded.value = true;
|
currentRoundEnded.value = true;
|
||||||
audioManager.play("比赛开始");
|
audioManager.play("比赛开始");
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ const updateSound = () => {
|
|||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(msg) {
|
||||||
if (Array.isArray(msg)) return;
|
if (Array.isArray(msg)) return;
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||||
|
halfTime.value = false;
|
||||||
audioManager.play("比赛开始");
|
audioManager.play("比赛开始");
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||||
audioManager.play("比赛结束");
|
audioManager.play("比赛结束");
|
||||||
@@ -135,62 +136,10 @@ async function onReceiveMessage(msg) {
|
|||||||
key.push(`向${getDirectionText(msg.shootData.angle)}调整`);
|
key.push(`向${getDirectionText(msg.shootData.angle)}调整`);
|
||||||
audioManager.play(key, false);
|
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) => {
|
const playSound = (key) => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import BowPower from "@/components/BowPower.vue";
|
|||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import { MESSAGETYPES } from "@/constants";
|
import { MESSAGETYPESV2 } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@@ -26,7 +26,6 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
const arrow = ref({});
|
const arrow = ref({});
|
||||||
const distance = ref(0);
|
const distance = ref(0);
|
||||||
const debugInfo = ref("");
|
|
||||||
const showsimul = ref(false);
|
const showsimul = ref(false);
|
||||||
const count = ref(props.count);
|
const count = ref(props.count);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
@@ -49,19 +48,13 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("update-timer", updateTimer);
|
uni.$off("update-timer", updateTimer);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onReceiveMessage(messages = []) {
|
async function onReceiveMessage(msg) {
|
||||||
if (!Array.isArray(messages)) return;
|
if (Array.isArray(msg)) return;
|
||||||
messages.forEach((msg) => {
|
if (msg.type === MESSAGETYPESV2.TestDistance) {
|
||||||
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
distance.value = Number((msg.shootData.distance / 100).toFixed(2));
|
||||||
arrow.value = msg.target;
|
if (distance.value >= 5) audioManager.play("距离合格");
|
||||||
distance.value = Number((msg.target.dst / 100).toFixed(2));
|
else audioManager.play("距离不足");
|
||||||
debugInfo.value = msg.target;
|
|
||||||
audioManager.play("距离合格");
|
|
||||||
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
|
||||||
distance.value = Number((msg.target.dst / 100).toFixed(2));
|
|
||||||
audioManager.play("距离不足");
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export const MESSAGETYPESV2 = {
|
|||||||
NewRound: 5,
|
NewRound: 5,
|
||||||
BattleEnd: 6,
|
BattleEnd: 6,
|
||||||
HalfRest: 7,
|
HalfRest: 7,
|
||||||
|
TestDistance: 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
||||||
|
|||||||
@@ -71,11 +71,7 @@ function recoverData(battleInfo, { force = false } = {}) {
|
|||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
||||||
console.log(
|
console.log(`当前轮已进行${remain}秒`);
|
||||||
`当前轮已进行${remain}秒,${Date.now()},${
|
|
||||||
battleInfo.current.startTimeText
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
if (remain > 0 && remain < 90) {
|
if (remain > 0 && remain < 90) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.$emit("update-remain", 90 - remain - 0.2);
|
uni.$emit("update-remain", 90 - remain - 0.2);
|
||||||
|
|||||||
@@ -71,11 +71,7 @@ const recoverData = (battleInfo, { force = false, arrowOnly = false } = {}) => {
|
|||||||
uni.$emit("update-tips", nextTips);
|
uni.$emit("update-tips", nextTips);
|
||||||
if (force) {
|
if (force) {
|
||||||
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
||||||
console.log(
|
console.log(`当前轮已进行${remain}秒`);
|
||||||
`当前轮已进行${remain}秒,${Date.now()},${
|
|
||||||
battleInfo.current.startTimeText
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
if (remain > 0 && remain < 15) {
|
if (remain > 0 && remain < 15) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.$emit("update-remain", 15 - remain - 0.2);
|
uni.$emit("update-remain", 15 - remain - 0.2);
|
||||||
|
|||||||
Reference in New Issue
Block a user