From e3d447d0d2a8670dd804b853c355151ef014618d Mon Sep 17 00:00:00 2001 From: Ali Sharoz Date: Wed, 15 Jan 2025 20:33:42 +0500 Subject: [PATCH] Ability UI Stopwatch Cooldown Timer --- Assets/Scenes/BossRoom.unity | 438 +++++++++++++++++++++- Assets/Scripts/Gameplay/AbilitySystem.cs | 13 +- Assets/Scripts/Gameplay/AbilityUI.cs | 43 +++ Assets/Scripts/Gameplay/AbilityUI.cs.meta | 11 + 4 files changed, 493 insertions(+), 12 deletions(-) create mode 100644 Assets/Scripts/Gameplay/AbilityUI.cs create mode 100644 Assets/Scripts/Gameplay/AbilityUI.cs.meta diff --git a/Assets/Scenes/BossRoom.unity b/Assets/Scenes/BossRoom.unity index b05388a..a8702fc 100644 --- a/Assets/Scenes/BossRoom.unity +++ b/Assets/Scenes/BossRoom.unity @@ -690,11 +690,161 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 0 +--- !u!1 &192475866 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 192475867} + - component: {fileID: 192475869} + - component: {fileID: 192475868} + m_Layer: 5 + m_Name: CoolDownClock (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &192475867 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 192475866} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.000011, y: 1.000011, z: 1.000011} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1878242782} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &192475868 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 192475866} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 3 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &192475869 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 192475866} + m_CullTransparentMesh: 1 --- !u!1 &222782634 stripped GameObject: m_CorrespondingSourceObject: {fileID: 2885098433089441387, guid: 8a7264ba4f271fa4fa6de65ef54333a7, type: 3} m_PrefabInstance: {fileID: 4768801497889015874} m_PrefabAsset: {fileID: 0} +--- !u!1 &299397429 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 299397430} + - component: {fileID: 299397432} + - component: {fileID: 299397431} + m_Layer: 5 + m_Name: CoolDownClock + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &299397430 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 299397429} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 3784538605243177484} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &299397431 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 299397429} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 3 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &299397432 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 299397429} + m_CullTransparentMesh: 1 --- !u!114 &370423840 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1485,6 +1635,81 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 0 +--- !u!1 &785551900 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 785551901} + - component: {fileID: 785551903} + - component: {fileID: 785551902} + m_Layer: 5 + m_Name: CoolDownClock (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &785551901 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785551900} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.000011, y: 1.000011, z: 1.000011} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1878242783} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.000030517578, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &785551902 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785551900} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 3 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &785551903 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785551900} + m_CullTransparentMesh: 1 --- !u!1001 &791609700 PrefabInstance: m_ObjectHideFlags: 0 @@ -8788,6 +9013,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 863331223} m_CullTransparentMesh: 1 +--- !u!1 &914389892 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 914389893} + - component: {fileID: 914389895} + - component: {fileID: 914389894} + m_Layer: 5 + m_Name: CoolDownClock + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &914389893 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 914389892} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.000011, y: 1.000011, z: 1.000011} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 3784538605243177481} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &914389894 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 914389892} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 0 + m_FillOrigin: 3 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &914389895 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 914389892} + m_CullTransparentMesh: 1 --- !u!1 &992061975 GameObject: m_ObjectHideFlags: 0 @@ -8997,11 +9297,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.w - value: 0.85294455 + value: 0.8529446 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.x - value: 0.3943448 + value: 0.39434478 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.y @@ -9009,7 +9309,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.z - value: -0.14352979 + value: -0.14352977 objectReference: {fileID: 0} - target: {fileID: 1676734516302391364, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_UpdateMethod @@ -9266,15 +9566,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.x - value: 0.39434484 + value: 0.3943448 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.y - value: 0.3104465 + value: 0.31044644 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.z - value: -0.1435298 + value: -0.14352976 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -10921,6 +11221,16 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 1 +--- !u!224 &1878242782 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 9059929380243764539, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!224 &1878242783 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 9059929380544550687, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} --- !u!114 &1893001415 MonoBehaviour: m_ObjectHideFlags: 0 @@ -125742,7 +126052,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 9059929381720062002, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} propertyPath: m_AnchoredPosition.y - value: 29.99997 + value: 30 objectReference: {fileID: 0} - target: {fileID: 9059929381720062002, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -125786,14 +126096,124 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 9059929380544550687, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 785551901} + - targetCorrespondingSourceObject: {fileID: 9059929381734582209, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 914389893} + - targetCorrespondingSourceObject: {fileID: 9059929380243764539, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 192475867} + - targetCorrespondingSourceObject: {fileID: 9059929381413149715, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 299397430} + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 9059929380544550686, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 3784538605243177490} + - targetCorrespondingSourceObject: {fileID: 9059929381734582208, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 3784538605243177483} + - targetCorrespondingSourceObject: {fileID: 9059929380243764538, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 3784538605243177489} + - targetCorrespondingSourceObject: {fileID: 9059929381413149714, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + insertIndex: -1 + addedObject: {fileID: 3784538605243177488} m_SourcePrefab: {fileID: 100100000, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} --- !u!224 &3784538605243177480 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 9059929381720062002, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} m_PrefabInstance: {fileID: 3784538605243177479} m_PrefabAsset: {fileID: 0} +--- !u!224 &3784538605243177481 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 9059929381734582209, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!1 &3784538605243177482 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 9059929381734582208, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!114 &3784538605243177483 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3784538605243177482} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0398e1dcd39dde54b98e9e930bd6ebc5, type: 3} + m_Name: + m_EditorClassIdentifier: + key: DashNCrash + CoolDownImg: {fileID: 914389894} +--- !u!224 &3784538605243177484 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 9059929381413149715, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!1 &3784538605243177485 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 9059929381413149714, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!1 &3784538605243177486 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 9059929380243764538, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!1 &3784538605243177487 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 9059929380544550686, guid: 334e483163a0ba54bb764e318223c9ba, type: 3} + m_PrefabInstance: {fileID: 3784538605243177479} + m_PrefabAsset: {fileID: 0} +--- !u!114 &3784538605243177488 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3784538605243177485} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0398e1dcd39dde54b98e9e930bd6ebc5, type: 3} + m_Name: + m_EditorClassIdentifier: + key: VectorFence + CoolDownImg: {fileID: 299397431} +--- !u!114 &3784538605243177489 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3784538605243177486} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0398e1dcd39dde54b98e9e930bd6ebc5, type: 3} + m_Name: + m_EditorClassIdentifier: + key: FreezeThrow + CoolDownImg: {fileID: 192475868} +--- !u!114 &3784538605243177490 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3784538605243177487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0398e1dcd39dde54b98e9e930bd6ebc5, type: 3} + m_Name: + m_EditorClassIdentifier: + key: Swap + CoolDownImg: {fileID: 785551902} --- !u!65 &3790878148979662611 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Gameplay/AbilitySystem.cs b/Assets/Scripts/Gameplay/AbilitySystem.cs index 78a2ed1..08ed9fd 100644 --- a/Assets/Scripts/Gameplay/AbilitySystem.cs +++ b/Assets/Scripts/Gameplay/AbilitySystem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Unity.BossRoom.Gameplay.GameplayObjects; using Unity.BossRoom.Gameplay.GameplayObjects.Character; +using Unity.Multiplayer.Samples.BossRoom; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; @@ -12,6 +13,7 @@ public class AbilitySystem : NetworkBehaviour { [Header("Assigned Abilities")] public List abilities = new List(); + public AbilityUI[] abilitiesUI; private Ability activeAbility; private bool isAbilityActive = false; @@ -37,6 +39,10 @@ public class AbilitySystem : NetworkBehaviour { m_Agent = GetComponent(); } + private void Start() + { + abilitiesUI = FindObjectsOfType(); + } void Update() { HandleAbilityMode(); @@ -137,7 +143,7 @@ public class AbilitySystem : NetworkBehaviour { //if (isValidPlacement) { - wallSpawnPosition = new Vector3( hit.point.x,0, hit.point.z); // Save spawn position + wallSpawnPosition = new Vector3(hit.point.x, 0, hit.point.z); // Save spawn position initialMousePosition = Input.mousePosition; // Store the initial mouse position on click isWallPlacementStarted = true; Debug.Log($"[AbilitySystem] Wall placement started at {wallSpawnPosition}"); @@ -197,7 +203,7 @@ public class AbilitySystem : NetworkBehaviour Ray ray = Camera.main.ScreenPointToRay(currentMousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { - Vector3 direction = (new Vector3( hit.point.x,0, hit.point.z) - wallIndicator.transform.position).normalized; + Vector3 direction = (new Vector3(hit.point.x, 0, hit.point.z) - wallIndicator.transform.position).normalized; float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg; angle -= 90f; Quaternion targetRotation = Quaternion.Euler(0f, angle, 0f); @@ -362,7 +368,8 @@ public class AbilitySystem : NetworkBehaviour { abilitiesOnCooldown.Add(ability); Debug.Log($"{ability.abilityName} is now on cooldown for {ability.abilityCooldownTime} seconds."); - + var abilityUI = abilitiesUI.FirstOrDefault(a => a.key == ability.abilityKey); + abilityUI.StopWatchFiller(ability.abilityCooldownTime); yield return new WaitForSeconds(ability.abilityCooldownTime); abilitiesOnCooldown.Remove(ability); diff --git a/Assets/Scripts/Gameplay/AbilityUI.cs b/Assets/Scripts/Gameplay/AbilityUI.cs new file mode 100644 index 0000000..6567434 --- /dev/null +++ b/Assets/Scripts/Gameplay/AbilityUI.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace Unity.Multiplayer.Samples.BossRoom +{ + + public class AbilityUI : MonoBehaviour + { + public string key; + public Image CoolDownImg; + public IEnumerator StopWatchRoutine; + public void StopWatchFiller(float coolDownTime) + { + if (StopWatchRoutine == null) + { + StopWatchRoutine = StopWatchFillerRoutine(coolDownTime); + StartCoroutine(StopWatchRoutine); + } + else + { + StopCoroutine(StopWatchRoutine); + StopWatchRoutine = StopWatchFillerRoutine(coolDownTime); + StartCoroutine(StopWatchRoutine); + } + } + public IEnumerator StopWatchFillerRoutine(float coolDownTime) + { + float factor = coolDownTime; + CoolDownImg.gameObject.SetActive(true); + CoolDownImg.fillAmount = 1; + while (coolDownTime > 0) + { + coolDownTime -= Time.deltaTime; + CoolDownImg.fillAmount = coolDownTime / factor; + yield return new WaitForSeconds(Time.deltaTime); + } + CoolDownImg.gameObject.SetActive(false); + StopWatchRoutine = null; + } + } +} diff --git a/Assets/Scripts/Gameplay/AbilityUI.cs.meta b/Assets/Scripts/Gameplay/AbilityUI.cs.meta new file mode 100644 index 0000000..7c6f517 --- /dev/null +++ b/Assets/Scripts/Gameplay/AbilityUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0398e1dcd39dde54b98e9e930bd6ebc5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: