From 1adc69542b6db6a3c9705dd0af9978c17271f8c9 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Wed, 19 Feb 2025 13:48:38 +0500 Subject: [PATCH 1/2] 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() { From 5fd6490f082cad177ee0e4a36d9787a4d01632bc Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Wed, 19 Feb 2025 18:56:30 +0500 Subject: [PATCH 2/2] Changed the executioners mechanic --- .../Abilities/The Executioner Ability.asset | 5 ++- Assets/Scenes/BossRoom.unity | 40 +++++++++++++++++-- Assets/Scripts/Gameplay/AbilitySystem.cs | 8 ++-- Assets/Scripts/Gameplay/CrowManager.cs | 3 +- .../Scripts/Gameplay/TheExecutionerAbility.cs | 33 +++++++++------ 5 files changed, 64 insertions(+), 25 deletions(-) diff --git a/Assets/GameData/Action/Abilities/The Executioner Ability.asset b/Assets/GameData/Action/Abilities/The Executioner Ability.asset index 4bc3448..4e425c0 100644 --- a/Assets/GameData/Action/Abilities/The Executioner Ability.asset +++ b/Assets/GameData/Action/Abilities/The Executioner Ability.asset @@ -20,5 +20,6 @@ MonoBehaviour: abilityCooldownTime: 0 abilityApplicationRadius: 20 prefab: {fileID: 2026889198986879358, guid: cbe217685dd069b47ac56eefeb3f6cdc, type: 3} - travelTime: 2 - lineLength: 50 + travelTime: 3 + spawnRadius: 30 + moveThroughCenterDistance: 60 diff --git a/Assets/Scenes/BossRoom.unity b/Assets/Scenes/BossRoom.unity index 9176cc5..ee8b11b 100644 --- a/Assets/Scenes/BossRoom.unity +++ b/Assets/Scenes/BossRoom.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18194216, g: 0.2276266, b: 0.3074139, a: 1} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -2066,7 +2066,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 501460ae984b4e44d991e4b43e36afee, type: 3} m_Name: m_EditorClassIdentifier: - activeForesight: {fileID: 0} + mapCenter: {fileID: 485162418} --- !u!4 &396364068 Transform: m_ObjectHideFlags: 0 @@ -2464,6 +2464,37 @@ MonoBehaviour: SpawnWithObservers: 1 DontDestroyWithOwner: 0 AutoObjectParentSync: 1 +--- !u!1 &485162417 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 485162418} + m_Layer: 0 + m_Name: Center + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &485162418 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 485162417} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1, y: 0, z: -1.4} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &489428172 GameObject: m_ObjectHideFlags: 0 @@ -13686,11 +13717,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.y - value: 0.28987613 + value: 0.28987607 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.z - value: -0.18152039 + value: -0.18152031 objectReference: {fileID: 0} - target: {fileID: 1676734516302391364, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_UpdateMethod @@ -471843,3 +471874,4 @@ SceneRoots: - {fileID: 5277713031461887262} - {fileID: 917181830697422961} - {fileID: 1010981557} + - {fileID: 485162418} diff --git a/Assets/Scripts/Gameplay/AbilitySystem.cs b/Assets/Scripts/Gameplay/AbilitySystem.cs index d3c4c0e..b85a95b 100644 --- a/Assets/Scripts/Gameplay/AbilitySystem.cs +++ b/Assets/Scripts/Gameplay/AbilitySystem.cs @@ -113,10 +113,10 @@ public class AbilitySystem : NetworkBehaviour isWallPlacementStarted = false; } } - else if (activeAbility.abilityKey == "TheExecutioner") - { - HandleExecutionerPlacement(); - } + // else if (activeAbility.abilityKey == "TheExecutioner") + // { + // HandleExecutionerPlacement(); + // } else { ManageStandardAbilityIndicator(); diff --git a/Assets/Scripts/Gameplay/CrowManager.cs b/Assets/Scripts/Gameplay/CrowManager.cs index b4b5ead..36ed9f5 100644 --- a/Assets/Scripts/Gameplay/CrowManager.cs +++ b/Assets/Scripts/Gameplay/CrowManager.cs @@ -11,8 +11,7 @@ public class CrowManager : NetworkBehaviour private List players = new List(); private ServerCharacter currentCrow; - public GameObject activeForesight; - + public Transform mapCenter; private void Awake() { if (Instance != null && Instance != this) diff --git a/Assets/Scripts/Gameplay/TheExecutionerAbility.cs b/Assets/Scripts/Gameplay/TheExecutionerAbility.cs index 82e5d46..48f7232 100644 --- a/Assets/Scripts/Gameplay/TheExecutionerAbility.cs +++ b/Assets/Scripts/Gameplay/TheExecutionerAbility.cs @@ -7,27 +7,34 @@ public class TheExecutionerAbility : Ability { [Header("Executioner Settings")] public float travelTime = 2f; - public float lineLength = 50f; - public float boxStartingPointOffset = 20f; - public float boxEndingPointOffset = 20f; - - public override void Execute(ServerCharacter character, Vector3 startPoint, Vector3 direction) + public float spawnRadius = 18f; // Fixed spawn radius around the map center + + public override void Execute(ServerCharacter character, Vector3 ignoredStartPoint, Vector3 ignoredDirection) { - // Extend start and end points - Vector3 adjustedStartPoint = startPoint - (direction * boxStartingPointOffset); - Vector3 adjustedEndPoint = startPoint + (direction * lineLength) + (direction * boxEndingPointOffset); - - GameObject boxInstance = Instantiate(prefab, adjustedStartPoint, Quaternion.LookRotation(direction)); + Vector3 mapCenter = CrowManager.Instance.mapCenter.position; // Use dynamic map center + + // Generate a random point on the edge of the circle (radius = spawnRadius) + float angle = Random.Range(0f, Mathf.PI * 2); + Vector3 spawnPoint = new Vector3( + mapCenter.x + Mathf.Cos(angle) * spawnRadius, + mapCenter.y, + mapCenter.z + Mathf.Sin(angle) * spawnRadius + ); + + // Calculate the exact opposite point across the center (radius * 2 away) + Vector3 endPoint = mapCenter + (mapCenter - spawnPoint); + + // Spawn and initialize the executioner box + GameObject boxInstance = Instantiate(prefab, spawnPoint, Quaternion.LookRotation(endPoint - spawnPoint)); if (boxInstance.TryGetComponent(out var netObj)) { netObj.Spawn(); boxInstance.GetComponent().Initialize( character, - adjustedStartPoint, - adjustedEndPoint, + spawnPoint, + endPoint, travelTime ); } } - }