Added Vector Fence

dev-hazim
Hazim Bin Ijaz 2 weeks ago
parent 698b189e05
commit 89cc5f60e3

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71c78dee15b407d4183dd799c1b1a39f, type: 3}
m_Name: Vector Fence
m_EditorClassIdentifier:
abilityKey: VectorFence
abilityName: Vector Fence
abilityRadius: 0
abilityMagnitude: 0
abilityDuration: 10
abilityCooldownTime: 3
prefab: {fileID: 9694722736535169, guid: 9b94ed8895919e84aa669628b0761eaf, type: 3}
wallLength: 5
wallWidth: 0.5
wallHeight: 1
scaleUpDuration: 1

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 834f18926d3364d40ab9894f716b4e3b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -79,3 +79,8 @@ MonoBehaviour:
SourcePrefabToOverride: {fileID: 0} SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0 SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0} OverridingTargetPrefab: {fileID: 0}
- Override: 0
Prefab: {fileID: 9694722736535169, guid: 9b94ed8895919e84aa669628b0761eaf, type: 3}
SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0}

@ -0,0 +1,160 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &9694722736535169
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1756252046645169901}
- component: {fileID: 7200474853122004856}
- component: {fileID: 5290524345172392442}
- component: {fileID: 550742182908126467}
- component: {fileID: 8921202503349013827}
- component: {fileID: 5807442085122568602}
- component: {fileID: -7009867759405921325}
m_Layer: 0
m_Name: VectorFencePrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1756252046645169901
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 8, y: 1, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7200474853122004856
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5290524345172392442
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &550742182908126467
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!208 &8921202503349013827
NavMeshObstacle:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Enabled: 1
serializedVersion: 3
m_Shape: 1
m_Extents: {x: 0.5, y: 0.5, z: 0.5}
m_MoveThreshold: 0.1
m_Carve: 1
m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0, z: 0}
m_TimeToStationary: 0.5
--- !u!114 &5807442085122568602
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 3892629208
InScenePlacedSourceGlobalObjectIdHash: 0
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
--- !u!114 &-7009867759405921325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9694722736535169}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a951069c9ff70a479b426f4310ca775, type: 3}
m_Name:
m_EditorClassIdentifier:
Ability: {fileID: 11400000, guid: 834f18926d3364d40ab9894f716b4e3b, type: 2}

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9b94ed8895919e84aa669628b0761eaf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,85 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3894374618083898175
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3764456690617734740}
- component: {fileID: 2500946308868101064}
- component: {fileID: 1322199249233456991}
m_Layer: 0
m_Name: WallAbilityIndicator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &3764456690617734740
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894374618083898175}
serializedVersion: 2
m_LocalRotation: {x: -0, y: 0.5913096, z: -0, w: 0.8064447}
m_LocalPosition: {x: 7.958935, y: 3.7648613e-17, z: 6.871315}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2500946308868101064
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894374618083898175}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1322199249233456991
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894374618083898175}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 3a415e4b90d5e7346a544b94fa0f34bd, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bfc4217c8584ae04385dcac0be33d77e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -68,6 +68,77 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_ClientVisualsAnimator: {fileID: 1829276847453002016} m_ClientVisualsAnimator: {fileID: 1829276847453002016}
m_VisualizationConfiguration: {fileID: 11400000, guid: 9504973cdecd65749889771972fa0117, type: 2} m_VisualizationConfiguration: {fileID: 11400000, guid: 9504973cdecd65749889771972fa0117, type: 2}
--- !u!1001 &2846064494856670853
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 6009713983291384766}
m_Modifications:
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3894374618083898175, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_Name
value: WallAbilityIndicator
objectReference: {fileID: 0}
- target: {fileID: 3894374618083898175, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
--- !u!1 &1257869342993333690 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3894374618083898175, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
m_PrefabInstance: {fileID: 2846064494856670853}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1387471517613578449 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
m_PrefabInstance: {fileID: 2846064494856670853}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &3984775118419009769 --- !u!1001 &3984775118419009769
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -193,7 +264,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: GlobalObjectIdHash propertyPath: GlobalObjectIdHash
value: 3737985212 value: 3177087589
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: PrefabHashGenerator propertyPath: PrefabHashGenerator
@ -278,6 +349,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - targetCorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1 insertIndex: -1
addedObject: {fileID: 248483794971195069} addedObject: {fileID: 248483794971195069}
- targetCorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1
addedObject: {fileID: 1387471517613578449}
m_AddedComponents: m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 4600110157238723781, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - targetCorrespondingSourceObject: {fileID: 4600110157238723781, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1 insertIndex: -1
@ -763,7 +837,9 @@ MonoBehaviour:
abilities: abilities:
- {fileID: 11400000, guid: e4794e2f71f66a74486c797344695ce7, type: 2} - {fileID: 11400000, guid: e4794e2f71f66a74486c797344695ce7, type: 2}
- {fileID: 11400000, guid: 6c697d5efda1b0147b0c3f4088ee62f9, type: 2} - {fileID: 11400000, guid: 6c697d5efda1b0147b0c3f4088ee62f9, type: 2}
- {fileID: 11400000, guid: 834f18926d3364d40ab9894f716b4e3b, type: 2}
currentAbilityIndicator: {fileID: 92142163933926358} currentAbilityIndicator: {fileID: 92142163933926358}
wallIndicator: {fileID: 1257869342993333690}
--- !u!114 &4321537148236331373 --- !u!114 &4321537148236331373
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -1528,6 +1528,10 @@ PrefabInstance:
propertyPath: SlowDownAbilityKey propertyPath: SlowDownAbilityKey
value: DashNCrash value: DashNCrash
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 370034730102636685, guid: 4512c09d24f3fa147afb198fa90d63c6, type: 3}
propertyPath: VectorWallAbilityKey
value: VectorFence
objectReference: {fileID: 0}
- target: {fileID: 370034730102636685, guid: 4512c09d24f3fa147afb198fa90d63c6, type: 3} - target: {fileID: 370034730102636685, guid: 4512c09d24f3fa147afb198fa90d63c6, type: 3}
propertyPath: m_GeneralSwapActionPrototype propertyPath: m_GeneralSwapActionPrototype
value: value:

@ -17,7 +17,7 @@ public abstract class Ability : ScriptableObject
/// <summary> /// <summary>
/// Executes the ability's specific behavior. /// Executes the ability's specific behavior.
/// </summary> /// </summary>
public abstract void Execute(ServerCharacter character, Vector3 targetPosition); public abstract void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation);
/// <summary> /// <summary>
/// Retrieves the prefab associated with this ability. /// Retrieves the prefab associated with this ability.

