remove: scripts CheckpointSystem, CheckpointTrigger, EliminationOverlay
Nettoie aussi les references dans GameManager, GameHUD et StatsTracker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,6 @@ public class GameManager : MonoBehaviour
|
|||||||
public GameObject playerRoot;
|
public GameObject playerRoot;
|
||||||
public SpectatorCamera spectatorCamera;
|
public SpectatorCamera spectatorCamera;
|
||||||
public GameHUD gameHUD;
|
public GameHUD gameHUD;
|
||||||
public EliminationOverlay eliminationOverlay;
|
|
||||||
|
|
||||||
public GamePhase CurrentPhase { get; private set; } = GamePhase.Lobby;
|
public GamePhase CurrentPhase { get; private set; } = GamePhase.Lobby;
|
||||||
public bool IsLocalEliminated { get; private set; } = false;
|
public bool IsLocalEliminated { get; private set; } = false;
|
||||||
@@ -93,7 +92,6 @@ public class GameManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
IsLocalEliminated = true;
|
IsLocalEliminated = true;
|
||||||
TransitionTo(GamePhase.Eliminated);
|
TransitionTo(GamePhase.Eliminated);
|
||||||
eliminationOverlay?.ShowEliminated();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +100,6 @@ public class GameManager : MonoBehaviour
|
|||||||
if (sessionId == NetworkManager.Instance?.LocalSessionId)
|
if (sessionId == NetworkManager.Instance?.LocalSessionId)
|
||||||
{
|
{
|
||||||
TransitionTo(GamePhase.Qualified);
|
TransitionTo(GamePhase.Qualified);
|
||||||
eliminationOverlay?.ShowQualified();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +119,6 @@ public class GameManager : MonoBehaviour
|
|||||||
|
|
||||||
void HandleGameEnd(string winner)
|
void HandleGameEnd(string winner)
|
||||||
{
|
{
|
||||||
eliminationOverlay?.ShowGameEnd(winner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleDisconnected()
|
void HandleDisconnected()
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Manages race checkpoints and the finish line.
|
|
||||||
/// Place checkpoint GameObjects in order in the Inspector array.
|
|
||||||
/// Each checkpoint needs a Collider set to "Is Trigger".
|
|
||||||
/// The last checkpoint in the array is treated as the finish line.
|
|
||||||
/// Attach to a persistent manager GameObject in the race scene.
|
|
||||||
/// </summary>
|
|
||||||
public class CheckpointSystem : MonoBehaviour
|
|
||||||
{
|
|
||||||
public static CheckpointSystem Instance { get; private set; }
|
|
||||||
|
|
||||||
[Header("Checkpoints (in order — last one = finish line)")]
|
|
||||||
public Collider[] checkpoints;
|
|
||||||
|
|
||||||
[Header("Visuals")]
|
|
||||||
[Tooltip("Material to apply to active (next) checkpoint")]
|
|
||||||
public Material checkpointActiveMaterial;
|
|
||||||
[Tooltip("Material to apply to passed checkpoints")]
|
|
||||||
public Material checkpointPassedMaterial;
|
|
||||||
[Tooltip("Material to apply to finish line")]
|
|
||||||
public Material finishLineMaterial;
|
|
||||||
|
|
||||||
public int LocalCheckpointIndex => _localCheckpointIndex;
|
|
||||||
public bool RaceStarted { get; private set; }
|
|
||||||
|
|
||||||
private int _localCheckpointIndex = 0;
|
|
||||||
private Renderer[] _checkpointRenderers;
|
|
||||||
private bool _finished = false;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
Instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
_checkpointRenderers = new Renderer[checkpoints.Length];
|
|
||||||
for (int i = 0; i < checkpoints.Length; i++)
|
|
||||||
{
|
|
||||||
_checkpointRenderers[i] = checkpoints[i].GetComponent<Renderer>();
|
|
||||||
checkpoints[i].gameObject.name = $"Checkpoint_{i}";
|
|
||||||
|
|
||||||
// Auto-assign index so trigger knows its position in the sequence
|
|
||||||
var trigger = checkpoints[i].GetComponent<CheckpointTrigger>();
|
|
||||||
if (trigger != null) trigger.checkpointIndex = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tell HUD total checkpoints
|
|
||||||
GameHUD.TotalCheckpoints = checkpoints.Length;
|
|
||||||
UpdateCheckpointVisuals();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Called by CheckpointTrigger on each checkpoint object.</summary>
|
|
||||||
public void OnLocalPlayerHitCheckpoint(int index)
|
|
||||||
{
|
|
||||||
if (_finished) return;
|
|
||||||
if (index != _localCheckpointIndex) return;
|
|
||||||
|
|
||||||
// CP0 = start gate: activate race HUD and start local timer
|
|
||||||
if (index == 0)
|
|
||||||
{
|
|
||||||
RaceStarted = true;
|
|
||||||
GameHUD.Instance?.SetLocalRaceActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
_localCheckpointIndex++;
|
|
||||||
StatsTracker.Instance?.RegisterCheckpoint();
|
|
||||||
NetworkManager.Instance?.SendCheckpoint(_localCheckpointIndex);
|
|
||||||
|
|
||||||
Debug.Log($"[Checkpoint] Reached {_localCheckpointIndex}/{checkpoints.Length}");
|
|
||||||
|
|
||||||
// Update HUD
|
|
||||||
GameHUD.Instance?.SetCheckpoint(_localCheckpointIndex, checkpoints.Length);
|
|
||||||
|
|
||||||
UpdateCheckpointVisuals();
|
|
||||||
|
|
||||||
if (_localCheckpointIndex >= checkpoints.Length)
|
|
||||||
{
|
|
||||||
_finished = true;
|
|
||||||
StatsTracker.Instance?.RegisterFinish(GameHUD.Instance != null ? GameHUD.Instance.LocalRaceTimer : 0f);
|
|
||||||
Debug.Log("[Checkpoint] FINISH LINE reached!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StartCoroutine(FlashCheckpoint(_localCheckpointIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetForRound()
|
|
||||||
{
|
|
||||||
_localCheckpointIndex = 0;
|
|
||||||
_finished = false;
|
|
||||||
RaceStarted = false;
|
|
||||||
UpdateCheckpointVisuals();
|
|
||||||
GameHUD.Instance?.SetLocalRaceActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateCheckpointVisuals()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < checkpoints.Length; i++)
|
|
||||||
{
|
|
||||||
if (_checkpointRenderers[i] == null) continue;
|
|
||||||
|
|
||||||
if (i < _localCheckpointIndex)
|
|
||||||
{
|
|
||||||
// Passed
|
|
||||||
if (checkpointPassedMaterial != null)
|
|
||||||
_checkpointRenderers[i].material = checkpointPassedMaterial;
|
|
||||||
_checkpointRenderers[i].enabled = false; // hide passed checkpoints
|
|
||||||
}
|
|
||||||
else if (i == _localCheckpointIndex)
|
|
||||||
{
|
|
||||||
// Active (next to hit)
|
|
||||||
_checkpointRenderers[i].enabled = true;
|
|
||||||
if (i == checkpoints.Length - 1 && finishLineMaterial != null)
|
|
||||||
_checkpointRenderers[i].material = finishLineMaterial;
|
|
||||||
else if (checkpointActiveMaterial != null)
|
|
||||||
_checkpointRenderers[i].material = checkpointActiveMaterial;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Upcoming (not yet active)
|
|
||||||
_checkpointRenderers[i].enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator FlashCheckpoint(int index)
|
|
||||||
{
|
|
||||||
if (index < 0 || index >= checkpoints.Length) yield break;
|
|
||||||
var rend = _checkpointRenderers[index];
|
|
||||||
if (rend == null) yield break;
|
|
||||||
|
|
||||||
Color orig = rend.material.HasProperty("_BaseColor")
|
|
||||||
? rend.material.GetColor("_BaseColor")
|
|
||||||
: rend.material.color;
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
SetRendererColor(rend, new Color(0.3f, 1f, 0.5f));
|
|
||||||
yield return new WaitForSeconds(0.08f);
|
|
||||||
SetRendererColor(rend, orig);
|
|
||||||
yield return new WaitForSeconds(0.08f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetRendererColor(Renderer rend, Color c)
|
|
||||||
{
|
|
||||||
if (rend.material.HasProperty("_BaseColor")) rend.material.SetColor("_BaseColor", c);
|
|
||||||
else rend.material.color = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attach to each checkpoint GameObject (which must have a trigger Collider).
|
|
||||||
/// Set the checkpointIndex in the Inspector to match the checkpoint's position in the sequence.
|
|
||||||
/// </summary>
|
|
||||||
public class CheckpointTrigger : MonoBehaviour
|
|
||||||
{
|
|
||||||
[Tooltip("Index in the CheckpointSystem.checkpoints array (0-based)")]
|
|
||||||
public int checkpointIndex = 0;
|
|
||||||
|
|
||||||
void OnTriggerEnter(Collider other)
|
|
||||||
{
|
|
||||||
// Only trigger for the local player (has PlayerController)
|
|
||||||
if (other.GetComponent<PlayerController>() == null) return;
|
|
||||||
CheckpointSystem.Instance?.OnLocalPlayerHitCheckpoint(checkpointIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,11 +17,9 @@ public class StatsTracker : MonoBehaviour
|
|||||||
private float _totalDistance;
|
private float _totalDistance;
|
||||||
private int _totalJumps;
|
private int _totalJumps;
|
||||||
private float _maxSpeed;
|
private float _maxSpeed;
|
||||||
private float _bestRaceTime; // 0 = not set
|
|
||||||
private int _racesPlayed;
|
private int _racesPlayed;
|
||||||
private int _qualifications;
|
private int _qualifications;
|
||||||
private int _eliminations;
|
private int _eliminations;
|
||||||
private int _checkpointsTotal;
|
|
||||||
private int _bumpsGiven;
|
private int _bumpsGiven;
|
||||||
private float _totalPlaytime;
|
private float _totalPlaytime;
|
||||||
|
|
||||||
@@ -104,18 +102,6 @@ public class StatsTracker : MonoBehaviour
|
|||||||
_bumpsGiven++;
|
_bumpsGiven++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterCheckpoint()
|
|
||||||
{
|
|
||||||
_checkpointsTotal++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterFinish(float raceTime)
|
|
||||||
{
|
|
||||||
if (raceTime <= 0f) return;
|
|
||||||
if (_bestRaceTime <= 0f || raceTime < _bestRaceTime)
|
|
||||||
_bestRaceTime = raceTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Event handlers ──────────────────────────────────────────────────
|
// ─── Event handlers ──────────────────────────────────────────────────
|
||||||
|
|
||||||
private void OnConnected()
|
private void OnConnected()
|
||||||
@@ -187,11 +173,11 @@ public class StatsTracker : MonoBehaviour
|
|||||||
totalDistance = _totalDistance,
|
totalDistance = _totalDistance,
|
||||||
totalJumps = _totalJumps,
|
totalJumps = _totalJumps,
|
||||||
maxSpeed = _maxSpeed,
|
maxSpeed = _maxSpeed,
|
||||||
bestRaceTime = _bestRaceTime > 0f ? _bestRaceTime : 0f,
|
|
||||||
racesPlayed = _racesPlayed,
|
racesPlayed = _racesPlayed,
|
||||||
qualifications = _qualifications,
|
qualifications = _qualifications,
|
||||||
eliminations = _eliminations,
|
eliminations = _eliminations,
|
||||||
checkpointsTotal = _checkpointsTotal,
|
|
||||||
bumpsGiven = _bumpsGiven,
|
bumpsGiven = _bumpsGiven,
|
||||||
totalPlaytime = _totalPlaytime,
|
totalPlaytime = _totalPlaytime,
|
||||||
}
|
}
|
||||||
@@ -224,11 +210,9 @@ public class StatsTracker : MonoBehaviour
|
|||||||
public float totalDistance;
|
public float totalDistance;
|
||||||
public int totalJumps;
|
public int totalJumps;
|
||||||
public float maxSpeed;
|
public float maxSpeed;
|
||||||
public float bestRaceTime;
|
|
||||||
public int racesPlayed;
|
public int racesPlayed;
|
||||||
public int qualifications;
|
public int qualifications;
|
||||||
public int eliminations;
|
public int eliminations;
|
||||||
public int checkpointsTotal;
|
|
||||||
public int bumpsGiven;
|
public int bumpsGiven;
|
||||||
public float totalPlaytime;
|
public float totalPlaytime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,142 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Full-screen overlay for elimination, qualification, and game-end events.
|
|
||||||
/// Fade in → hold → fade out automatically.
|
|
||||||
/// </summary>
|
|
||||||
public class EliminationOverlay : MonoBehaviour
|
|
||||||
{
|
|
||||||
private enum OverlayType { None, Eliminated, Qualified, GameEnd }
|
|
||||||
|
|
||||||
private OverlayType _type = OverlayType.None;
|
|
||||||
private float _alpha = 0f;
|
|
||||||
private string _winnerName = "";
|
|
||||||
|
|
||||||
private static Texture2D _bgTex;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
if (_bgTex == null)
|
|
||||||
{
|
|
||||||
_bgTex = new Texture2D(1, 1);
|
|
||||||
_bgTex.SetPixel(0, 0, Color.white);
|
|
||||||
_bgTex.Apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowEliminated() => StartCoroutine(ShowOverlay(OverlayType.Eliminated, 3f));
|
|
||||||
public void ShowQualified() => StartCoroutine(ShowOverlay(OverlayType.Qualified, 2.5f));
|
|
||||||
public void ShowGameEnd(string winner)
|
|
||||||
{
|
|
||||||
_winnerName = winner;
|
|
||||||
StartCoroutine(ShowOverlay(OverlayType.GameEnd, 6f));
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator ShowOverlay(OverlayType type, float holdTime)
|
|
||||||
{
|
|
||||||
_type = type;
|
|
||||||
|
|
||||||
// Fade in
|
|
||||||
float t = 0f;
|
|
||||||
while (t < 0.3f)
|
|
||||||
{
|
|
||||||
t += Time.deltaTime;
|
|
||||||
_alpha = Mathf.Clamp01(t / 0.3f);
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
_alpha = 1f;
|
|
||||||
|
|
||||||
// Hold
|
|
||||||
yield return new WaitForSeconds(holdTime);
|
|
||||||
|
|
||||||
// Fade out
|
|
||||||
t = 0f;
|
|
||||||
while (t < 0.4f)
|
|
||||||
{
|
|
||||||
t += Time.deltaTime;
|
|
||||||
_alpha = 1f - Mathf.Clamp01(t / 0.4f);
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_alpha = 0f;
|
|
||||||
_type = OverlayType.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnGUI()
|
|
||||||
{
|
|
||||||
if (_type == OverlayType.None || _alpha < 0.01f) return;
|
|
||||||
|
|
||||||
// Background tint
|
|
||||||
Color bgColor = _type switch
|
|
||||||
{
|
|
||||||
OverlayType.Eliminated => new Color(0.7f, 0.05f, 0.05f, _alpha * 0.55f),
|
|
||||||
OverlayType.Qualified => new Color(0.05f, 0.55f, 0.15f, _alpha * 0.45f),
|
|
||||||
OverlayType.GameEnd => new Color(0.05f, 0.05f, 0.3f, _alpha * 0.6f),
|
|
||||||
_ => Color.clear
|
|
||||||
};
|
|
||||||
GUI.color = bgColor;
|
|
||||||
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), _bgTex);
|
|
||||||
GUI.color = Color.white;
|
|
||||||
|
|
||||||
// Main text
|
|
||||||
var mainStyle = new GUIStyle(GUI.skin.label)
|
|
||||||
{
|
|
||||||
alignment = TextAnchor.MiddleCenter,
|
|
||||||
fontSize = 72,
|
|
||||||
fontStyle = FontStyle.Bold,
|
|
||||||
};
|
|
||||||
|
|
||||||
string mainText = _type switch
|
|
||||||
{
|
|
||||||
OverlayType.Eliminated => "ÉLIMINÉ !",
|
|
||||||
OverlayType.Qualified => "QUALIFIÉ !",
|
|
||||||
OverlayType.GameEnd => "VICTOIRE !",
|
|
||||||
_ => ""
|
|
||||||
};
|
|
||||||
|
|
||||||
Color textColor = _type switch
|
|
||||||
{
|
|
||||||
OverlayType.Eliminated => new Color(1f, 0.3f, 0.2f, _alpha),
|
|
||||||
OverlayType.Qualified => new Color(0.3f, 1f, 0.5f, _alpha),
|
|
||||||
OverlayType.GameEnd => new Color(1f, 0.85f, 0.1f, _alpha),
|
|
||||||
_ => Color.clear
|
|
||||||
};
|
|
||||||
mainStyle.normal.textColor = textColor;
|
|
||||||
GUI.Label(new Rect(0, Screen.height * 0.35f, Screen.width, 100f), mainText, mainStyle);
|
|
||||||
|
|
||||||
// Sub text
|
|
||||||
var subStyle = new GUIStyle(GUI.skin.label)
|
|
||||||
{
|
|
||||||
alignment = TextAnchor.MiddleCenter,
|
|
||||||
fontSize = 26,
|
|
||||||
fontStyle = FontStyle.Bold,
|
|
||||||
};
|
|
||||||
subStyle.normal.textColor = new Color(1f, 1f, 1f, _alpha * 0.85f);
|
|
||||||
|
|
||||||
string subText = _type switch
|
|
||||||
{
|
|
||||||
OverlayType.Eliminated => "Meilleure chance la prochaine fois !",
|
|
||||||
OverlayType.Qualified => "Tu passes au round suivant !",
|
|
||||||
OverlayType.GameEnd => $"Gagnant : {_winnerName}",
|
|
||||||
_ => ""
|
|
||||||
};
|
|
||||||
GUI.Label(new Rect(0, Screen.height * 0.35f + 100f, Screen.width, 50f), subText, subStyle);
|
|
||||||
|
|
||||||
// Emoji accent
|
|
||||||
var emojiStyle = new GUIStyle(GUI.skin.label)
|
|
||||||
{
|
|
||||||
alignment = TextAnchor.MiddleCenter,
|
|
||||||
fontSize = 48,
|
|
||||||
};
|
|
||||||
emojiStyle.normal.textColor = new Color(1f, 1f, 1f, _alpha * 0.7f);
|
|
||||||
string emoji = _type switch
|
|
||||||
{
|
|
||||||
OverlayType.Eliminated => "💀",
|
|
||||||
OverlayType.Qualified => "✅",
|
|
||||||
OverlayType.GameEnd => "🏆",
|
|
||||||
_ => ""
|
|
||||||
};
|
|
||||||
GUI.Label(new Rect(0, Screen.height * 0.35f - 80f, Screen.width, 70f), emoji, emojiStyle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,9 +16,6 @@ public class GameHUD : MonoBehaviour
|
|||||||
private float _roundTimer = 0f;
|
private float _roundTimer = 0f;
|
||||||
private bool _timerRunning = false;
|
private bool _timerRunning = false;
|
||||||
|
|
||||||
// Checkpoint info (set by CheckpointSystem)
|
|
||||||
private int _checkpointsCurrent = 0;
|
|
||||||
private int _checkpointsTotal = 5;
|
|
||||||
|
|
||||||
// Local race state (activated when CP0 gate is crossed, independent of server phase)
|
// Local race state (activated when CP0 gate is crossed, independent of server phase)
|
||||||
private bool _localRaceActive = false;
|
private bool _localRaceActive = false;
|
||||||
@@ -64,7 +61,6 @@ public class GameHUD : MonoBehaviour
|
|||||||
_gameMode = mode;
|
_gameMode = mode;
|
||||||
_roundTimer = 0f;
|
_roundTimer = 0f;
|
||||||
_timerRunning = true;
|
_timerRunning = true;
|
||||||
_checkpointsCurrent = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPhaseChanged(string phase)
|
void OnPhaseChanged(string phase)
|
||||||
@@ -95,7 +91,7 @@ public class GameHUD : MonoBehaviour
|
|||||||
public void SetCountdown(float v) => _countdown = v;
|
public void SetCountdown(float v) => _countdown = v;
|
||||||
public void SetRoundInfo(int round, string mode) { _roundNumber = round; _gameMode = mode; }
|
public void SetRoundInfo(int round, string mode) { _roundNumber = round; _gameMode = mode; }
|
||||||
public void SetTotalRounds(int n) => _totalRounds = n;
|
public void SetTotalRounds(int n) => _totalRounds = n;
|
||||||
public void SetCheckpoint(int current, int total) { _checkpointsCurrent = current; _checkpointsTotal = total; }
|
|
||||||
|
|
||||||
public void SetLocalRaceActive(bool active)
|
public void SetLocalRaceActive(bool active)
|
||||||
{
|
{
|
||||||
@@ -207,38 +203,11 @@ public class GameHUD : MonoBehaviour
|
|||||||
$"{mins:00}:{secs:00}", timerStyle);
|
$"{mins:00}:{secs:00}", timerStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Race: checkpoint progress (bottom center) ─────────────────────
|
|
||||||
if (_gameMode == "race" && (_phase == "playing" || _localRaceActive))
|
|
||||||
{
|
|
||||||
float bw = 300f;
|
|
||||||
float bx = (Screen.width - bw) / 2f;
|
|
||||||
float by = Screen.height - 60f;
|
|
||||||
|
|
||||||
GUI.color = new Color(0.08f, 0.08f, 0.12f, 0.85f);
|
|
||||||
GUI.DrawTexture(new Rect(bx - 8f, by - 8f, bw + 16f, 36f), _bgTex);
|
|
||||||
GUI.color = Color.white;
|
|
||||||
|
|
||||||
// Background bar
|
|
||||||
GUI.color = new Color(0.2f, 0.2f, 0.28f, 1f);
|
|
||||||
GUI.DrawTexture(new Rect(bx, by, bw, 20f), _barBgTex);
|
|
||||||
|
|
||||||
// Fill
|
|
||||||
float fill = _checkpointsTotal > 0 ? (float)_checkpointsCurrent / _checkpointsTotal : 0f;
|
|
||||||
GUI.color = new Color(0.3f, 1f, 0.5f, 1f);
|
|
||||||
GUI.DrawTexture(new Rect(bx, by, bw * fill, 20f), _barFillTex);
|
|
||||||
GUI.color = Color.white;
|
|
||||||
|
|
||||||
var cpStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontSize = 11 };
|
|
||||||
cpStyle.normal.textColor = Color.white;
|
|
||||||
GUI.Label(new Rect(bx, by, bw, 20f),
|
|
||||||
$"Checkpoint {_checkpointsCurrent} / {_checkpointsTotal}", cpStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static accessors for cross-script use
|
// Static accessors for cross-script use
|
||||||
public static GameHUD Instance { get; private set; }
|
public static GameHUD Instance { get; private set; }
|
||||||
public static int TotalCheckpoints { get; set; } = 5;
|
|
||||||
|
|
||||||
// Cached values updated from NetworkManager state polling
|
// Cached values updated from NetworkManager state polling
|
||||||
private int _cachedPlayersAlive = 0;
|
private int _cachedPlayersAlive = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user