using UnityEngine; using Unity.Netcode; using Unity.BossRoom.Gameplay.GameplayObjects.Character; public class PlayerScoreComponent : NetworkBehaviour { public int CurrentScore { get; private set; } public ServerCharacter serverCharacter; public int m_index; public PlayerItem playerItem; public override void OnNetworkSpawn() { if (IsOwner) { Debug.Log($"[PlayerScoreComponent] Requesting score initialization for Player {OwnerClientId}"); ScoreManager.Instance?.InitializeAndSyncPlayerServerRpc(OwnerClientId, serverCharacter.uIStateDisplayHandler.m_UIState.playerName); } serverCharacter = GetComponent(); } public void UpdateScore(int newScore) { CurrentScore = newScore; Debug.Log($"[PlayerScoreComponent] Player {OwnerClientId} score updated to {newScore}."); UpdateScoreUI(); } private void UpdateScoreUI() { // Update the player's score display in the UI. Debug.Log($"[PlayerScoreComponent] Updated score UI for Player {OwnerClientId}: {CurrentScore}"); } //private void OnDestroy() //{ // Destroy(playerItem.gameObject); //} }