优化轮到你了声音播放
This commit is contained in:
@@ -18,7 +18,6 @@ const ended = ref(false);
|
|||||||
const halfTime = ref(false);
|
const halfTime = ref(false);
|
||||||
const currentShot = ref(0);
|
const currentShot = ref(0);
|
||||||
const totalShot = ref(0);
|
const totalShot = ref(0);
|
||||||
const yourTurn = ref(false);
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => tips.value,
|
() => tips.value,
|
||||||
@@ -37,9 +36,8 @@ watch(
|
|||||||
// 延迟播放队伍提示音
|
// 延迟播放队伍提示音
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
if (key && !yourTurn.value) audioManager.play(key);
|
if (key) audioManager.play(newVal.includes("你") ? "轮到你了" : key);
|
||||||
currentRoundEnded.value = false;
|
currentRoundEnded.value = false;
|
||||||
yourTurn.value = false;
|
|
||||||
},
|
},
|
||||||
currentRoundEnded.value ? 1000 : 0
|
currentRoundEnded.value ? 1000 : 0
|
||||||
);
|
);
|
||||||
@@ -81,8 +79,6 @@ async function onReceiveMessage(messages = []) {
|
|||||||
: "未上靶";
|
: "未上靶";
|
||||||
audioManager.play(currentSound.value);
|
audioManager.play(currentSound.value);
|
||||||
}
|
}
|
||||||
} else if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
|
||||||
yourTurn.value = user.value.id === msg.userId;
|
|
||||||
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
||||||
if (msg.userId === user.value.id) {
|
if (msg.userId === user.value.id) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -159,7 +155,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<text>{{ tips }}</text>
|
<text>{{ (tips || "").replace(/你/g, "") }}</text>
|
||||||
<text v-if="totalShot > 0"> ({{ currentShot }}/{{ totalShot }}) </text>
|
<text v-if="totalShot > 0"> ({{ currentShot }}/{{ totalShot }}) </text>
|
||||||
<button v-if="!!tips" hover-class="none" @click="updateSound">
|
<button v-if="!!tips" hover-class="none" @click="updateSound">
|
||||||
<image
|
<image
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image :src="RoundGoldImages[props.currentRound]" mode="widthFix" />
|
<image :src="RoundGoldImages[props.currentRound]" mode="widthFix" />
|
||||||
<view>
|
<view
|
||||||
|
:style="{
|
||||||
|
justifyContent: tips.includes('红队') ? 'flex-end' : 'flex-start',
|
||||||
|
}"
|
||||||
|
>
|
||||||
<view
|
<view
|
||||||
:style="{
|
:style="{
|
||||||
width: `${(remain / total) * 100}%`,
|
width: `${(remain / total) * 100}%`,
|
||||||
@@ -85,7 +89,7 @@ onBeforeUnmount(() => {
|
|||||||
.container > image {
|
.container > image {
|
||||||
width: 360rpx;
|
width: 360rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
transform: translateY(24rpx);
|
transform: translateY(20rpx);
|
||||||
}
|
}
|
||||||
.container > view:last-child {
|
.container > view:last-child {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -95,6 +99,8 @@ onBeforeUnmount(() => {
|
|||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
.container > view:last-child > view {
|
.container > view:last-child > view {
|
||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
|
|||||||
@@ -165,14 +165,15 @@ function recoverData(battleInfo) {
|
|||||||
.filter((item) => !!item.playerId)
|
.filter((item) => !!item.playerId)
|
||||||
.sort((a, b) => a.shotTimeUnix - b.shotTimeUnix);
|
.sort((a, b) => a.shotTimeUnix - b.shotTimeUnix);
|
||||||
}
|
}
|
||||||
// if (battleInfo.status !== 11) return;
|
|
||||||
if (battleInfo.firePlayerIndex) {
|
if (battleInfo.firePlayerIndex) {
|
||||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||||
const redPlayer = redTeam.value.find(
|
const redPlayer = redTeam.value.find(
|
||||||
(item) => item.id === currentShooterId.value
|
(item) => item.id === currentShooterId.value
|
||||||
);
|
);
|
||||||
tips.value = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||||
uni.$emit("update-tips", tips.value);
|
if (battleInfo.firePlayerIndex === user.value.id) nextTips += "你";
|
||||||
|
tips.value = nextTips;
|
||||||
|
uni.$emit("update-tips", nextTips);
|
||||||
}
|
}
|
||||||
if (battleInfo.fireTime > 0) {
|
if (battleInfo.fireTime > 0) {
|
||||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||||
@@ -198,8 +199,8 @@ async function onReceiveMessage(messages = []) {
|
|||||||
const redPlayer = redTeam.value.find(
|
const redPlayer = redTeam.value.find(
|
||||||
(item) => item.id === currentShooterId.value
|
(item) => item.id === currentShooterId.value
|
||||||
);
|
);
|
||||||
if (msg.userId === user.value.id) audioManager.play("轮到你了");
|
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||||
const nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
if (msg.userId === user.value.id) nextTips += "你";
|
||||||
if (nextTips !== tips.value) {
|
if (nextTips !== tips.value) {
|
||||||
tips.value = nextTips;
|
tips.value = nextTips;
|
||||||
uni.$emit("update-tips", tips.value);
|
uni.$emit("update-tips", tips.value);
|
||||||
@@ -209,27 +210,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
// if (currentShooterId.value !== msg.userId) return;
|
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||||
// 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.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
const result = msg.preRoundResult;
|
const result = msg.preRoundResult;
|
||||||
|
|||||||
Reference in New Issue
Block a user