Merge branch 'new-race-mode' into test
This commit is contained in:
@@ -29,6 +29,33 @@ const updateRemain = (value) => {
|
|||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// zeroThenReset:ToSomeoneShoot 到达时,若进度条仍在倒计时则先瞬间清零(约 150ms 停留)再显示下一玩家满值
|
||||||
|
// 若进度条已到 0(loading 状态),直接切换满值
|
||||||
|
if (value.zeroThenReset) {
|
||||||
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
const wasNonZero = remain.value > 0;
|
||||||
|
// 更新下一玩家颜色和方向(在清零和满值时均生效)
|
||||||
|
currentTeam.value = value.team;
|
||||||
|
if (value.team === 'red') barColor.value = "linear-gradient( 180deg, #FFA0A0 0%, #FF6060 100%)";
|
||||||
|
if (value.team === 'blue') barColor.value = "linear-gradient( 180deg, #9AB3FF 0%, #4288FF 100%)";
|
||||||
|
transitionStyle.value = "none";
|
||||||
|
if (wasNonZero) {
|
||||||
|
// 瞬间清零,停留约 150ms 后切换为满值
|
||||||
|
remain.value = 0;
|
||||||
|
loading.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
remain.value = value.value;
|
||||||
|
loading.value = false;
|
||||||
|
setTimeout(() => { transitionStyle.value = "all 1s linear"; }, 50);
|
||||||
|
}, 150);
|
||||||
|
} else {
|
||||||
|
// 已在底部,直接切换满值
|
||||||
|
remain.value = value.value;
|
||||||
|
loading.value = false;
|
||||||
|
setTimeout(() => { transitionStyle.value = "all 1s linear"; }, 50);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
currentTeam.value = value.team
|
currentTeam.value = value.team
|
||||||
if (value.team === 'red')
|
if (value.team === 'red')
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ const battleWay = ref(0);
|
|||||||
const lastToSomeoneShootKey = ref("");
|
const lastToSomeoneShootKey = ref("");
|
||||||
/** 控制设备离线提示弹窗的显示状态 */
|
/** 控制设备离线提示弹窗的显示状态 */
|
||||||
const showOfflineModal = ref(false);
|
const showOfflineModal = ref(false);
|
||||||
/** 待延迟发出的进度条重置队伍(ShootResult 报环期间暂缓切换,报环音频结束后再发 reset) */
|
|
||||||
const pendingProgressTeam = ref(null);
|
|
||||||
/** 报环序列的最后一个音频类型('hasAdjust' = 最后 key 为方向调整,'noAdjust' = 最后 key 为环数/未上靶) */
|
|
||||||
const pendingTriggerKey = ref(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听设备在线状态,比赛进行中设备离线时弹窗提示用户
|
* 监听设备在线状态,比赛进行中设备离线时弹窗提示用户
|
||||||
@@ -148,8 +144,8 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
|
|||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 报环语音播放期间暂缓切换进度条:存储目标队伍,待报环音频结束后由 onAudioEnded 发出 reset
|
// ToSomeoneShoot 到达时:若进度条仍在倒计时则瞬间清零再切换满值,确保视觉连贯
|
||||||
pendingProgressTeam.value = targetTeam;
|
uni.$emit("update-remain", {zeroThenReset: true, value: 15, team: targetTeam});
|
||||||
updateRemainSecond.value = battleInfo.readyTime;
|
updateRemainSecond.value = battleInfo.readyTime;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -170,20 +166,6 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onAudioEnded(s) {
|
function onAudioEnded(s) {
|
||||||
// 报环序列最后一个音频结束后,切换进度条到下一玩家满值
|
|
||||||
// pendingTriggerKey 标记最后一个 key 类型:hasAdjust 则等"调整"音频结束,noAdjust 则等"环"/"靶"音频结束
|
|
||||||
if (
|
|
||||||
pendingProgressTeam.value !== null &&
|
|
||||||
pendingTriggerKey.value !== null &&
|
|
||||||
(
|
|
||||||
(pendingTriggerKey.value === 'hasAdjust' && s.includes('调整')) ||
|
|
||||||
(pendingTriggerKey.value === 'noAdjust' && (s.includes('环') || s.includes('靶')))
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
uni.$emit("update-remain", {reset: true, value: 15, team: pendingProgressTeam.value});
|
|
||||||
pendingProgressTeam.value = null;
|
|
||||||
pendingTriggerKey.value = null;
|
|
||||||
}
|
|
||||||
// "请红方射箭"/"请蓝方射箭":队友或对手轮次;"轮到你了":用户本人轮次(HeaderProgress特殊分支)
|
// "请红方射箭"/"请蓝方射箭":队友或对手轮次;"轮到你了":用户本人轮次(HeaderProgress特殊分支)
|
||||||
// 三者音频结束后均需启动倒计时进度条
|
// 三者音频结束后均需启动倒计时进度条
|
||||||
if (s.indexOf('请红方射箭') >= 0 || s.indexOf('请蓝方射箭') >= 0 || s.indexOf('轮到你了') >= 0) {
|
if (s.indexOf('请红方射箭') >= 0 || s.indexOf('请蓝方射箭') >= 0 || s.indexOf('轮到你了') >= 0) {
|
||||||
@@ -191,12 +173,6 @@ function onAudioEnded(s) {
|
|||||||
if (s.indexOf('请红方射箭') >= 0) team = 'red';
|
if (s.indexOf('请红方射箭') >= 0) team = 'red';
|
||||||
else if (s.indexOf('请蓝方射箭') >= 0) team = 'blue';
|
else if (s.indexOf('请蓝方射箭') >= 0) team = 'blue';
|
||||||
else team = tips.value.includes('红队') ? 'red' : 'blue'; // 轮到你了:从当前tips判断用户所在队伍
|
else team = tips.value.includes('红队') ? 'red' : 'blue'; // 轮到你了:从当前tips判断用户所在队伍
|
||||||
// 兜底:无报环音频时(如首次 ToSomeoneShoot 无前置 ShootResult),在此清空 pending 并发出 reset
|
|
||||||
if (pendingProgressTeam.value !== null) {
|
|
||||||
uni.$emit("update-remain", {reset: true, value: 15, team: pendingProgressTeam.value});
|
|
||||||
pendingProgressTeam.value = null;
|
|
||||||
pendingTriggerKey.value = null;
|
|
||||||
}
|
|
||||||
uni.$emit("update-remain", {stop: false, value: updateRemainSecond.value, team: team});
|
uni.$emit("update-remain", {stop: false, value: updateRemainSecond.value, team: team});
|
||||||
}
|
}
|
||||||
if (s.indexOf("比赛结束") >= 0) {
|
if (s.indexOf("比赛结束") >= 0) {
|
||||||
@@ -251,14 +227,8 @@ async function onReceiveMessage(msg) {
|
|||||||
lastToSomeoneShootKey.value = key;
|
lastToSomeoneShootKey.value = key;
|
||||||
recoverData(msg);
|
recoverData(msg);
|
||||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
||||||
uni.$emit("update-remain", {stop: true})
|
|
||||||
showRoundTip.value = false;
|
showRoundTip.value = false;
|
||||||
recoverData(msg, {arrowOnly: true});
|
recoverData(msg, {arrowOnly: true});
|
||||||
// 根据 shootData.angle 预判报环序列最后一个 key:
|
|
||||||
// 有 angle 则最后 key 为"向X调整"(hasAdjust),否则为"环"/"未上靶"(noAdjust)
|
|
||||||
if (msg.shootData) {
|
|
||||||
pendingTriggerKey.value = (msg.shootData.angle !== null) ? 'hasAdjust' : 'noAdjust';
|
|
||||||
}
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
||||||
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
||||||
const prevRound = currentRound.value;
|
const prevRound = currentRound.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user