优化轮到你了声音播放
This commit is contained in:
@@ -165,14 +165,15 @@ function recoverData(battleInfo) {
|
||||
.filter((item) => !!item.playerId)
|
||||
.sort((a, b) => a.shotTimeUnix - b.shotTimeUnix);
|
||||
}
|
||||
// if (battleInfo.status !== 11) return;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
const redPlayer = redTeam.value.find(
|
||||
(item) => item.id === currentShooterId.value
|
||||
);
|
||||
tips.value = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||
uni.$emit("update-tips", tips.value);
|
||||
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||
if (battleInfo.firePlayerIndex === user.value.id) nextTips += "你";
|
||||
tips.value = nextTips;
|
||||
uni.$emit("update-tips", nextTips);
|
||||
}
|
||||
if (battleInfo.fireTime > 0) {
|
||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||
@@ -198,8 +199,8 @@ async function onReceiveMessage(messages = []) {
|
||||
const redPlayer = redTeam.value.find(
|
||||
(item) => item.id === currentShooterId.value
|
||||
);
|
||||
if (msg.userId === user.value.id) audioManager.play("轮到你了");
|
||||
const nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||
if (msg.userId === user.value.id) nextTips += "你";
|
||||
if (nextTips !== tips.value) {
|
||||
tips.value = nextTips;
|
||||
uni.$emit("update-tips", tips.value);
|
||||
@@ -209,27 +210,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
// if (currentShooterId.value !== msg.userId) return;
|
||||
// const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||
// if (isRed) scores.value.push({ ...msg.target });
|
||||
// else blueScores.value.push({ ...msg.target });
|
||||
// // 下标从0开始的,要减1
|
||||
// if (!roundResults.value[currentRound.value - 1]) {
|
||||
// roundResults.value.push({
|
||||
// redArrows: [],
|
||||
// blueArrows: [],
|
||||
// gold: goldenRound.value > 0,
|
||||
// });
|
||||
// }
|
||||
// roundResults.value[currentRound.value - 1][
|
||||
// isRed ? "redArrows" : "blueArrows"
|
||||
// ].push({ ...msg.target });
|
||||
if (msg.battleInfo) {
|
||||
recoverData(msg.battleInfo);
|
||||
// if (isFinalShoot.value) {
|
||||
// uni.setStorageSync(`current-battle-${Date.now()}`, msg.battleInfo);
|
||||
// }
|
||||
}
|
||||
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
const result = msg.preRoundResult;
|
||||
|
||||
Reference in New Issue
Block a user