@ -14,18 +14,82 @@ public class AbilitySystem : NetworkBehaviour
private bool isAbilityActive = false; private bool isAbilityActive = false;
private HashSet<Ability> abilitiesOnCooldown = new HashSet<Ability>(); private HashSet<Ability> abilitiesOnCooldown = new HashSet<Ability>();
[SerializeField] private GameObject currentAbilityIndicator; [SerializeField] private GameObject currentAbilityIndicator;
[SerializeField] private GameObject wallIndicator; // Separate indicator for the wall
void Update() void Update()
{ {
if (isAbilityActive) if (isAbilityActive)
{ {
UpdateIndicatorPosition(); if (activeAbility.abilityKey == "VectorFence")
{
// Use wallIndicator for VectorFence
if (!wallIndicator.activeSelf)
{
wallIndicator.SetActive(true);
currentAbilityIndicator.SetActive(false);
}
if (Input.GetMouseButtonDown(0))
{
// Save the spawn position for the wall
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
wallIndicator.transform.position = hit.point;
// wallIndicator.transform.rotation = Quaternion.identity; // Reset rotation
wallIndicator.transform.localScale = new Vector3(((VectorFenceAbility) activeAbility).wallLength,
((VectorFenceAbility) activeAbility).wallHeight,
((VectorFenceAbility) activeAbility).wallWidth);
}
}
if (Input.GetMouseButton(0))
{
// Rotate the wall using Mouse X for Y-axis rotation
float mouseX = Input.GetAxis("Mouse X");
wallIndicator.transform.Rotate(Vector3.up, mouseX); // Adjust rotation speed if needed
}
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonUp(0))
{
// Place the wall at the saved position and rotation
UseActiveAbility();
}
}
else
{ {
UseActiveAbility(); // Use currentAbilityIndicator for all other abilities
if (!currentAbilityIndicator.activeSelf)
{
currentAbilityIndicator.SetActive(true);
wallIndicator.SetActive(false);
}
UpdateIndicatorPosition();
if (Input.GetMouseButtonDown(0))
{
UseActiveAbility();
}
} }
} }
else
{
// Deactivate both indicators when ability mode is inactive
currentAbilityIndicator.SetActive(false);
wallIndicator.SetActive(false);
}
}
private void UpdateIndicatorForVectorFence(Vector3 center, Vector3 direction, float length)
{
if (wallIndicator != null)
{
wallIndicator.transform.position = center;
wallIndicator.transform.rotation = Quaternion.LookRotation(direction);
wallIndicator.transform.localScale = new Vector3(length, 1, 0.2f); // Adjust wall width & height
}
} }
public void ActivateAbilityByKey(string key) public void ActivateAbilityByKey(string key)
@ -69,7 +133,6 @@ public class AbilitySystem : NetworkBehaviour
{ {
isAbilityActive = true; isAbilityActive = true;
activeAbility = ability; activeAbility = ability;
currentAbilityIndicator?.SetActive(true);
Debug.Log($"Ability {ability.abilityName} activated! Click to use."); Debug.Log($"Ability {ability.abilityName} activated! Click to use.");
} }
@ -77,7 +140,6 @@ public class AbilitySystem : NetworkBehaviour
{ {
isAbilityActive = false; isAbilityActive = false;
activeAbility = null; activeAbility = null;
currentAbilityIndicator?.SetActive(false);
Debug.Log("Ability mode deactivated."); Debug.Log("Ability mode deactivated.");
} }
@ -86,8 +148,22 @@ public class AbilitySystem : NetworkBehaviour
if (activeAbility != null) if (activeAbility != null)
{ {
Debug.Log($"[AbilitySystem] Using active ability {activeAbility.abilityName}."); Debug.Log($"[AbilitySystem] Using active ability {activeAbility.abilityName}.");
Vector3 targetPosition = currentAbilityIndicator.transform.position;
RequestAbilityActivationServerRpc(activeAbility.abilityKey, targetPosition); Vector3 targetPosition;
Vector3 targetRotation;
if (activeAbility.abilityKey == "VectorFence")
{
targetPosition = wallIndicator.transform.position;
targetRotation = wallIndicator.transform.eulerAngles;
}
else
{
targetPosition = currentAbilityIndicator.transform.position;
targetRotation = currentAbilityIndicator.transform.eulerAngles; // Optional, depending on other abilities
}
RequestAbilityActivationServerRpc(activeAbility.abilityKey, targetPosition, targetRotation);
StartCoroutine(StartCooldown(activeAbility)); StartCoroutine(StartCooldown(activeAbility));
DeactivateAbilityMode(); DeactivateAbilityMode();
} }
@ -97,17 +173,18 @@ public class AbilitySystem : NetworkBehaviour
} }
} }
[ServerRpc(RequireOwnership = false)] [ServerRpc(RequireOwnership = false)]
private void RequestAbilityActivationServerRpc(string abilityKey, Vector3 targetPosition, ServerRpcParams rpcParams = default) private void RequestAbilityActivationServerRpc(string abilityKey, Vector3 targetPosition, Vector3 targetRotation, ServerRpcParams rpcParams = default)
{ {
ulong ownerClientId = rpcParams.Receive.SenderClientId; ulong ownerClientId = rpcParams.Receive.SenderClientId;
Debug.Log($"[AbilitySystem] Received activation request for ability '{abilityKey}' from client {ownerClientId} at position {targetPosition}."); Debug.Log($"[AbilitySystem] Received activation request for ability '{abilityKey}' from client {ownerClientId} at position {targetPosition} with rotation {targetRotation}.");
ExecuteAbilityOnServer(abilityKey, ownerClientId, targetPosition); ExecuteAbilityOnServer(abilityKey, ownerClientId, targetPosition, targetRotation);
} }
private void ExecuteAbilityOnServer(string abilityKey, ulong ownerClientId, Vector3 targetPosition) private void ExecuteAbilityOnServer(string abilityKey, ulong ownerClientId, Vector3 targetPosition, Vector3 targetRotation)
{ {
// Find the player's ServerCharacter // Find the player's ServerCharacter
var playerObject = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList var playerObject = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList
@ -128,8 +205,8 @@ public class AbilitySystem : NetworkBehaviour
} }
// Activate the ability // Activate the ability
Debug.Log($"[AbilitySystem] Activating ability {ability.abilityName} for player {ownerClientId} at {targetPosition}."); Debug.Log($"[AbilitySystem] Activating ability {ability.abilityName} for player {ownerClientId} at {targetPosition} with rotation {targetRotation}.");
ability.Execute(character, targetPosition); ability.Execute(character, targetPosition, targetRotation);
} }
private IEnumerator StartCooldown(Ability ability) private IEnumerator StartCooldown(Ability ability)

