game end screen l10 fix

This commit is contained in:
2026-04-05 21:43:25 +05:30
parent 4cabf27f29
commit cace0cc664
9 changed files with 1081 additions and 4390 deletions
+55
View File
@@ -603,7 +603,62 @@ public class GameManager : NetworkBehaviour
IEnumerator CoroutineGameOver(Team team){
yield return new WaitForSeconds(2f);
yield return CoroutineFetchBothPlayersL10();
LevelLoadManager.instance.SetupGameOver(team,redScore,blueScore);
LevelLoadManager.LoadLevel("MainMenu");
}
IEnumerator CoroutineFetchBothPlayersL10()
{
var my = LevelLoadManager.myPlayer;
var opp = LevelLoadManager.opponentPlayer;
if (my == null || opp == null)
yield break;
string baseUrl = (DedicatedInternalApiBase ?? "").TrimEnd('/');
if (string.IsNullOrEmpty(baseUrl))
yield break;
if (my.UserId > 0){
yield return CoFetchPlayerL10Apply(baseUrl, my);
}
if (opp.UserId > 0 && opp.UserId != my.UserId){
yield return CoFetchPlayerL10Apply(baseUrl, opp);
}
LevelLoadManager.myPlayer = my;
LevelLoadManager.opponentPlayer = opp;
}
static IEnumerator CoFetchPlayerL10Apply(string baseUrl, MatchmadePlayer player)
{
string url = baseUrl + "/players/" + player.UserId + "/l10";
using (var req = UnityWebRequest.Get(url))
{
yield return req.SendWebRequest();
if (req.result != UnityWebRequest.Result.Success)
{
Logger.Log("Player L10 fetch failed: " + req.error + " " + url);
yield break;
}
var resp = JsonUtility.FromJson<PlayerL10Response>(req.downloadHandler.text);
if (resp != null && resp.ok)
{
player.l10_wins = resp.l10_wins;
player.l10_losses = resp.l10_losses;
}
}
}
[Serializable]
class PlayerL10Response
{
public bool ok;
public int player_id;
public int l10_wins;
public int l10_losses;
}
bool freezeInput = false;
@@ -115,8 +115,8 @@ public class LevelLoadManager : MonoBehaviour
p2_l10.text = opponentL10;
}
MatchmadePlayer myPlayer;
MatchmadePlayer opponentPlayer;
public static MatchmadePlayer myPlayer;
public static MatchmadePlayer opponentPlayer;
public void SetupMatchMade(Team myTeam_, MatchmadePlayer myPlayer_, MatchmadePlayer opponentPlayer_){
myTeam = myTeam_;
@@ -140,21 +140,9 @@ public class LevelLoadManager : MonoBehaviour
if(myTeam == winningTeam){
p1_winner.SetActive(true);
p2_winner.SetActive(false);
myPlayer.l10_wins++;
myPlayer.l10_losses--;
opponentPlayer.l10_losses++;
opponentPlayer.l10_wins--;
}else{
p1_winner.SetActive(false);
p2_winner.SetActive(true);
opponentPlayer.l10_wins++;
opponentPlayer.l10_losses--;
myPlayer.l10_losses++;
myPlayer.l10_wins--;
}
p1_l10.text = $"L10 {myPlayer.l10_wins}-{myPlayer.l10_losses}";