|
|
|
@ -25,7 +25,7 @@ public class ScoreManager : NetworkBehaviour
|
|
|
|
|
{
|
|
|
|
|
if (IsServer)
|
|
|
|
|
{
|
|
|
|
|
StartCrowPenaltyCoroutineServerRpc();
|
|
|
|
|
StartCrowPenaltyCoroutine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -38,6 +38,7 @@ public class ScoreManager : NetworkBehaviour
|
|
|
|
|
playerNames[ownerClientId] = name;
|
|
|
|
|
Debug.Log($"[ScoreManager] Player {ownerClientId} initialized with a starting score of 200 and name '{name}'.");
|
|
|
|
|
Scoreboard.instance.ScoreBoardItemInitializer(ownerClientId, playerScores[ownerClientId], name);
|
|
|
|
|
InitializePlayerScoreClientRpc(ownerClientId, name);
|
|
|
|
|
UpdatePlayerScoreClientRpc(ownerClientId, 200);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -45,7 +46,23 @@ public class ScoreManager : NetworkBehaviour
|
|
|
|
|
Debug.LogWarning($"[ScoreManager] Player {ownerClientId} already initialized.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[ClientRpc]
|
|
|
|
|
public void InitializePlayerScoreClientRpc(ulong ownerClientId, string name)
|
|
|
|
|
{
|
|
|
|
|
if (!playerScores.ContainsKey(ownerClientId))
|
|
|
|
|
{
|
|
|
|
|
playerScores[ownerClientId] = 200;
|
|
|
|
|
playerNames[ownerClientId] = name;
|
|
|
|
|
Debug.Log($"[ScoreManager] Player {ownerClientId} initialized with a starting score of 200 and name '{name}'.");
|
|
|
|
|
Scoreboard.instance.ScoreBoardItemInitializer(ownerClientId, playerScores[ownerClientId], name);
|
|
|
|
|
|
|
|
|
|
Scoreboard.instance.ScoreBoardUpdaterLocal(name, playerScores[ownerClientId]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"[ScoreManager] Player (from client) {ownerClientId} already initialized.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void UpdatePlayerScore(ulong ownerClientId, int newScore)
|
|
|
|
|
{
|
|
|
|
|
if (playerScores.ContainsKey(ownerClientId))
|
|
|
|
@ -67,10 +84,11 @@ public class ScoreManager : NetworkBehaviour
|
|
|
|
|
{
|
|
|
|
|
string playerName = playerNames[ownerClientId];
|
|
|
|
|
Debug.Log($"[ScoreManager] Received score update for Player {ownerClientId} (Name: {playerName}): {newScore}");
|
|
|
|
|
Scoreboard.instance.ScoreBoardUpdater(playerName, newScore);
|
|
|
|
|
Scoreboard.instance.ScoreBoardUpdaterLocal(playerName, newScore);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Debug.LogWarning($"[ScoreManager] Player name not found for Player {ownerClientId}. Cannot update scoreboard.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -93,8 +111,7 @@ public class ScoreManager : NetworkBehaviour
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ServerRpc]
|
|
|
|
|
public void StartCrowPenaltyCoroutineServerRpc()
|
|
|
|
|
public void StartCrowPenaltyCoroutine()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(ApplyCrowPenaltyCoroutine());
|
|
|
|
|
}
|
|
|
|
|