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:
@@ -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 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)
|
||||
private bool _localRaceActive = false;
|
||||
@@ -64,7 +61,6 @@ public class GameHUD : MonoBehaviour
|
||||
_gameMode = mode;
|
||||
_roundTimer = 0f;
|
||||
_timerRunning = true;
|
||||
_checkpointsCurrent = 0;
|
||||
}
|
||||
|
||||
void OnPhaseChanged(string phase)
|
||||
@@ -95,7 +91,7 @@ public class GameHUD : MonoBehaviour
|
||||
public void SetCountdown(float v) => _countdown = v;
|
||||
public void SetRoundInfo(int round, string mode) { _roundNumber = round; _gameMode = mode; }
|
||||
public void SetTotalRounds(int n) => _totalRounds = n;
|
||||
public void SetCheckpoint(int current, int total) { _checkpointsCurrent = current; _checkpointsTotal = total; }
|
||||
|
||||
|
||||
public void SetLocalRaceActive(bool active)
|
||||
{
|
||||
@@ -207,38 +203,11 @@ public class GameHUD : MonoBehaviour
|
||||
$"{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
|
||||
public static GameHUD Instance { get; private set; }
|
||||
public static int TotalCheckpoints { get; set; } = 5;
|
||||
|
||||
|
||||
// Cached values updated from NetworkManager state polling
|
||||
private int _cachedPlayersAlive = 0;
|
||||
|
||||
Reference in New Issue
Block a user