房间大乱斗调试
This commit is contained in:
@@ -1,22 +1,30 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
|
total: {
|
||||||
|
type: Number,
|
||||||
|
default: 10,
|
||||||
|
},
|
||||||
players: {
|
players: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const seats = new Array(10).fill(1);
|
const seats = new Array(props.total).fill(1);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="players">
|
<view class="players">
|
||||||
<view v-for="(_, index) in seats" :key="index">
|
<view v-for="(_, index) in seats" :key="index">
|
||||||
<image src="../static/player-bg.png" mode="widthFix" />
|
<image src="../static/player-bg.png" mode="widthFix" />
|
||||||
<image v-if="players[index]" src="../static/avatar.png" mode="widthFix" />
|
<image
|
||||||
|
v-if="players[index]"
|
||||||
|
:src="players[index].avatar"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
<view v-else class="player-unknow">
|
<view v-else class="player-unknow">
|
||||||
<image src="../static/question-mark.png" mode="widthFix" />
|
<image src="../static/question-mark.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
<text v-if="players[index]">选手{{ index + 1 }}</text>
|
<text v-if="players[index]">{{ players[index].name }}</text>
|
||||||
<text v-else :style="{ color: '#fff9' }">虚位以待</text>
|
<text v-else :style="{ color: '#fff9' }">虚位以待</text>
|
||||||
<view v-if="index === 0" class="founder">创建者</view>
|
<view v-if="index === 0" class="founder">创建者</view>
|
||||||
<image
|
<image
|
||||||
@@ -32,19 +40,20 @@ const seats = new Array(10).fill(1);
|
|||||||
.players {
|
.players {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: flex-start;
|
||||||
column-gap: 15px;
|
-moz-column-gap: 20px;
|
||||||
row-gap: 10px;
|
column-gap: 14px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
padding: 0 14px;
|
||||||
}
|
}
|
||||||
.players > view {
|
.players > view {
|
||||||
width: 45%;
|
width: calc(50% - 7px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
height: 90px;
|
height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.players > view > image:first-child {
|
.players > view > image:first-child {
|
||||||
@@ -54,16 +63,23 @@ const seats = new Array(10).fill(1);
|
|||||||
}
|
}
|
||||||
.players > view > image:nth-child(2) {
|
.players > view > image:nth-child(2) {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
margin: 0 10px;
|
margin: 0 10px;
|
||||||
border: 1px solid #fff;
|
border: 1px solid #fff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
.players > view > text:nth-child(3) {
|
||||||
|
width: 20vw;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
.founder {
|
.founder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: #fed847;
|
background-color: #fed847;
|
||||||
top: 0;
|
top: 0;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-size: 12px;
|
font-size: 10px;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
border-top-left-radius: 10px;
|
border-top-left-radius: 10px;
|
||||||
border-bottom-right-radius: 10px;
|
border-bottom-right-radius: 10px;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ watch(
|
|||||||
:style="{
|
:style="{
|
||||||
width: 100 / (rowCount + 2) + 'vw',
|
width: 100 / (rowCount + 2) + 'vw',
|
||||||
height: 100 / (rowCount + 2) + 'vw',
|
height: 100 / (rowCount + 2) + 'vw',
|
||||||
|
lineHeight: 100 / (rowCount + 2) + 'vw',
|
||||||
fontSize: fontSize + 'px',
|
fontSize: fontSize + 'px',
|
||||||
margin: margin + 'px',
|
margin: margin + 'px',
|
||||||
}"
|
}"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ onLoad(async (options) => {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (result.battleType === 1 && result.count === 2) {
|
if (result.battleType === 1) {
|
||||||
if (user.value.id !== owner.value.id) {
|
if (user.value.id !== owner.value.id) {
|
||||||
opponent.value = {
|
opponent.value = {
|
||||||
id: user.value.id,
|
id: user.value.id,
|
||||||
@@ -76,6 +76,10 @@ onLoad(async (options) => {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (result.battleType === 2) {
|
||||||
|
result.members.forEach((m) => {
|
||||||
|
players.value.push(m.userInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,26 +107,38 @@ async function onReceiveMessage(content) {
|
|||||||
// 这里会掉多次;
|
// 这里会掉多次;
|
||||||
timerSeq.value += 1;
|
timerSeq.value += 1;
|
||||||
battleId.value = msg.id;
|
battleId.value = msg.id;
|
||||||
redTeam.value = msg.groupUserStatus.redTeam;
|
if (room.value.battleType === 1) {
|
||||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
redTeam.value = msg.groupUserStatus.redTeam;
|
||||||
|
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||||
|
}
|
||||||
step.value = 2;
|
step.value = 2;
|
||||||
}
|
}
|
||||||
if (msg.roomNumber === roomNumber.value) {
|
if (msg.roomNumber === roomNumber.value) {
|
||||||
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
||||||
if (room.value.battleType === 1 && room.value.count === 2) {
|
if (room.value.battleType === 1) {
|
||||||
opponent.value = {
|
opponent.value = {
|
||||||
id: msg.userId,
|
id: msg.userId,
|
||||||
name: msg.name,
|
name: msg.name,
|
||||||
avatar: msg.avatar,
|
avatar: msg.avatar,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (room.value.battleType === 2) {
|
||||||
|
players.value.push({
|
||||||
|
id: msg.userId,
|
||||||
|
name: msg.name,
|
||||||
|
avatar: msg.avatar,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
if (!start.value && msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||||
if (room.value.battleType === 1 && room.value.count === 2) {
|
if (room.value.battleType === 1) {
|
||||||
opponent.value = {
|
opponent.value = {
|
||||||
id: "",
|
id: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (room.value.battleType === 2) {
|
||||||
|
players.value = players.value.filter((p) => p.id !== msg.userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -142,19 +158,32 @@ async function onReceiveMessage(content) {
|
|||||||
scores.value = [];
|
scores.value = [];
|
||||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||||
step.value = 3;
|
step.value = 3;
|
||||||
|
if (room.value.battleType === 2) {
|
||||||
|
tips.value = "请在90秒内射完12支箭";
|
||||||
|
seq.value += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||||
scores.value = [];
|
if (room.value.battleType === 1) {
|
||||||
seq.value += 1;
|
scores.value = [];
|
||||||
currentShooterId.value = msg.userId;
|
seq.value += 1;
|
||||||
if (owner.id !== currentShooterId.value) {
|
currentShooterId.value = msg.userId;
|
||||||
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
if (owner.id !== currentShooterId.value) {
|
||||||
} else {
|
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
||||||
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
} else {
|
||||||
|
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
scores.value = [msg.target];
|
if (room.value.battleType === 1) {
|
||||||
|
scores.value = [msg.target];
|
||||||
|
}
|
||||||
|
if (room.value.battleType === 2) {
|
||||||
|
scores.value.push(msg.target);
|
||||||
|
power.value = msg.target.battery;
|
||||||
|
}
|
||||||
|
playersScores.value[msg.userId].push(msg.target);
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.RoundPoint) {
|
if (msg.constructor === MESSAGETYPES.RoundPoint) {
|
||||||
bluePoints.value += msg.blueScore;
|
bluePoints.value += msg.blueScore;
|
||||||
@@ -205,7 +234,7 @@ onUnmounted(() => {
|
|||||||
<text>天赋异禀的弓箭手们,比赛即将开始!</text>
|
<text>天赋异禀的弓箭手们,比赛即将开始!</text>
|
||||||
</view>
|
</view>
|
||||||
</Guide>
|
</Guide>
|
||||||
<view v-if="room.battleType === 1 && room.count === 2" class="team-mode">
|
<view v-if="room.battleType === 1" class="team-mode">
|
||||||
<image src="../static/1v1-bg.png" mode="widthFix" />
|
<image src="../static/1v1-bg.png" mode="widthFix" />
|
||||||
<view>
|
<view>
|
||||||
<view class="player" :style="{ transform: 'translateY(-60px)' }">
|
<view class="player" :style="{ transform: 'translateY(-60px)' }">
|
||||||
@@ -227,23 +256,20 @@ onUnmounted(() => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<PlayerSeats
|
<PlayerSeats
|
||||||
v-if="room.battleType === 2 && room.count === 10"
|
v-if="room.battleType === 2"
|
||||||
|
:total="room.count || 10"
|
||||||
:players="players"
|
:players="players"
|
||||||
/>
|
/>
|
||||||
<view>
|
<view>
|
||||||
<SButton
|
<SButton
|
||||||
v-if="
|
v-if="user.id === owner.id && room.battleType === 1"
|
||||||
user.id === owner.id && room.battleType === 1 && room.count === 2
|
|
||||||
"
|
|
||||||
:disabled="!opponent.id"
|
:disabled="!opponent.id"
|
||||||
:onClick="startGame"
|
:onClick="startGame"
|
||||||
>进入对战</SButton
|
>进入对战</SButton
|
||||||
>
|
>
|
||||||
<SButton
|
<SButton
|
||||||
v-if="
|
v-if="user.id === owner.id && room.battleType === 2"
|
||||||
user.id === owner.id && room.battleType === 2 && room.count === 10
|
:disabled="players.length < 2"
|
||||||
"
|
|
||||||
:disabled="players.length === 1"
|
|
||||||
:onClick="startGame"
|
:onClick="startGame"
|
||||||
>进入大乱斗</SButton
|
>进入大乱斗</SButton
|
||||||
>
|
>
|
||||||
@@ -280,15 +306,11 @@ onUnmounted(() => {
|
|||||||
<view v-if="step === 3">
|
<view v-if="step === 3">
|
||||||
<ShootProgress :tips="tips" :seq="seq" :start="start" />
|
<ShootProgress :tips="tips" :seq="seq" :start="start" />
|
||||||
<PlayersRow
|
<PlayersRow
|
||||||
v-if="room.battleType === 1 && room.count === 2"
|
v-if="room.battleType === 1"
|
||||||
:blueTeam="blueTeam"
|
:blueTeam="blueTeam"
|
||||||
:redTeam="redTeam"
|
:redTeam="redTeam"
|
||||||
:currentShooterId="currentShooterId"
|
:currentShooterId="currentShooterId"
|
||||||
/>
|
/>
|
||||||
<BattleHeader
|
|
||||||
v-if="room.battleType === 2 && room.count === 10"
|
|
||||||
:players="players"
|
|
||||||
/>
|
|
||||||
<BowTarget
|
<BowTarget
|
||||||
:power="power"
|
:power="power"
|
||||||
:currentRound="currentRound"
|
:currentRound="currentRound"
|
||||||
@@ -296,13 +318,13 @@ onUnmounted(() => {
|
|||||||
:scores="scores"
|
:scores="scores"
|
||||||
/>
|
/>
|
||||||
<BattleFooter
|
<BattleFooter
|
||||||
v-if="room.battleType === 1 && room.count === 2"
|
v-if="room.battleType === 1"
|
||||||
:roundResults="roundResults"
|
:roundResults="roundResults"
|
||||||
:redPoints="redPoints"
|
:redPoints="redPoints"
|
||||||
:bluePoints="bluePoints"
|
:bluePoints="bluePoints"
|
||||||
/>
|
/>
|
||||||
<PlayerScore
|
<PlayerScore
|
||||||
v-if="room.battleType === 2 && room.count === 10"
|
v-if="room.battleType === 2"
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in players"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="player.name"
|
:name="player.name"
|
||||||
@@ -341,7 +363,7 @@ onUnmounted(() => {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.player-unknow {
|
.player-unknow {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ onMounted(async () => {
|
|||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click="() => toPage('/pages/my-device')"
|
@click="() => toPage('/pages/my-device')"
|
||||||
/>
|
/>
|
||||||
<text>{{
|
<text v-if="!user.id">我的弓箭</text>
|
||||||
user.id && !device.deviceId ? "请绑定设备" : "我的弓箭"
|
<text v-if="user.id && !device.deviceId">请绑定设备</text>
|
||||||
}}</text>
|
<text v-if="user.id && device.deviceId">{{ device.deviceName }}</text>
|
||||||
<image
|
<image
|
||||||
src="../static/a2@2x.png"
|
src="../static/a2@2x.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@@ -207,6 +207,7 @@ onMounted(async () => {
|
|||||||
top: 67%;
|
top: 67%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
white-space: nowrap;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #b3b3b3;
|
color: #b3b3b3;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user