Fixed some issues

dev-main-mobile
Hazim Bin Ijaz 1 month ago
parent 477bd9cec5
commit 50ccadf4cf

@ -22,7 +22,7 @@ public class CrowsForesightAbility : Ability
{ {
netObj.Spawn(); netObj.Spawn();
CrowsForesightPrefab foresightPrefab = foresightInstance.GetComponent<CrowsForesightPrefab>(); CrowsForesightPrefab foresightPrefab = foresightInstance.GetComponent<CrowsForesightPrefab>();
foresightPrefab.Initialize(CrowManager.Instance.GetCurrentCrow().OwnerClientId); foresightPrefab.Initialize(CrowManager.Instance.GetCurrentCrow().OwnerClientId, this);
Debug.Log($"[CrowsForesightAbility] Assigned foresight prefab to Crow {character.OwnerClientId}"); Debug.Log($"[CrowsForesightAbility] Assigned foresight prefab to Crow {character.OwnerClientId}");
} }
} }

@ -8,21 +8,16 @@ public class CrowsForesightPrefab : NetworkBehaviour
{ {
private Dictionary<ulong, LineRenderer> foresightLines = new Dictionary<ulong, LineRenderer>(); private Dictionary<ulong, LineRenderer> foresightLines = new Dictionary<ulong, LineRenderer>();
private ulong crowClientId; private ulong crowClientId;
private Coroutine destroyCoroutine; public void Initialize(ulong crowId, CrowsForesightAbility ability)
private void Start()
{ {
crowClientId = crowId;
if (IsServer) if (IsServer)
{ {
Debug.Log("[CrowsForesightPrefab] Starting auto-destroy coroutine."); 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() public override void OnNetworkSpawn()
{ {
Debug.Log($"[CrowsForesightPrefab] OnNetworkSpawn called - LocalClientId: {NetworkManager.Singleton.LocalClientId}, crowClientId: {crowClientId}"); Debug.Log($"[CrowsForesightPrefab] OnNetworkSpawn called - LocalClientId: {NetworkManager.Singleton.LocalClientId}, crowClientId: {crowClientId}");

@ -8,21 +8,26 @@ public class TheExecutionerAbility : Ability
[Header("Executioner Settings")] [Header("Executioner Settings")]
public float travelTime = 2f; public float travelTime = 2f;
public float lineLength = 50f; public float lineLength = 50f;
public float boxStartingPointOffset = 20f;
public float boxEndingPointOffset = 20f;
public override void Execute(ServerCharacter character, Vector3 startPoint, Vector3 direction) public override void Execute(ServerCharacter character, Vector3 startPoint, Vector3 direction)
{ {
Vector3 endPoint = startPoint + (direction * lineLength); // Extend start and end points
Vector3 adjustedStartPoint = startPoint - (direction * boxStartingPointOffset);
GameObject boxInstance = Instantiate(prefab, startPoint, Quaternion.LookRotation(direction)); Vector3 adjustedEndPoint = startPoint + (direction * lineLength) + (direction * boxEndingPointOffset);
GameObject boxInstance = Instantiate(prefab, adjustedStartPoint, Quaternion.LookRotation(direction));
if (boxInstance.TryGetComponent<NetworkObject>(out var netObj)) if (boxInstance.TryGetComponent<NetworkObject>(out var netObj))
{ {
netObj.Spawn(); netObj.Spawn();
boxInstance.GetComponent<ExecutionerBox>().Initialize( boxInstance.GetComponent<ExecutionerBox>().Initialize(
character, character,
startPoint, adjustedStartPoint,
endPoint, adjustedEndPoint,
travelTime travelTime
); );
} }
} }
} }

Loading…
Cancel
Save