From 50ccadf4cfd9d0404f1648e3879cf2be93932a2e Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Fri, 14 Feb 2025 14:13:51 +0500 Subject: [PATCH] Fixed some issues --- Assets/Scripts/Gameplay/CrowsForesightAbility.cs | 2 +- Assets/Scripts/Gameplay/CrowsForesightPrefab.cs | 11 +++-------- Assets/Scripts/Gameplay/TheExecutionerAbility.cs | 15 ++++++++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/Gameplay/CrowsForesightAbility.cs b/Assets/Scripts/Gameplay/CrowsForesightAbility.cs index 5a8b37af..85cd3092 100644 --- a/Assets/Scripts/Gameplay/CrowsForesightAbility.cs +++ b/Assets/Scripts/Gameplay/CrowsForesightAbility.cs @@ -22,7 +22,7 @@ public class CrowsForesightAbility : Ability { netObj.Spawn(); CrowsForesightPrefab foresightPrefab = foresightInstance.GetComponent(); - foresightPrefab.Initialize(CrowManager.Instance.GetCurrentCrow().OwnerClientId); + foresightPrefab.Initialize(CrowManager.Instance.GetCurrentCrow().OwnerClientId, this); Debug.Log($"[CrowsForesightAbility] Assigned foresight prefab to Crow {character.OwnerClientId}"); } } diff --git a/Assets/Scripts/Gameplay/CrowsForesightPrefab.cs b/Assets/Scripts/Gameplay/CrowsForesightPrefab.cs index e19b7a8d..8c7dd5e7 100644 --- a/Assets/Scripts/Gameplay/CrowsForesightPrefab.cs +++ b/Assets/Scripts/Gameplay/CrowsForesightPrefab.cs @@ -8,21 +8,16 @@ public class CrowsForesightPrefab : NetworkBehaviour { private Dictionary foresightLines = new Dictionary(); private ulong crowClientId; - private Coroutine destroyCoroutine; - private void Start() + public void Initialize(ulong crowId, CrowsForesightAbility ability) { + crowClientId = crowId; if (IsServer) { Debug.Log("[CrowsForesightPrefab] Starting auto-destroy coroutine."); - destroyCoroutine = StartCoroutine(DelayedDestroy()); + StartCoroutine(DelayedDestroy(ability.abilityDuration)); } } - public void Initialize(ulong crowId) - { - crowClientId = crowId; - } - public override void OnNetworkSpawn() { Debug.Log($"[CrowsForesightPrefab] OnNetworkSpawn called - LocalClientId: {NetworkManager.Singleton.LocalClientId}, crowClientId: {crowClientId}"); diff --git a/Assets/Scripts/Gameplay/TheExecutionerAbility.cs b/Assets/Scripts/Gameplay/TheExecutionerAbility.cs index 59f78509..82e5d46e 100644 --- a/Assets/Scripts/Gameplay/TheExecutionerAbility.cs +++ b/Assets/Scripts/Gameplay/TheExecutionerAbility.cs @@ -8,21 +8,26 @@ 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) { - Vector3 endPoint = startPoint + (direction * lineLength); - - GameObject boxInstance = Instantiate(prefab, startPoint, Quaternion.LookRotation(direction)); + // 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)); if (boxInstance.TryGetComponent(out var netObj)) { netObj.Spawn(); boxInstance.GetComponent().Initialize( character, - startPoint, - endPoint, + adjustedStartPoint, + adjustedEndPoint, travelTime ); } } + }