房间比赛流程同步
This commit is contained in:
@@ -57,6 +57,7 @@ defineProps({
|
||||
.container {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.container > view:first-child {
|
||||
position: relative;
|
||||
|
||||
@@ -49,10 +49,6 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
start: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
default: "solo", // solo 单排,team 双排
|
||||
@@ -201,7 +197,6 @@ const simulShoot = async () => {
|
||||
.container {
|
||||
width: calc(100% - 30px);
|
||||
padding: 15px;
|
||||
/* overflow: hidden; */
|
||||
position: relative;
|
||||
}
|
||||
.target {
|
||||
|
||||
@@ -10,6 +10,7 @@ export const MESSAGETYPES = {
|
||||
SomeGuyIsReady: parseInt("0xAEE8C236"), // 2934489654
|
||||
MatchOver: parseInt("0xB7815EEF"), // 3078708975
|
||||
StartCount: parseInt("0xD7B0DD2F"), // 3618692399
|
||||
FinalShoot: parseInt("0x5953C8A1"), // 1498663073
|
||||
RoundPoint: 4061248646,
|
||||
UserEnterRoom: 2133805521,
|
||||
UserExitRoom: 3896523333,
|
||||
|
||||
@@ -35,8 +35,10 @@ const players = ref([]);
|
||||
const currentRound = ref(1);
|
||||
const totalRounds = ref(0);
|
||||
const start = ref(false);
|
||||
const startCount = ref(false);
|
||||
const power = ref(0);
|
||||
const scores = ref([]);
|
||||
const blueScores = ref([]);
|
||||
const tips = ref("即将开始...");
|
||||
const roundResults = ref([]);
|
||||
const redPoints = ref(0);
|
||||
@@ -46,6 +48,9 @@ const currentBluePoint = ref(0);
|
||||
const showRoundTip = ref(false);
|
||||
const playersScores = ref({});
|
||||
const showModal = ref(false);
|
||||
const halfTimeTip = ref(false);
|
||||
const total = ref(90);
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.roomNumber) {
|
||||
roomNumber.value = options.roomNumber;
|
||||
@@ -63,6 +68,7 @@ onLoad(async (options) => {
|
||||
return false;
|
||||
});
|
||||
if (result.battleType === 1) {
|
||||
total.value = 15;
|
||||
if (user.value.id !== owner.value.id) {
|
||||
opponent.value = {
|
||||
id: user.value.id,
|
||||
@@ -159,7 +165,7 @@ async function onReceiveMessage(messages = []) {
|
||||
players.value = players.value.filter((p) => p.id !== msg.userId);
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
||||
if (msg.constructor === MESSAGETYPES.RoomDestroy && !battleId.value) {
|
||||
uni.showToast({
|
||||
title: "房间已解散",
|
||||
icon: "none",
|
||||
@@ -182,12 +188,21 @@ async function onReceiveMessage(messages = []) {
|
||||
seq.value += 1;
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
start.value = true;
|
||||
startCount.value = true;
|
||||
seq.value += 1;
|
||||
timerSeq.value = 0;
|
||||
tips.value = "请连续射出6支箭";
|
||||
scores.value = [];
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||
if (room.value.battleType === 1) {
|
||||
scores.value = [];
|
||||
blueScores.value = [];
|
||||
seq.value += 1;
|
||||
currentShooterId.value = msg.userId;
|
||||
if (owner.id !== currentShooterId.value) {
|
||||
if (redTeam.value[0].id === currentShooterId.value) {
|
||||
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
} else {
|
||||
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
@@ -196,7 +211,12 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||
if (room.value.battleType === 1) {
|
||||
scores.value = [msg.target];
|
||||
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||
if (isRed) {
|
||||
scores.value = [msg.target];
|
||||
} else {
|
||||
blueScores.value = [msg.target];
|
||||
}
|
||||
}
|
||||
if (room.value.battleType === 2) {
|
||||
scores.value.push(msg.target);
|
||||
@@ -205,26 +225,32 @@ async function onReceiveMessage(messages = []) {
|
||||
if (playersScores.value[msg.userId])
|
||||
playersScores.value[msg.userId].push(msg.target);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.RoundPoint) {
|
||||
bluePoints.value += msg.blueScore;
|
||||
redPoints.value += msg.redScore;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
const result = msg.preRoundResult;
|
||||
scores.value = [];
|
||||
currentShooterId.value = 0;
|
||||
currentBluePoint.value = result.blueScore;
|
||||
currentRedPoint.value = result.redScore;
|
||||
showRoundTip.value = true;
|
||||
if (
|
||||
result.currentRound > 0 &&
|
||||
result.currentRound < totalRounds.value
|
||||
) {
|
||||
// 开始下一轮;
|
||||
roundResults.value = result.roundResults;
|
||||
currentRound.value = result.currentRound + 1;
|
||||
if (room.value.battleType === 1) {
|
||||
const result = msg.preRoundResult;
|
||||
scores.value = [];
|
||||
blueScores.value = [];
|
||||
currentShooterId.value = 0;
|
||||
currentBluePoint.value = result.blueScore;
|
||||
currentRedPoint.value = result.redScore;
|
||||
bluePoints.value += result.blueScore;
|
||||
redPoints.value += result.redScore;
|
||||
showRoundTip.value = true;
|
||||
if (
|
||||
result.currentRound > 0 &&
|
||||
result.currentRound < totalRounds.value
|
||||
) {
|
||||
// 开始下一轮;
|
||||
roundResults.value = result.roundResults;
|
||||
currentRound.value = result.currentRound + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||
startCount.value = false;
|
||||
halfTimeTip.value = true;
|
||||
tips.value = "准备下半场";
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/battle-result?battleId=${msg.id}&winner=${msg.endStatus.winner}`,
|
||||
@@ -341,7 +367,12 @@ onUnmounted(() => {
|
||||
/>
|
||||
</view>
|
||||
<view v-if="step === 3">
|
||||
<ShootProgress :tips="tips" :seq="seq" :start="start" />
|
||||
<ShootProgress
|
||||
:tips="tips"
|
||||
:seq="seq"
|
||||
:start="start && startCount"
|
||||
:total="total"
|
||||
/>
|
||||
<PlayersRow
|
||||
v-if="room.battleType === 1"
|
||||
:blueTeam="blueTeam"
|
||||
@@ -349,10 +380,13 @@ onUnmounted(() => {
|
||||
:currentShooterId="currentShooterId"
|
||||
/>
|
||||
<BowTarget
|
||||
:power="power"
|
||||
:mode="room.battleType ? 'team' : 'solo'"
|
||||
:showE="start && user.id === currentShooterId"
|
||||
:power="start ? power : 0"
|
||||
:currentRound="currentRound"
|
||||
:totalRound="totalRounds"
|
||||
:scores="scores"
|
||||
:blueScores="blueScores"
|
||||
/>
|
||||
<BattleFooter
|
||||
v-if="room.battleType === 1"
|
||||
@@ -383,6 +417,16 @@ onUnmounted(() => {
|
||||
</view>
|
||||
</view>
|
||||
</ScreenHint>
|
||||
<ScreenHint
|
||||
:show="halfTimeTip"
|
||||
mode="small"
|
||||
:onClose="() => (halfTimeTip = false)"
|
||||
>
|
||||
<view class="half-time-tip">
|
||||
<text>上半场结束,休息一下吧:)</text>
|
||||
<text>20秒后开始下半场</text>
|
||||
</view>
|
||||
</ScreenHint>
|
||||
<SModal :show="showModal" :onClose="() => (showModal = false)">
|
||||
<view class="btns">
|
||||
<SButton :onClick="exitRoom" width="200px" :rounded="20">
|
||||
|
||||
@@ -151,15 +151,17 @@ onUnmounted(() => {
|
||||
:totalRound="start ? 12 : 0"
|
||||
:scores="scores"
|
||||
/>
|
||||
<PlayerScore
|
||||
v-if="start"
|
||||
v-for="(player, index) in players"
|
||||
:key="index"
|
||||
:name="player.name"
|
||||
:avatar="player.avatar"
|
||||
:scores="playersScores[player.id]"
|
||||
:done="playersScores[player.id].length === 12"
|
||||
/>
|
||||
<view :style="{ paddingBottom: '20px' }">
|
||||
<PlayerScore
|
||||
v-if="start"
|
||||
v-for="(player, index) in players"
|
||||
:key="index"
|
||||
:name="player.name"
|
||||
:avatar="player.avatar"
|
||||
:scores="playersScores[player.id]"
|
||||
:done="playersScores[player.id].length === 12"
|
||||
/>
|
||||
</view>
|
||||
<Timer :seq="timerSeq" :callBack="readyToGo" />
|
||||
<ScreenHint
|
||||
:show="halfTimeTip"
|
||||
|
||||
@@ -107,13 +107,10 @@ async function onReceiveMessage(messages = []) {
|
||||
blueScores.value = [msg.target];
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.RoundPoint) {
|
||||
// bluePoints.value += msg.blueScore;
|
||||
// redPoints.value += msg.redScore;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||
const result = msg.preRoundResult;
|
||||
scores.value = [];
|
||||
blueScores.value = [];
|
||||
currentShooterId.value = 0;
|
||||
currentBluePoint.value = result.blueScore;
|
||||
currentRedPoint.value = result.redScore;
|
||||
|
||||
Reference in New Issue
Block a user