diff --git a/Assets/GameData/Action/Abilities/SlowZoneAbility.asset b/Assets/GameData/Action/Abilities/DashNCrash.asset
similarity index 66%
rename from Assets/GameData/Action/Abilities/SlowZoneAbility.asset
rename to Assets/GameData/Action/Abilities/DashNCrash.asset
index 60ce60d..29bcab4 100644
--- a/Assets/GameData/Action/Abilities/SlowZoneAbility.asset
+++ b/Assets/GameData/Action/Abilities/DashNCrash.asset
@@ -10,13 +10,14 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e7350d0607d7cc46a92f7ff596ad88d, type: 3}
- m_Name: SlowZoneAbility
+ m_Name: DashNCrash
m_EditorClassIdentifier:
- abilityName: Slowdown Area
- abilityKey: Slowdown
- keybind: 113
- cooldownTime: 3
+ abilityKey: DashNCrash
+ abilityName: DashNCrash
abilityRadius: 3
- abilityDuration: 3
abilityMagnitude: 0.3
- abilityPrefab: {fileID: 5818330108676053786, guid: 4979352732bf84b44a9c789bef80b18a, type: 3}
+ abilityDuration: 3
+ abilityCooldownTime: 3
+ prefab: {fileID: 5818330108676053786, guid: 4979352732bf84b44a9c789bef80b18a, type: 3}
+ dashSpeed: 10
+ dashDuration: 0.5
diff --git a/Assets/GameData/Action/Abilities/SlowZoneAbility.asset.meta b/Assets/GameData/Action/Abilities/DashNCrash.asset.meta
similarity index 100%
rename from Assets/GameData/Action/Abilities/SlowZoneAbility.asset.meta
rename to Assets/GameData/Action/Abilities/DashNCrash.asset.meta
diff --git a/Assets/Prefabs/Abilities/SlowDownZonePrefab.prefab b/Assets/Prefabs/Abilities/DashNCrashPrefab.prefab
similarity index 99%
rename from Assets/Prefabs/Abilities/SlowDownZonePrefab.prefab
rename to Assets/Prefabs/Abilities/DashNCrashPrefab.prefab
index 4f79b82..d7bb925 100644
--- a/Assets/Prefabs/Abilities/SlowDownZonePrefab.prefab
+++ b/Assets/Prefabs/Abilities/DashNCrashPrefab.prefab
@@ -15,7 +15,7 @@ GameObject:
- component: {fileID: 7596904637393423818}
- component: {fileID: 1396255635289861961}
m_Layer: 0
- m_Name: SlowDownZonePrefab
+ m_Name: DashNCrashPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
diff --git a/Assets/Prefabs/Abilities/SlowDownZonePrefab.prefab.meta b/Assets/Prefabs/Abilities/DashNCrashPrefab.prefab.meta
similarity index 100%
rename from Assets/Prefabs/Abilities/SlowDownZonePrefab.prefab.meta
rename to Assets/Prefabs/Abilities/DashNCrashPrefab.prefab.meta
diff --git a/Assets/Scenes/Startup.unity b/Assets/Scenes/Startup.unity
index 9d63d3b..f29fa43 100644
--- a/Assets/Scenes/Startup.unity
+++ b/Assets/Scenes/Startup.unity
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
- m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
+ m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -1524,6 +1524,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
+ - target: {fileID: 370034730102636685, guid: 4512c09d24f3fa147afb198fa90d63c6, type: 3}
+ propertyPath: SlowDownAbilityKey
+ value: DashNCrash
+ objectReference: {fileID: 0}
- target: {fileID: 370034730102636685, guid: 4512c09d24f3fa147afb198fa90d63c6, type: 3}
propertyPath: m_GeneralSwapActionPrototype
value:
diff --git a/Assets/Scripts/Gameplay/Ability.cs b/Assets/Scripts/Gameplay/Ability.cs
index ec10e7a..01c562e 100644
--- a/Assets/Scripts/Gameplay/Ability.cs
+++ b/Assets/Scripts/Gameplay/Ability.cs
@@ -1,28 +1,29 @@
+using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using UnityEngine;
public abstract class Ability : ScriptableObject
{
- [Header("Ability Settings")]
- public string abilityName;
public string abilityKey;
- public KeyCode keybind; // Key to activate the ability
- public float cooldownTime; // Cooldown duration in seconds
+ public string abilityName;
+
+ [Header("Common Ability Settings")]
public float abilityRadius;
- public float abilityDuration;
public float abilityMagnitude;
+ public float abilityDuration;
+ public float abilityCooldownTime;
+ [Header("Ability Prefab")]
+ public GameObject prefab;
- [SerializeField]
- private GameObject abilityPrefab; // Prefab associated with this ability
+ ///
+ /// Executes the ability's specific behavior.
+ ///
+ public abstract void Execute(ServerCharacter character, Vector3 targetPosition);
+ ///
+ /// Retrieves the prefab associated with this ability.
+ ///
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
-}
\ No newline at end of file
+}
diff --git a/Assets/Scripts/Gameplay/AbilitySystem.cs b/Assets/Scripts/Gameplay/AbilitySystem.cs
index 12d8c7b..14f7d35 100644
--- a/Assets/Scripts/Gameplay/AbilitySystem.cs
+++ b/Assets/Scripts/Gameplay/AbilitySystem.cs
@@ -1,5 +1,7 @@
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
+using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using Unity.Netcode;
using UnityEngine;
@@ -8,9 +10,8 @@ public class AbilitySystem : NetworkBehaviour
[Header("Assigned Abilities")]
public List abilities = new List();
- private Ability activeAbility; // Tracks the currently active ability in "spawn mode"
+ private Ability activeAbility;
private bool isAbilityActive = false;
-
private HashSet abilitiesOnCooldown = new HashSet();
[SerializeField] private GameObject currentAbilityIndicator;
@@ -27,9 +28,6 @@ public class AbilitySystem : NetworkBehaviour
}
}
- ///
- /// Activates an ability by its keybind.
- ///
public void ActivateAbilityByKey(string key)
{
foreach (var ability in abilities)
@@ -52,7 +50,7 @@ public class AbilitySystem : NetworkBehaviour
public bool IsAbilityModeActive()
{
- return isAbilityActive; // Returns true if an ability mode is currently active
+ return isAbilityActive;
}
private void ToggleAbilityMode(Ability ability)
@@ -71,7 +69,7 @@ public class AbilitySystem : NetworkBehaviour
{
isAbilityActive = true;
activeAbility = ability;
- currentAbilityIndicator.SetActive(true);
+ currentAbilityIndicator?.SetActive(true);
Debug.Log($"Ability {ability.abilityName} activated! Click to use.");
}
@@ -79,67 +77,70 @@ public class AbilitySystem : NetworkBehaviour
{
isAbilityActive = false;
activeAbility = null;
- currentAbilityIndicator.SetActive(false);
+ currentAbilityIndicator?.SetActive(false);
Debug.Log("Ability mode deactivated.");
}
- private void UseActiveAbility()
+ public void UseActiveAbility()
{
if (activeAbility != null)
{
- var spawnPosition = currentAbilityIndicator.transform.position;
- SpawnAbilityServerRpc(activeAbility.abilityKey, spawnPosition);
+ Debug.Log($"[AbilitySystem] Using active ability {activeAbility.abilityName}.");
+ Vector3 targetPosition = currentAbilityIndicator.transform.position;
+ RequestAbilityActivationServerRpc(activeAbility.abilityKey, targetPosition);
StartCoroutine(StartCooldown(activeAbility));
DeactivateAbilityMode();
}
+ else
+ {
+ Debug.LogWarning("[AbilitySystem] No active ability to use.");
+ }
}
- ///
- /// Starts the cooldown coroutine for the ability.
- ///
- private IEnumerator StartCooldown(Ability ability)
+ [ServerRpc(RequireOwnership = false)]
+ private void RequestAbilityActivationServerRpc(string abilityKey, Vector3 targetPosition, ServerRpcParams rpcParams = default)
{
- abilitiesOnCooldown.Add(ability);
- Debug.Log($"{ability.abilityName} is now on cooldown for {ability.cooldownTime} seconds.");
+ ulong ownerClientId = rpcParams.Receive.SenderClientId;
- yield return new WaitForSeconds(ability.cooldownTime);
+ Debug.Log($"[AbilitySystem] Received activation request for ability '{abilityKey}' from client {ownerClientId} at position {targetPosition}.");
- abilitiesOnCooldown.Remove(ability);
- Debug.Log($"{ability.abilityName} is off cooldown.");
+ ExecuteAbilityOnServer(abilityKey, ownerClientId, targetPosition);
}
- ///
- /// Spawns the requested ability on the server.
- ///
- [ServerRpc(RequireOwnership = false)]
- private void SpawnAbilityServerRpc(string abilityKey, Vector3 position, ServerRpcParams rpcParams = default)
+ private void ExecuteAbilityOnServer(string abilityKey, ulong ownerClientId, Vector3 targetPosition)
{
- var ability = abilities.Find(a => a.abilityKey == abilityKey);
- if (ability == null)
+ // Find the player's ServerCharacter
+ var playerObject = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList
+ .FirstOrDefault(obj => obj.OwnerClientId == ownerClientId && obj.GetComponent());
+
+ if (playerObject == null || !playerObject.TryGetComponent(out ServerCharacter character))
{
- Debug.LogError($"Ability {abilityKey} not found in the Ability System!");
+ Debug.LogError($"[AbilitySystem] No ServerCharacter component found for player {ownerClientId}.");
return;
}
- var prefab = ability.GetPrefab(); // Ensure your Ability class has a method to get the prefab
- if (prefab == null)
+ // Find the ability
+ var ability = abilities.Find(a => a.abilityKey == abilityKey);
+ if (ability == null)
{
- Debug.LogError($"Prefab for Ability {abilityKey} is not assigned!");
+ Debug.LogError($"[AbilitySystem] Ability {abilityKey} not found in the Ability System.");
return;
}
- GameObject abilityInstance = Instantiate(prefab, position, Quaternion.identity);
- var networkObject = abilityInstance.GetComponent();
+ // Activate the ability
+ Debug.Log($"[AbilitySystem] Activating ability {ability.abilityName} for player {ownerClientId} at {targetPosition}.");
+ ability.Execute(character, targetPosition);
+ }
- if (networkObject != null)
- {
- networkObject.Spawn();
- Debug.Log($"Spawned {abilityKey} at {position}.");
- }
- else
- {
- Debug.LogError($"Ability prefab {abilityKey} must have a NetworkObject component.");
- }
+ private IEnumerator StartCooldown(Ability ability)
+ {
+ abilitiesOnCooldown.Add(ability);
+ Debug.Log($"{ability.abilityName} is now on cooldown for {ability.abilityCooldownTime} seconds.");
+
+ yield return new WaitForSeconds(ability.abilityCooldownTime);
+
+ abilitiesOnCooldown.Remove(ability);
+ Debug.Log($"{ability.abilityName} is off cooldown.");
}
private void UpdateIndicatorPosition()
@@ -148,8 +149,11 @@ public class AbilitySystem : NetworkBehaviour
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
- currentAbilityIndicator.transform.position = hit.point;
- currentAbilityIndicator.transform.localScale = Vector3.one * activeAbility.abilityRadius;
+ if (currentAbilityIndicator != null)
+ {
+ currentAbilityIndicator.transform.position = hit.point;
+ currentAbilityIndicator.transform.localScale = Vector3.one * activeAbility.abilityRadius;
+ }
}
}
}
diff --git a/Assets/Scripts/Gameplay/DashNCrashAbility.cs b/Assets/Scripts/Gameplay/DashNCrashAbility.cs
new file mode 100644
index 0000000..fbc9c6d
--- /dev/null
+++ b/Assets/Scripts/Gameplay/DashNCrashAbility.cs
@@ -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();
+
+ if (networkObject != null)
+ {
+ networkObject.Spawn();
+ Debug.Log($"Slow Zone spawned at {position}.");
+ }
+ else
+ {
+ Debug.LogError("Slow Zone prefab must have a NetworkObject component.");
+ }
+ }
+ }
+}
diff --git a/Assets/Scripts/Gameplay/SlowZoneAbility.cs.meta b/Assets/Scripts/Gameplay/DashNCrashAbility.cs.meta
similarity index 100%
rename from Assets/Scripts/Gameplay/SlowZoneAbility.cs.meta
rename to Assets/Scripts/Gameplay/DashNCrashAbility.cs.meta
diff --git a/Assets/Scripts/Gameplay/SlowZonePrefab.cs b/Assets/Scripts/Gameplay/DashNCrashPrefab.cs
similarity index 98%
rename from Assets/Scripts/Gameplay/SlowZonePrefab.cs
rename to Assets/Scripts/Gameplay/DashNCrashPrefab.cs
index e540fba..69a296f 100644
--- a/Assets/Scripts/Gameplay/SlowZonePrefab.cs
+++ b/Assets/Scripts/Gameplay/DashNCrashPrefab.cs
@@ -5,7 +5,7 @@ using Unity.Netcode;
using UnityEngine;
[RequireComponent(typeof(SphereCollider))]
-public class SlowZonePrefab : NetworkBehaviour
+public class DashNCrashPrefab : NetworkBehaviour
{
[Header("Slow Zone Settings")]
public Ability Ability;
diff --git a/Assets/Scripts/Gameplay/SlowZonePrefab.cs.meta b/Assets/Scripts/Gameplay/DashNCrashPrefab.cs.meta
similarity index 100%
rename from Assets/Scripts/Gameplay/SlowZonePrefab.cs.meta
rename to Assets/Scripts/Gameplay/DashNCrashPrefab.cs.meta
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs
index 79c9104..2b93f41 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs
@@ -185,6 +185,19 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
}
}
+ public void SetKinematic(bool isKinematic)
+ {
+ if (physicsWrapper != null)
+ {
+ var rigidbody = physicsWrapper.GetComponent();
+ if (rigidbody != null)
+ {
+ rigidbody.isKinematic = isKinematic;
+ }
+ }
+ }
+
+
public void SetAsCrow(bool status)
{
if (IsServer)
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs
index cb98187..7204cb6 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs
@@ -91,14 +91,74 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
m_NavPath.SetTargetPosition(position);
}
+ public void StartDash(Vector3 targetPosition, float dashSpeed, float duration)
+ {
+ if (!IsServer)
+ {
+ Debug.LogWarning("[ServerCharacterMovement] StartDash called on a client. This should only run on the server.");
+ return;
+ }
+
+ if (m_NavMeshAgent == null || m_Rigidbody == null)
+ {
+ Debug.LogError("[ServerCharacterMovement] NavMeshAgent or Rigidbody is null. Ensure they are assigned.");
+ return;
+ }
+
+ Debug.Log($"[ServerCharacterMovement] StartDash initiated. Target position: {targetPosition}, Speed: {dashSpeed}, Duration: {duration}");
+
+ Vector3 direction = (targetPosition - transform.position).normalized;
+ if (direction.sqrMagnitude > 0.001f)
+ {
+ transform.rotation = Quaternion.LookRotation(direction);
+ Debug.Log($"[ServerCharacterMovement] Adjusted rotation towards {targetPosition}.");
+ }
+ else
+ {
+ Debug.LogWarning("[ServerCharacterMovement] Dash direction vector is too small. Aborting dash.");
+ return;
+ }
+
+ StartForwardCharge(dashSpeed, duration);
+ Debug.Log("[ServerCharacterMovement] Dash executed successfully.");
+ }
+
+
+
public void StartForwardCharge(float speed, float duration)
{
+ if (!IsServer)
+ {
+ Debug.LogWarning("[ServerCharacterMovement] StartForwardCharge called on a client. This should only run on the server.");
+ return;
+ }
+
+ if (m_NavMeshAgent == null)
+ {
+ Debug.LogError("[ServerCharacterMovement] NavMeshAgent is null. Ensure it is assigned.");
+ return;
+ }
+
+ Debug.Log($"[ServerCharacterMovement] Starting forward charge for {name} with speed {speed} and duration {duration}.");
+
m_NavPath.Clear();
m_MovementState = MovementState.Charging;
m_ForcedSpeed = speed;
m_SpecialModeDurationRemaining = duration;
}
+ public void SetKinematic(bool isKinematic)
+ {
+ m_Rigidbody.isKinematic = isKinematic;
+ m_NavMeshAgent.enabled = !isKinematic; // Disable NavMeshAgent while kinematic
+ if (isKinematic)
+ {
+ m_Rigidbody.velocity = Vector3.zero; // Stop ongoing movement
+ }
+ }
+
+
+
public void StartKnockback(Vector3 knocker, float speed, float duration)
{
m_NavPath.Clear();
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs b/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs
index 59dc31b..ba7f20b 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs
@@ -81,7 +81,7 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects
public Action DropActionPrototype => m_DropActionPrototype;
public Action PickUpActionPrototype => m_PickUpActionPrototype;
- public string SlowDownAbilityKey = "Slowdown";
+ public string SlowDownAbilityKey = "DashNCrash";
List m_AllActions;
diff --git a/Assets/Scripts/Gameplay/SlowZoneAbility.cs b/Assets/Scripts/Gameplay/SlowZoneAbility.cs
deleted file mode 100644
index 2dbf40e..0000000
--- a/Assets/Scripts/Gameplay/SlowZoneAbility.cs
+++ /dev/null
@@ -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}.");
- }
-}
\ No newline at end of file