调试多v多房间功能

This commit is contained in:
kron
2026-02-05 18:06:55 +08:00
parent 93c549109f
commit 4cfa097cc8
7 changed files with 32 additions and 121 deletions

View File

@@ -48,83 +48,7 @@ const updateSound = () => {
async function onReceiveMessage(message) {
if (ended.value) return;
if (Array.isArray(message)) {
message.forEach((msg) => {
// if (msg.constructor === MESSAGETYPES.ShootResult) {
// if (melee.value && msg.userId !== user.value.id) return;
// if (msg.userId === user.value.id) currentShot.value++;
// if (msg.battleInfo && msg.userId === user.value.id) {
// const players = [
// ...(msg.battleInfo.blueTeam || []),
// ...(msg.battleInfo.redTeam || []),
// ];
// const currentPlayer = players.find((p) => p.id === msg.userId);
// currentShot.value = 0;
// try {
// if (
// currentPlayer &&
// currentPlayer.shotHistory &&
// currentPlayer.shotHistory[msg.battleInfo.currentRound]
// ) {
// currentShot.value =
// currentPlayer.shotHistory[msg.battleInfo.currentRound].length;
// }
// } catch (_) {}
// }
// 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) {
// const { config } = msg.groupUserStatus;
// if (config && config.mode === 1) {
// totalShot.value = config.teamSize === 2 ? 3 : 2;
// }
// currentRoundEnded.value = true;
// audioManager.play("比赛开始");
// } else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
// melee.value = true;
// halfTime.value = false;
// audioManager.play("比赛开始");
// } else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
// currentShot.value = 0;
// if (msg.preRoundResult && msg.preRoundResult.currentRound) {
// currentRound.value = msg.preRoundResult.currentRound;
// currentRoundEnded.value = true;
// }
// } else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
// halfTime.value = true;
// audioManager.play("中场休息");
// } else if (msg.constructor === MESSAGETYPES.MatchOver) {
// audioManager.play("比赛结束");
// } else if (msg.constructor === MESSAGETYPES.FinalShoot) {
// totalShot.value = 0;
// audioManager.play("决金箭轮");
// tips.value = "即将开始...";
// currentRoundEnded.value = false;
// } else if (msg.constructor === MESSAGETYPES.MatchOver) {
// ended.value = true;
// } else if (msg.constructor === MESSAGETYPES.BackToGame) {
// if (msg.battleInfo) {
// melee.value = msg.battleInfo.config.mode === 2;
// }
// }
});
return;
}
if (Array.isArray(message)) return;
if (message.type === MESSAGETYPESV2.BattleStart) {
melee.value = Boolean(message.mode);
totalShot.value = message.mode === 1 ? 3 : 2;

View File

@@ -79,7 +79,7 @@ const seats = new Array(props.total).fill(1);
}
.avatar > text {
background-color: #2c261fb3;
border-color: #a3793f66;
border: 1rpx solid #a3793f66;
color: #fed847;
font-size: 16rpx;
border-radius: 20rpx;

View File

@@ -36,10 +36,12 @@ const updateTimer = (value) => {
};
onMounted(() => {
audioManager.play("请射箭测试距离");
timer.value = setInterval(() => {
if (count.value > 0) count.value -= 1;
else clearInterval(timer.value);
}, 1000);
if (props.isBattle) {
timer.value = setInterval(() => {
count.value -= 1;
if (count.value < 0) clearInterval(timer.value);
}, 1000);
}
uni.$on("update-timer", updateTimer);
});
onBeforeUnmount(() => {
@@ -117,11 +119,12 @@ onBeforeUnmount(() => {
</view>
<view v-if="isBattle" class="ready-timer">
<image src="../static/test-tip.png" mode="widthFix" />
<view>
<view v-if="count >= 0">
<text>具体正式比赛还有</text>
<text>{{ count }}</text>
<text></text>
</view>
<view v-else> 进入中... </view>
</view>
</view>
</template>