@ -11,7 +11,7 @@ public class DashNCrashAbility : Ability
public float dashDuration = 0.5f; public float dashDuration = 0.5f;
public override void Execute(ServerCharacter character, Vector3 targetPosition) public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
{ {
Debug.Log($"Executing DashNCrash for character {character.OwnerClientId} at {targetPosition}."); Debug.Log($"Executing DashNCrash for character {character.OwnerClientId} at {targetPosition}.");

@ -8,7 +8,7 @@ public class FreezeThrowAbility : Ability
[Header("FreezeThrow Settings")] [Header("FreezeThrow Settings")]
public float projectileSpeed = 10f; public float projectileSpeed = 10f;
public override void Execute(ServerCharacter character, Vector3 targetPosition) public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
{ {
if (!NetworkManager.Singleton.IsServer) if (!NetworkManager.Singleton.IsServer)
{ {

@ -84,6 +84,7 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects
public string DashNCrashAbilityKey = "DashNCrash"; public string DashNCrashAbilityKey = "DashNCrash";
public string FreezeThrowAbilityKey = "FreezeThrow"; public string FreezeThrowAbilityKey = "FreezeThrow";
public string VectorWallAbilityKey = "VectorWall";
List<Action> m_AllActions; List<Action> m_AllActions;

@ -527,6 +527,18 @@ namespace Unity.BossRoom.Gameplay.UserInput
Debug.Log("Cannot activate ability mode while swap mode is active."); Debug.Log("Cannot activate ability mode while swap mode is active.");
} }
} }
if (Input.GetKeyDown(KeyCode.F))
{
if (!IsSwapModeActive) // Prevent ability mode if swap mode is active
{
m_UIMessageFeed.DisplayMessage("Activated Ability mode");
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.VectorWallAbilityKey);
}
else
{
Debug.Log("Cannot activate ability mode while swap mode is active.");
}
}
if (m_AbilitySystem.IsAbilityModeActive()) return; if (m_AbilitySystem.IsAbilityModeActive()) return;
if (!IsSwapModeActive) // Prevent other inputs if swap mode is active if (!IsSwapModeActive) // Prevent other inputs if swap mode is active
{ {

@ -0,0 +1,40 @@
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[CreateAssetMenu(menuName = "Abilities/Vector Fence Ability")]
public class VectorFenceAbility : Ability
{
[Header("Vector Fence Settings")]
public float wallLength = 8f;
public float wallWidth = 0.5f;
public float wallHeight = 1f;
public float scaleUpDuration = 1.0f;
public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
{
if (!NetworkManager.Singleton.IsServer)
{
Debug.LogError("[VectorFenceAbility] Execute should only be called on the server.");
return;
}
if (character == null)
{
Debug.LogError("[VectorFenceAbility] ServerCharacter is null.");
return;
}
// Calculate wall placement based on target position and forward direction
Vector3 forward = character.transform.forward;
Vector3 wallCenter = targetPosition;
GameObject wallInstance = Instantiate(prefab, wallCenter, Quaternion.identity);
wallInstance.transform.eulerAngles = targetRotation;
if (wallInstance.TryGetComponent(out NetworkObject networkObject))
{
networkObject.Spawn();
Debug.Log($"[VectorFenceAbility] Wall spawned at {wallCenter} facing {forward}.");
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71c78dee15b407d4183dd799c1b1a39f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,75 @@
using System.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
public class VectorFencePrefab : NetworkBehaviour
{
[Header("Fence Settings")]
public VectorFenceAbility Ability;
private NavMeshObstacle navMeshObstacle;
private void Awake()
{
navMeshObstacle = GetComponent<NavMeshObstacle>();
if (navMeshObstacle == null)
{
Debug.LogError("[VectorFencePrefab] NavMeshObstacle is missing on the prefab!");
}
transform.localScale = new Vector3(Ability.wallLength, 0, Ability.wallWidth); // Start with zero height
}
public override void OnNetworkSpawn()
{
if (IsServer)
{
StartCoroutine(ScaleUp());
StartCoroutine(DestroyAfterLifetime());
}
}
private IEnumerator ScaleUp()
{
float elapsedTime = 0f;
Vector3 originalScale = transform.localScale;
Vector3 targetScale = new Vector3(Ability.wallLength, Ability.wallHeight, Ability.wallWidth); // Target full height scale
while (elapsedTime < Ability.scaleUpDuration)
{
transform.localScale = Vector3.Lerp(originalScale, targetScale, elapsedTime / Ability.scaleUpDuration);
elapsedTime += Time.deltaTime;
yield return null;
}
transform.localScale = targetScale;
// Enable the NavMeshObstacle after scaling is complete
if (navMeshObstacle != null)
{
navMeshObstacle.enabled = true;
navMeshObstacle.carving = true;
navMeshObstacle.center = Vector3.zero; // Adjust center if needed
navMeshObstacle.shape = NavMeshObstacleShape.Box;
}
}
private IEnumerator DestroyAfterLifetime()
{
yield return new WaitForSeconds(Ability.abilityDuration);
if (IsServer)
{
if (NetworkObject != null)
{
NetworkObject.Despawn(true);
}
else
{
Destroy(gameObject);
}
Debug.Log("[VectorFencePrefab] Fence destroyed.");
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9a951069c9ff70a479b426f4310ca775
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save