chore: adjust player tank's size
This commit is contained in:
+97
-10
@@ -240,6 +240,11 @@ const TeamGameScene = {
|
||||
tank.color = tankColor;
|
||||
// Unlimited lives for 3v3
|
||||
tank.lives = 999;
|
||||
// Apply equipped skin (only for the LOCAL player — other players keep team color)
|
||||
if (GameGlobal.skinManager && isLocal) {
|
||||
tank._skinColors = GameGlobal.skinManager.getCurrentSkinColors();
|
||||
tank._skinId = GameGlobal.skinManager.getEquippedSkinId();
|
||||
}
|
||||
}
|
||||
|
||||
tank.activateShield(3000);
|
||||
@@ -256,6 +261,7 @@ const TeamGameScene = {
|
||||
|
||||
const playerData = {
|
||||
playerId: member.playerId,
|
||||
nickname: member.nickname || '',
|
||||
tank,
|
||||
isBot,
|
||||
team,
|
||||
@@ -441,6 +447,29 @@ const TeamGameScene = {
|
||||
}
|
||||
}));
|
||||
|
||||
// Receive live team roster updates — keeps every tank's overhead label in
|
||||
// sync with the real WeChat nickname, which may be granted AFTER the match
|
||||
// has already started (via MenuScene's UserInfoButton).
|
||||
unsubs.push(nm.on(NET_MSG.TEAM_STATE, (data) => {
|
||||
if (!data) return;
|
||||
const rosterA = Array.isArray(data.teamA) ? data.teamA : [];
|
||||
const rosterB = Array.isArray(data.teamB) ? data.teamB : [];
|
||||
const byId = Object.create(null);
|
||||
for (const m of rosterA) if (m && m.playerId) byId[m.playerId] = m.nickname || '';
|
||||
for (const m of rosterB) if (m && m.playerId) byId[m.playerId] = m.nickname || '';
|
||||
let changed = false;
|
||||
for (const p of this._players) {
|
||||
const nn = byId[p.playerId];
|
||||
if (nn && p.nickname !== nn) {
|
||||
p.nickname = nn;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
console.log('[TeamGameScene] Roster nicknames refreshed.');
|
||||
}
|
||||
}));
|
||||
|
||||
this._unsubscribers = unsubs;
|
||||
},
|
||||
|
||||
@@ -1126,6 +1155,7 @@ const TeamGameScene = {
|
||||
stats: this._stats,
|
||||
players: this._players.map(p => ({
|
||||
playerId: p.playerId,
|
||||
nickname: p.nickname || '',
|
||||
team: p.team,
|
||||
isBot: p.isBot,
|
||||
isLocal: p.isLocal,
|
||||
@@ -1154,16 +1184,41 @@ const TeamGameScene = {
|
||||
if (player.tank.alive && !player.isRespawning) {
|
||||
player.tank.render(ctx);
|
||||
|
||||
// Draw team indicator above tank
|
||||
if (!player.isLocal) {
|
||||
const tx = player.tank.x;
|
||||
const ty = player.tank.y - player.tank.halfSize - 8;
|
||||
ctx.fillStyle = player.team === this._myTeam ? TEAM_A_COLOR : TEAM_B_COLOR;
|
||||
ctx.font = 'bold 8px Arial';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
const label = player.isBot ? '🤖' : (player.team === this._myTeam ? '▲' : '▼');
|
||||
ctx.fillText(label, tx, ty);
|
||||
// Name & team indicator above the tank
|
||||
const tx = player.tank.x;
|
||||
const labelY = player.tank.y - player.tank.halfSize - 4;
|
||||
const nameY = labelY - 10;
|
||||
|
||||
// Per-tank team color:
|
||||
// - local player → gold
|
||||
// - ally (not me) → blue
|
||||
// - enemy → red
|
||||
let labelColor;
|
||||
if (player.isLocal) labelColor = LOCAL_PLAYER_COLOR;
|
||||
else if (player.team === this._myTeam) labelColor = TEAM_A_COLOR;
|
||||
else labelColor = TEAM_B_COLOR;
|
||||
|
||||
ctx.fillStyle = labelColor;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
// Arrow / bot tag
|
||||
ctx.font = 'bold 8px Arial';
|
||||
let marker;
|
||||
if (player.isLocal) marker = '★';
|
||||
else if (player.isBot) marker = '🤖';
|
||||
else marker = (player.team === this._myTeam) ? '▲' : '▼';
|
||||
ctx.fillText(marker, tx, labelY);
|
||||
|
||||
// Nickname (truncated to 4 Chinese-equivalent chars)
|
||||
const name = this._getTankLabel(player);
|
||||
if (name) {
|
||||
ctx.font = 'bold 9px Arial';
|
||||
// Outline for readability on busy backgrounds
|
||||
ctx.lineWidth = 3;
|
||||
ctx.strokeStyle = 'rgba(0,0,0,0.7)';
|
||||
ctx.strokeText(name, tx, nameY);
|
||||
ctx.fillText(name, tx, nameY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1220,6 +1275,38 @@ const TeamGameScene = {
|
||||
return { kills, deaths };
|
||||
},
|
||||
|
||||
/**
|
||||
* Compute a short label (≤ 4 Chinese-equivalent chars) to draw above a tank.
|
||||
* Uses real WeChat nickname if available, otherwise a stable fallback.
|
||||
* @private
|
||||
*/
|
||||
_getTankLabel(player) {
|
||||
if (!player) return '';
|
||||
const profile = GameGlobal.playerProfile;
|
||||
let raw = '';
|
||||
if (player.isLocal) {
|
||||
// For local player prefer the freshest profile nickname if granted.
|
||||
if (profile && profile.nickname) raw = profile.nickname;
|
||||
else raw = player.nickname || '';
|
||||
} else {
|
||||
raw = player.nickname || '';
|
||||
}
|
||||
if (!raw) {
|
||||
if (player.isBot) {
|
||||
raw = ''; // bot — we already draw the 🤖 marker, skip name
|
||||
} else if (profile && typeof profile.getDisplayName === 'function') {
|
||||
raw = profile.getDisplayName(player.playerId);
|
||||
} else {
|
||||
raw = player.playerId || '';
|
||||
}
|
||||
}
|
||||
if (!raw) return '';
|
||||
if (profile && typeof profile.truncate === 'function') {
|
||||
return profile.truncate(raw, 4);
|
||||
}
|
||||
return raw.length > 8 ? raw.substring(0, 8) + '..' : raw;
|
||||
},
|
||||
|
||||
_renderHUD(ctx) {
|
||||
const hudY = 4;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user