完成打乱斗数据调试
This commit is contained in:
@@ -46,14 +46,14 @@ const onClick = debounce(async () => {
|
||||
loading.value = true;
|
||||
const result = await getBattleAPI();
|
||||
if (result && result.matchId) {
|
||||
// await uni.$checkAudio();
|
||||
if (result.way === 1) {
|
||||
await uni.$checkAudio();
|
||||
if (result.mode <= 3) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
} else if (result.way === 2) {
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-match?battleId=${result.matchId}`,
|
||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -5,7 +5,7 @@ import AppBackground from "@/components/AppBackground.vue";
|
||||
import Header from "@/components/Header.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import BackToGame from "@/components/BackToGame.vue";
|
||||
import { getCurrentGameAPI, laserAimAPI } from "@/apis";
|
||||
import { laserAimAPI, getBattleAPI } from "@/apis";
|
||||
import { capsuleHeight, debounce } from "@/util";
|
||||
import AudioManager from "@/audioManager";
|
||||
const props = defineProps({
|
||||
@@ -111,15 +111,19 @@ const backToGame = debounce(async () => {
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
const game = await getCurrentGameAPI();
|
||||
if (!game || !game.gameId) {
|
||||
uni.showToast({
|
||||
title: "没有进行中的对局",
|
||||
icon: "none",
|
||||
});
|
||||
const result = await getBattleAPI();
|
||||
if (result && result.matchId) {
|
||||
await checkAudioProgress();
|
||||
if (result.mode <= 3) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
showHint.value = false;
|
||||
} catch (error) {
|
||||
console.error("获取当前游戏失败:", error);
|
||||
} finally {
|
||||
|
||||
@@ -44,6 +44,8 @@ const createRoom = debounce(async () => {
|
||||
url: "/pages/battle-room?roomNumber=" + result.number,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ const signin = () => {
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const showLoader = ref(false);
|
||||
const pointBook = ref(null);
|
||||
const showProgress = ref(false);
|
||||
const heat = ref(0);
|
||||
@@ -80,20 +79,12 @@ onMounted(() => {
|
||||
pointBook.value = uni.getStorageSync("last-point-book");
|
||||
}
|
||||
}
|
||||
if (
|
||||
currentPage.route === "pages/team-battle" ||
|
||||
currentPage.route === "pages/melee-match"
|
||||
) {
|
||||
showLoader.value = true;
|
||||
}
|
||||
if (currentPage.route === "pages/team-battle") {
|
||||
showProgress.value = true;
|
||||
}
|
||||
uni.$on("update-header-loading", updateLoading);
|
||||
uni.$on("update-hot", updateHot);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
uni.$off("update-header-loading", updateLoading);
|
||||
uni.$off("update-hot", updateHot);
|
||||
});
|
||||
</script>
|
||||
@@ -161,12 +152,6 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<image
|
||||
:style="{ opacity: showLoader && loading ? 0 : 0 }"
|
||||
src="../static/btn-loading.png"
|
||||
mode="widthFix"
|
||||
class="loading"
|
||||
/>
|
||||
<view v-if="pointBook" class="point-book-info">
|
||||
<text>{{ pointBook.bowType.name }}</text>
|
||||
<text>{{ pointBook.distance }} 米</text>
|
||||
@@ -230,14 +215,6 @@ onBeforeUnmount(() => {
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
}
|
||||
.loading {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-left: 10px;
|
||||
transition: all 0.3s ease;
|
||||
background-blend-mode: darken;
|
||||
animation: rotate 2s linear infinite;
|
||||
}
|
||||
.point-book-info {
|
||||
color: #333;
|
||||
position: fixed;
|
||||
|
||||
@@ -3,7 +3,7 @@ import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const { user } = storeToRefs(useStore());
|
||||
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
player: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
@@ -23,7 +23,10 @@ const rowCount = new Array(6).fill(0);
|
||||
:style="{ borderColor: player.id === user.id ? '#FED847' : '#fff3' }"
|
||||
>
|
||||
<image
|
||||
:style="{ opacity: scores.length === 12 ? 1 : 0 }"
|
||||
:style="{
|
||||
opacity:
|
||||
(scores[0] || []).length + (scores[1] || []).length === 12 ? 1 : 0,
|
||||
}"
|
||||
src="../static/checked-green.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
@@ -32,20 +35,24 @@ const rowCount = new Array(6).fill(0);
|
||||
<view>
|
||||
<view>
|
||||
<view v-for="(_, index) in rowCount" :key="index">
|
||||
<text>{{ scores[index] ? `${scores[index].ring}环` : "-" }}</text>
|
||||
<text>{{
|
||||
scores[0] && scores[0][index] ? `${scores[0][index].ring}环` : "-"
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view v-for="(_, index) in rowCount" :key="index">
|
||||
<text>{{
|
||||
scores[index + 6] ? `${scores[index + 6].ring}环` : "-"
|
||||
scores[1] && scores[1][index] ? `${scores[0][index].ring}环` : "-"
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text
|
||||
>{{
|
||||
scores.map((s) => s.ring).reduce((last, next) => last + next, 0)
|
||||
scores
|
||||
.map((s) => s.reduce((last, next) => last + next.ring, 0))
|
||||
.reduce((last, next) => last + next, 0)
|
||||
}}环</text
|
||||
>
|
||||
</view>
|
||||
|
||||
@@ -9,7 +9,7 @@ defineProps({
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
scores: {
|
||||
arrows: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
@@ -21,10 +21,6 @@ defineProps({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
totalRing: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
const rowCount = new Array(6).fill(0);
|
||||
</script>
|
||||
@@ -60,19 +56,19 @@ const rowCount = new Array(6).fill(0);
|
||||
<view>
|
||||
<view>
|
||||
<view v-for="(_, index) in rowCount" :key="index">
|
||||
<text>{{ scores[index] ? `${scores[index].ring}环` : "-" }}</text>
|
||||
<text>{{ arrows[index] ? `${arrows[index].ring}环` : "-" }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view v-for="(_, index) in rowCount" :key="index">
|
||||
<text>{{
|
||||
scores[index + 6] ? `${scores[index + 6].ring}环` : "-"
|
||||
arrows[index + 6] ? `${arrows[index + 6].ring}环` : "-"
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>{{ totalRing }}环</text>
|
||||
<text>{{ arrows.reduce((last, next) => last + next.ring, 0) }}环</text>
|
||||
<text>积分{{ totalScore }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -124,15 +124,16 @@ const seats = new Array(props.total).fill(1);
|
||||
right: 0;
|
||||
} */
|
||||
.player-unknow {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
margin: 0 24rpx;
|
||||
border: 1px solid #fff3;
|
||||
border: 1rpx solid #fff3;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #69686866;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.player-unknow > image {
|
||||
width: 40%;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||
import audioManager from "@/audioManager";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { getDirectionText } from "@/util";
|
||||
|
||||
import useStore from "@/store";
|
||||
@@ -116,62 +116,77 @@ const updateSound = () => {
|
||||
audioManager.setMuted(!sound.value);
|
||||
};
|
||||
|
||||
async function onReceiveMessage(messages = []) {
|
||||
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;
|
||||
async function onReceiveMessage(msg) {
|
||||
if (Array.isArray(msg)) return;
|
||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
||||
audioManager.play("比赛开始");
|
||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
||||
audioManager.play("比赛结束");
|
||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||
if (msg.shootData.playerId !== user.value.id) return;
|
||||
if (msg.shootData) {
|
||||
let key = [];
|
||||
key.push(msg.shootData.ring ? `${msg.shootData.ring}环` : "未上靶");
|
||||
if (!msg.shootData.ring)
|
||||
key.push(`向${getDirectionText(msg.shootData.angle)}调整`);
|
||||
audioManager.play(key, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 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) => {
|
||||
|
||||
Reference in New Issue
Block a user