Added the DashNCrash
parent
0f36b90290
commit
bab271e4b3
@ -1,28 +1,29 @@
|
|||||||
|
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public abstract class Ability : ScriptableObject
|
public abstract class Ability : ScriptableObject
|
||||||
{
|
{
|
||||||
[Header("Ability Settings")]
|
|
||||||
public string abilityName;
|
|
||||||
public string abilityKey;
|
public string abilityKey;
|
||||||
public KeyCode keybind; // Key to activate the ability
|
public string abilityName;
|
||||||
public float cooldownTime; // Cooldown duration in seconds
|
|
||||||
|
[Header("Common Ability Settings")]
|
||||||
public float abilityRadius;
|
public float abilityRadius;
|
||||||
public float abilityDuration;
|
|
||||||
public float abilityMagnitude;
|
public float abilityMagnitude;
|
||||||
|
public float abilityDuration;
|
||||||
|
public float abilityCooldownTime;
|
||||||
|
[Header("Ability Prefab")]
|
||||||
|
public GameObject prefab;
|
||||||
|
|
||||||
[SerializeField]
|
/// <summary>
|
||||||
private GameObject abilityPrefab; // Prefab associated with this ability
|
/// Executes the ability's specific behavior.
|
||||||
|
/// </summary>
|
||||||
|
public abstract void Execute(ServerCharacter character, Vector3 targetPosition);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the prefab associated with this ability.
|
||||||
|
/// </summary>
|
||||||
public GameObject GetPrefab()
|
public GameObject GetPrefab()
|
||||||
{
|
{
|
||||||
return abilityPrefab;
|
return prefab;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ActivateAbility(GameObject owner)
|
|
||||||
{
|
|
||||||
Activate(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void Activate(GameObject owner); // Logic for the specific ability
|
|
||||||
}
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
||||||
|
using UnityEngine;
|
||||||
|
using Unity.Netcode;
|
||||||
|
|
||||||
|
[CreateAssetMenu(menuName = "Abilities/DashNCrash")]
|
||||||
|
public class DashNCrashAbility : Ability
|
||||||
|
{
|
||||||
|
[Header("Dash Settings")]
|
||||||
|
public float dashSpeed = 10f;
|
||||||
|
public float dashDuration = 0.5f;
|
||||||
|
|
||||||
|
|
||||||
|
public override void Execute(ServerCharacter character, Vector3 targetPosition)
|
||||||
|
{
|
||||||
|
Debug.Log($"Executing DashNCrash for character {character.OwnerClientId} at {targetPosition}.");
|
||||||
|
|
||||||
|
// Start the dash
|
||||||
|
character.Movement.StartDash(targetPosition, dashSpeed, dashDuration);
|
||||||
|
|
||||||
|
// Delay spawning the slow zone until after the dash
|
||||||
|
character.StartCoroutine(SpawnSlowZoneAfterDash(character, targetPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator SpawnSlowZoneAfterDash(ServerCharacter character, Vector3 position)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(dashDuration + 0.25f);
|
||||||
|
|
||||||
|
// Spawn the slow zone prefab at the dash's end position
|
||||||
|
var prefab = GetPrefab();
|
||||||
|
if (prefab != null)
|
||||||
|
{
|
||||||
|
GameObject instance = Instantiate(prefab, character.transform.position, Quaternion.identity);
|
||||||
|
var networkObject = instance.GetComponent<NetworkObject>();
|
||||||
|
|
||||||
|
if (networkObject != null)
|
||||||
|
{
|
||||||
|
networkObject.Spawn();
|
||||||
|
Debug.Log($"Slow Zone spawned at {position}.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Slow Zone prefab must have a NetworkObject component.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[CreateAssetMenu(menuName = "Abilities/Slow Zone Ability")]
|
|
||||||
public class SlowZoneAbility : Ability
|
|
||||||
{
|
|
||||||
protected override void Activate(GameObject owner)
|
|
||||||
{
|
|
||||||
// No direct logic here, spawning is handled in AbilitySystem
|
|
||||||
Debug.Log($"SlowZoneAbility activated by {owner.name}.");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue