Added ability highlighter

main
Hazim Bin Ijaz 1 month ago
parent e9b43d3321
commit bf8350d7be

@ -16,4 +16,7 @@ MonoBehaviour:
abilityKey: Slowdown
keybind: 113
cooldownTime: 3
abilityRadius: 4
abilityDuration: 3
abilityMagnitude: 0.3
slowZonePrefab: {fileID: 5818330108676053786, guid: 4979352732bf84b44a9c789bef80b18a, type: 3}

@ -0,0 +1,137 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHAPREMULTIPLY_ON
- _SURFACE_TYPE_TRANSPARENT
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- DepthOnly
- SHADOWCASTER
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 2
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 1
- _DstBlendAlpha: 1
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 1
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.048973173, g: 0.9773584, b: 0, a: 0.54509807}
- _Color: {r: 0.04897315, g: 0.9773584, b: 0, a: 0.54509807}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4405473290192554091
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3a415e4b90d5e7346a544b94fa0f34bd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
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: AbilityIndicator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !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, z: 0, w: 1}
m_LocalPosition: {x: 128.399, y: -2.7047109e-17, z: 53.489494}
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: 10207, 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: 63d404b949e644e4a92db7444ae88671
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -68,6 +68,77 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_ClientVisualsAnimator: {fileID: 1829276847453002016}
m_VisualizationConfiguration: {fileID: 11400000, guid: 9504973cdecd65749889771972fa0117, type: 2}
--- !u!1001 &3984775118419009769
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 6009713983291384766}
m_Modifications:
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3894374618083898175, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_Name
value: AbilityIndicator
objectReference: {fileID: 0}
- target: {fileID: 3894374618083898175, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
--- !u!1 &92142163933926358 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3894374618083898175, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
m_PrefabInstance: {fileID: 3984775118419009769}
m_PrefabAsset: {fileID: 0}
--- !u!4 &248483794971195069 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3764456690617734740, guid: 63d404b949e644e4a92db7444ae88671, type: 3}
m_PrefabInstance: {fileID: 3984775118419009769}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &7831782662127126385
PrefabInstance:
m_ObjectHideFlags: 0
@ -188,6 +259,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1
addedObject: {fileID: 7902288483105483375}
- targetCorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1
addedObject: {fileID: 248483794971195069}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 4600110157238723781, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
insertIndex: -1
@ -667,6 +741,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
abilities:
- {fileID: 11400000, guid: e4794e2f71f66a74486c797344695ce7, type: 2}
currentAbilityIndicator: {fileID: 92142163933926358}
--- !u!4 &6009713983291384766 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4600110157238723791, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}

@ -7,11 +7,16 @@ public abstract class Ability : ScriptableObject
public string abilityKey;
public KeyCode keybind; // Key to activate the ability
public float cooldownTime; // Cooldown duration in seconds
public float abilityRadius;
public float abilityDuration;
public float abilityMagnitude;
public void ActivateAbility(GameObject owner)
{
Activate(owner);
}
protected abstract void Activate(GameObject owner); // Logic for the specific ability
public abstract void OnDrawAbilityGizmos(Vector3 pos);
}

@ -11,12 +11,17 @@ public class AbilitySystem : MonoBehaviour
private bool isAbilityActive = false;
private HashSet<Ability> abilitiesOnCooldown = new HashSet<Ability>();
[SerializeField] private GameObject currentAbilityIndicator;
void Update()
{
if (isAbilityActive && Input.GetMouseButtonDown(0))
if (isAbilityActive)
{
UseActiveAbility();
UpdateIndicatorPosition();
if (Input.GetMouseButtonDown(0))
{
UseActiveAbility();
}
}
}
@ -43,6 +48,11 @@ public class AbilitySystem : MonoBehaviour
Debug.LogWarning($"No ability assigned to key {key}.");
}
public bool IsAbilityModeActive()
{
return isAbilityActive; // Returns true if an ability mode is currently active
}
private void ToggleAbilityMode(Ability ability)
{
if (isAbilityActive && activeAbility == ability)
@ -59,6 +69,7 @@ public class AbilitySystem : MonoBehaviour
{
isAbilityActive = true;
activeAbility = ability;
currentAbilityIndicator.SetActive(true);
Debug.Log($"Ability {ability.abilityName} activated! Click to use.");
}
@ -66,6 +77,7 @@ public class AbilitySystem : MonoBehaviour
{
isAbilityActive = false;
activeAbility = null;
currentAbilityIndicator.SetActive(false);
Debug.Log("Ability mode deactivated.");
}
@ -92,4 +104,30 @@ public class AbilitySystem : MonoBehaviour
abilitiesOnCooldown.Remove(ability);
Debug.Log($"{ability.abilityName} is off cooldown.");
}
private void UpdateIndicatorPosition()
{
// Raycast to get the position of the cursor on the ground
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; // Replace cooldownTime with your ability range if needed
}
}
// private void OnDrawGizmos()
// {
// if (isAbilityActive && activeAbility is SlowZoneAbility slowZoneAbility)
// {
// // Draw the gizmo at the mouse position
// Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// if (Physics.Raycast(ray, out RaycastHit hit))
// {
// slowZoneAbility.OnDrawAbilityGizmos(hit.point);
// }
// }
// }
}

@ -30,6 +30,14 @@ public class SlowZoneAbility : Ability
{
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);
}
}

@ -8,9 +8,7 @@ using UnityEngine.AI;
public class SlowZonePrefab : NetworkBehaviour
{
[Header("Slow Zone Settings")]
public float zoneRadius = 5f; // Radius of the slow zone
public float slowDuration = 3f; // Duration of the slow effect
public Ability Ability;
private void Start()
{
// Start the process to slow down players when the zone is spawned
@ -23,7 +21,7 @@ public class SlowZonePrefab : NetworkBehaviour
ApplySlowToPlayers();
// Optionally, repeat the check while the zone exists
yield return new WaitForSeconds(slowDuration);
yield return new WaitForSeconds(Ability.abilityDuration);
// Destroy the zone after applying the slow effect
Destroy(gameObject);
@ -32,7 +30,7 @@ public class SlowZonePrefab : NetworkBehaviour
private void ApplySlowToPlayers()
{
// Find all colliders in the zone
Collider[] hitColliders = Physics.OverlapSphere(transform.position, zoneRadius);
Collider[] hitColliders = Physics.OverlapSphere(transform.position, Ability.abilityRadius);
foreach (var collider in hitColliders)
{
if (collider.TryGetComponent<ServerCharacter>(out var player))
@ -51,11 +49,10 @@ public class SlowZonePrefab : NetworkBehaviour
private IEnumerator SlowPlayer(ServerCharacter player)
{
// Halve the player's movement speed
player.Movement.SetSpeedModifier(0.2f);
// player.Movement.SetMovementSpeed(originalSpeed * slowMultiplier);
player.Movement.SetSpeedModifier(Ability.abilityMagnitude);
// Wait for the slow duration
yield return new WaitForSeconds(slowDuration);
yield return new WaitForSeconds(Ability.abilityDuration);
// Restore the original speed
player.Movement.ResetSpeedModifier();
@ -67,6 +64,6 @@ public class SlowZonePrefab : NetworkBehaviour
private void OnDrawGizmos()
{
Gizmos.color = Color.cyan;
Gizmos.DrawWireSphere(transform.position, zoneRadius);
Gizmos.DrawWireSphere(transform.position, Ability.abilityRadius);
}
}

@ -477,6 +477,20 @@ namespace Unity.BossRoom.Gameplay.UserInput
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability
{
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.SlowDownAbilityKey);
}
else
{
Debug.Log("You must be the Crow to activate this ability.");
}
}
if (m_AbilitySystem.IsAbilityModeActive()) return;
if (Input.GetKeyDown(KeyCode.Alpha1) && CharacterClass.Skill1)
{
RequestAction(actionState1.actionID, SkillTriggerStyle.Keyboard);
@ -518,17 +532,7 @@ namespace Unity.BossRoom.Gameplay.UserInput
{
RequestAction(GameDataSource.Instance.Emote4ActionPrototype.ActionID, SkillTriggerStyle.Keyboard);
}
if (Input.GetKeyDown(KeyCode.Q))
{
if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability
{
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.SlowDownAbilityKey);
}
else
{
Debug.Log("You must be the Crow to activate this ability.");
}
}
if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null)
{
//IsPointerOverGameObject() is a simple way to determine if the mouse is over a UI element. If it is, we don't perform mouse input logic,

Loading…
Cancel
Save