From 1adc69542b6db6a3c9705dd0af9978c17271f8c9 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Wed, 19 Feb 2025 13:48:38 +0500 Subject: [PATCH] Fixed the crow issue where --- Assets/Scripts/Gameplay/CrowManager.cs | 12 ++++++++---- Assets/Scripts/Gameplay/Platform.cs | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Gameplay/CrowManager.cs b/Assets/Scripts/Gameplay/CrowManager.cs index 582358e..b4b5ead 100644 --- a/Assets/Scripts/Gameplay/CrowManager.cs +++ b/Assets/Scripts/Gameplay/CrowManager.cs @@ -109,19 +109,23 @@ public class CrowManager : NetworkBehaviour /// /// Clears the current Crow if no player is unoccupied. /// - private void ClearCrow() + public void ClearCrow() { if (currentCrow != null) { + Debug.Log($"[CrowManager] {currentCrow.name} landed on a platform. Removing crow status."); currentCrow.SetAsCrow(false); - Debug.Log($"{currentCrow.name} is no longer the Crow."); currentCrow = null; - // Notify all clients about the crow being cleared - NotifyCrowChangeClientRpc(0); // 0 indicates no crow + // Notify all clients that the crow role is cleared + NotifyCrowChangeClientRpc(0); // 0 means no crow } + + // Recalculate crow status after removing the old crow + DetermineCrow(); } + /// diff --git a/Assets/Scripts/Gameplay/Platform.cs b/Assets/Scripts/Gameplay/Platform.cs index 3445475..08277d8 100644 --- a/Assets/Scripts/Gameplay/Platform.cs +++ b/Assets/Scripts/Gameplay/Platform.cs @@ -190,6 +190,14 @@ namespace Unity.Multiplayer.Samples.BossRoom { return; } + + // If the player is currently the crow, convert them back into a normal player + if (player.IsCrow) + { + Debug.Log($"[Platform] Crow {player.name} landed on platform {PlatformID.Value}, converting back to player."); + CrowManager.Instance.ClearCrow(); // Notify CrowManager to clear the current crow + } + IsOccupied = true; occupierId.Value = player.OwnerClientId; player.OnArrivalOnPlatform(PlatformID.Value); @@ -253,6 +261,7 @@ namespace Unity.Multiplayer.Samples.BossRoom timerCoroutine = StartCoroutine(UpdateTimerShader(maxTime)); } } + [ClientRpc] private void PauseClientRpc() {