|
|
|
using UnityEngine;
|
|
|
|
using Unity.Netcode;
|
|
|
|
|
|
|
|
[CreateAssetMenu(menuName = "Abilities/Slow Zone Ability")]
|
|
|
|
public class SlowZoneAbility : Ability
|
|
|
|
{
|
|
|
|
[Header("Slow Zone Settings")]
|
|
|
|
public GameObject slowZonePrefab;
|
|
|
|
|
|
|
|
protected override void Activate(GameObject owner)
|
|
|
|
{
|
|
|
|
Camera mainCamera = Camera.main;
|
|
|
|
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
|
|
|
|
|
|
|
if (Physics.Raycast(ray, out RaycastHit hit))
|
|
|
|
{
|
|
|
|
Vector3 spawnPosition = hit.point;
|
|
|
|
|
|
|
|
if (owner.TryGetComponent(out NetworkObject networkOwner))
|
|
|
|
{
|
|
|
|
SpawnSlowZoneServerRpc(spawnPosition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Rpc(SendTo.Server)]
|
|
|
|
private void SpawnSlowZoneServerRpc(Vector3 position)
|
|
|
|
{
|
|
|
|
GameObject slowZone = Instantiate(slowZonePrefab, position, Quaternion.identity);
|
|
|
|
slowZone.GetComponent<NetworkObject>().Spawn();
|
|
|
|
slowZone.GetComponent<SlowZonePrefab>().Ability = this;
|
|
|
|
Debug.Log($"Slow Zone spawned at {position}.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnDrawAbilityGizmos(Vector3 pos)
|
|
|
|
{
|
|
|
|
Gizmos.color = new Color(0f, 0.5f, 1f, 0.2f); // Light blue with transparency
|
|
|
|
Gizmos.DrawSphere(pos, abilityRadius);
|
|
|
|
}
|
|
|
|
}
|