diff --git a/Assets/Prefabs/Camera/Cinemachine.prefab b/Assets/Prefabs/Camera/Cinemachine.prefab index 6f2b958..3d583ae 100644 --- a/Assets/Prefabs/Camera/Cinemachine.prefab +++ b/Assets/Prefabs/Camera/Cinemachine.prefab @@ -154,6 +154,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 8882344377078016156} + - component: {fileID: 7560456916114173029} m_Layer: 0 m_Name: Cinemachine m_TagString: Untagged @@ -179,6 +180,18 @@ Transform: - {fileID: 3665490202611795451} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7560456916114173029 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1127111119625446846} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6ffacdb73add99f4b9c96850264e7d1a, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1400473914611959530 GameObject: m_ObjectHideFlags: 3 @@ -283,7 +296,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2383950784329503899} serializedVersion: 2 - m_LocalRotation: {x: -0.0501939, y: 0.8159028, z: 0.5715319, w: 0.07165539} + m_LocalRotation: {x: -0.05019385, y: 0.8159028, z: 0.5715319, w: 0.071655326} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -622,8 +635,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6163557566655415017} serializedVersion: 2 - m_LocalRotation: {x: -0.0501939, y: 0.8159028, z: 0.5715319, w: 0.07165539} - m_LocalPosition: {x: 4.5844216, y: -19.255428, z: 6.807705} + m_LocalRotation: {x: -0.05019385, y: 0.8159028, z: 0.5715319, w: 0.071655326} + m_LocalPosition: {x: 4.584422, y: -19.255428, z: 6.807704} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Prefabs/Camera/TowerCam.prefab b/Assets/Prefabs/Camera/TowerCam.prefab index b9882df..6434c21 100644 --- a/Assets/Prefabs/Camera/TowerCam.prefab +++ b/Assets/Prefabs/Camera/TowerCam.prefab @@ -586,7 +586,6 @@ GameObject: - component: {fileID: 6162594480593627889} - component: {fileID: 5831827090361496139} - component: {fileID: 1880671857495123661} - - component: {fileID: 3685285690701009546} m_Layer: 0 m_Name: TowerCam m_TagString: Untagged @@ -730,6 +729,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_gameObject: {fileID: 0} + newTarget: {fileID: 0} --- !u!114 &5831827090361496139 MonoBehaviour: m_ObjectHideFlags: 0 @@ -782,26 +782,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 44d70cc20219cd84593f67d248eafe36, type: 3} m_Name: m_EditorClassIdentifier: - m_Offset: {x: 0, y: 0, z: -0.1} - m_ApplyAfter: 1 + m_Offset: {x: 0, y: 0, z: 0} + m_ApplyAfter: 0 m_PreserveComposition: 0 ---- !u!114 &3685285690701009546 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7612880158138396871} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0aa8da13840a5cb43997aca17b09b15d, type: 3} - m_Name: - m_EditorClassIdentifier: - target: {fileID: 0} - origin: {fileID: 7612880158138396871} - towerCamScript: {fileID: 6162594480593627889} - hideFadeSpeed: 7 - showFadeSpeed: 2 - sphereRadius: 3.5 - sphereRange: 2.5 - sphereOffset: {x: 0, y: 8, z: 0} diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 6e0f38d..6d24856 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -123,6 +123,88 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!21 &30339316 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 97.8265, g: 37.763, b: 0, a: 0} + - _r: {r: 30.96, g: 0, b: 0, a: 0} + - _rect2props: {r: 7.7400208, g: -7.7400017, b: 84.93025, a: 95.87626} + m_BuildTextureStacks: [] +--- !u!21 &34326813 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 5, g: 13.05, b: 0, a: 0} + - _r: {r: 0, g: 0, b: 5, a: 5} + - _rect2props: {r: 0.00000047683716, g: 2.4999986, b: 10.995511, a: 10.995511} + m_BuildTextureStacks: [] --- !u!20 &57718964 stripped Camera: m_CorrespondingSourceObject: {fileID: 3255403189825384754, guid: fd9f9b61c0ebb324ebc9f929e26706bc, @@ -1188,6 +1270,47 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7355133f21643b44e8b997303686916c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!21 &549491337 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 5, g: 13.05, b: 0, a: 0} + - _r: {r: 5, g: 5, b: 0, a: 0} + - _rect2props: {r: 0, g: -2.500002, b: 10.995511, a: 10.995511} + m_BuildTextureStacks: [] --- !u!1 &739155301 GameObject: m_ObjectHideFlags: 0 @@ -1638,72 +1761,32 @@ PrefabInstance: - target: {fileID: 2465233980315321778, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.w - value: 0.07165537 + value: 0.071655326 objectReference: {fileID: 0} - target: {fileID: 2465233980315321778, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.x - value: -0.050193876 - objectReference: {fileID: 0} - - target: {fileID: 2465233980315321778, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.z - value: 0.57153195 - objectReference: {fileID: 0} - - target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalPosition.x - value: 4.584422 - objectReference: {fileID: 0} - - target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalPosition.z - value: 6.807705 + value: -0.05019385 objectReference: {fileID: 0} - target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.w - value: 0.07165537 + value: 0.071655326 objectReference: {fileID: 0} - target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.x - value: -0.050193876 - objectReference: {fileID: 0} - - target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.z - value: 0.57153195 + value: -0.05019385 objectReference: {fileID: 0} - target: {fileID: 5753661378891917460, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.w - value: 0.07306354 + value: 0.07306359 objectReference: {fileID: 0} - target: {fileID: 5753661378891917460, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} propertyPath: m_LocalRotation.x - value: -0.04812096 - objectReference: {fileID: 0} - - target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.w - value: 0.074420586 - objectReference: {fileID: 0} - - target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.x - value: -0.04599445 - objectReference: {fileID: 0} - - target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.y - value: 0.84738916 - objectReference: {fileID: 0} - - target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc, - type: 3} - propertyPath: m_LocalRotation.z - value: 0.5237152 + value: -0.048121 objectReference: {fileID: 0} - target: {fileID: 8510394576666186474, guid: fd9f9b61c0ebb324ebc9f929e26706bc, type: 3} @@ -2031,6 +2114,47 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1016399493} m_PrefabAsset: {fileID: 0} +--- !u!21 &1113139868 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 340.1145, g: 535, b: 0, a: 0} + - _r: {r: 0, g: 0, b: 0, a: 40} + - _rect2props: {r: 10.0000305, g: 9.999878, b: 618.79944, a: 604.6573} + m_BuildTextureStacks: [] --- !u!1 &1117810916 GameObject: m_ObjectHideFlags: 0 @@ -2241,6 +2365,47 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1211328792} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!21 &1245510236 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 360, g: 550, b: 0, a: 0} + - _r: {r: 0, g: 59.4, b: 59.4, a: 59.4} + - _rect2props: {r: -14.850006, g: 14.849915, b: 622.4661, a: 601.4651} + m_BuildTextureStacks: [] --- !u!114 &1335003908 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 4274405463174037481, guid: 04b33788ffcc15e4e8f74ae3b8d95dc3, @@ -2265,6 +2430,47 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bb343e5418f1e1144aab7c51b7482da7, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!21 &1415767759 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 35.4485, g: 38.0555, b: 0, a: 0} + - _r: {r: 40, g: 0, b: 0, a: 40} + - _rect2props: {r: 20.000002, g: -0.0000038146973, b: 37.833046, a: 37.833046} + m_BuildTextureStacks: [] --- !u!21 &1454190399 Material: serializedVersion: 8 @@ -2629,6 +2835,47 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1554436711} m_PrefabAsset: {fileID: 0} +--- !u!21 &1565628770 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 97.85, g: 477.754, b: 0, a: 0} + - _r: {r: 0, g: 0, b: 0, a: 40} + - _rect2props: {r: 10, g: 9.999939, b: 407.01352, a: 392.87137} + m_BuildTextureStacks: [] --- !u!1 &1644633573 GameObject: m_ObjectHideFlags: 0 @@ -3147,6 +3394,47 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: TargetCarveGrid: {fileID: 1812668202} +--- !u!21 &2040596485 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI/RoundedCorners/IndependentRoundedCorners + m_Shader: {fileID: 4800000, guid: d3beb88e61f88ca4393acdefb005fa70, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _halfSize: {r: 36.5705, g: 37.7215, b: 0, a: 0} + - _r: {r: 40, g: 0, b: 0, a: 40} + - _rect2props: {r: 20, g: -0.0000076293945, b: 38.390244, a: 38.390244} + m_BuildTextureStacks: [] --- !u!1001 &2074753046 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Camera/CameraController.cs b/Assets/Scripts/Camera/CameraController.cs index dbaf129..b353e1c 100644 --- a/Assets/Scripts/Camera/CameraController.cs +++ b/Assets/Scripts/Camera/CameraController.cs @@ -4,8 +4,6 @@ using System.Collections; public class CameraController : MonoBehaviour { - public static CameraController instance; - [SerializeField] private GameObject cam; public float scrollSpeed = 2.5f; @@ -17,17 +15,8 @@ public class CameraController : MonoBehaviour private float timer; - private void Awake() - { - if (instance == null) - instance = this; - } - private void Start() { - if (instance != this) - instance = this; - defaultMaxSpeed *= 0; } @@ -66,29 +55,5 @@ public class CameraController : MonoBehaviour float evalTime = timer / stopAfterTime; if (!Input.GetMouseButton(1)) defaultMaxSpeed = Vector2.LerpUnclamped(defaultMaxSpeed, Vector2.zero, curve.Evaluate(evalTime)); - } - - public void ShakeCamera(float intensity, float duration) - { - StartCoroutine(DoShake(intensity, duration)); - } - - private IEnumerator DoShake(float intensity, float duration) - { - Vector3 originalOffset = cam.GetComponent().m_Offset; - float elapsed = 0.0f; - - while (elapsed < duration) - { - float x = Random.Range(-1f, 1f) * intensity; - float y = Random.Range(-1f, 1f) * intensity; - - cam.GetComponent().m_Offset = new Vector3(x, y, originalOffset.z); - - elapsed += Time.deltaTime; - yield return null; - } - - cam.GetComponent().m_Offset = originalOffset; - } + } } diff --git a/Assets/Scripts/Camera/CameraShake.cs b/Assets/Scripts/Camera/CameraShake.cs new file mode 100644 index 0000000..4319e40 --- /dev/null +++ b/Assets/Scripts/Camera/CameraShake.cs @@ -0,0 +1,43 @@ +using System.Collections; +using Cinemachine; +using UnityEngine; + +public class CameraShake : MonoBehaviour +{ + public static CameraShake instance; + + void Start() + { + if (instance == null) + instance = this; + } + public void ShakeCamera(float intensity, float duration) + { + StartCoroutine(DoShake(intensity, duration)); + print("Shaking da booty"); + } + + private IEnumerator DoShake(float intensity, float duration) + { + var cam = CinemachineCore.Instance.GetActiveBrain(0).ActiveVirtualCamera.VirtualCameraGameObject.GetComponent(); + + CinemachineCameraOffset cinemachineCameraOffset = cam.GetComponent(); + Vector3 originalOffset = cinemachineCameraOffset.m_Offset; + float elapsed = 0.0f; + + while (elapsed < duration) + { + float x = Random.Range(-1f, 1f) * intensity; + float y = Random.Range(-1f, 1f) * intensity; + + print("x: " + x + "y: " + y); + + cam.GetComponent().m_Offset = new Vector3(x, y, originalOffset.z); + + elapsed += Time.deltaTime; + yield return null; + } + + cam.GetComponent().m_Offset = originalOffset; + } +} diff --git a/Assets/Scripts/Camera/CameraShake.cs.meta b/Assets/Scripts/Camera/CameraShake.cs.meta new file mode 100644 index 0000000..a52c5ca --- /dev/null +++ b/Assets/Scripts/Camera/CameraShake.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6ffacdb73add99f4b9c96850264e7d1a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utilities/HealthComponent.cs b/Assets/Scripts/Utilities/HealthComponent.cs index 9d94c81..2e381ad 100644 --- a/Assets/Scripts/Utilities/HealthComponent.cs +++ b/Assets/Scripts/Utilities/HealthComponent.cs @@ -6,7 +6,7 @@ public class HealthComponent : MonoBehaviour { [SerializeField] float startHealth = 100; - public float currentHealth { get; private set; } + public float currentHealth { get; private set; } public static event Action OnHealthChangeAtPos; @@ -29,14 +29,14 @@ public class HealthComponent : MonoBehaviour OnHealthChangeAtPos?.Invoke(transform.position, currentHealth - damage); currentHealth -= damage; - currentHealth = (int) Mathf.Clamp(currentHealth, 0f, Mathf.Infinity); + currentHealth = (int)Mathf.Clamp(currentHealth, 0f, Mathf.Infinity); if (currentHealth == 0) OnHealthZero?.Invoke(); } public void SimpleKill() { - CameraController.instance.ShakeCamera(5,1); + CameraShake.instance.ShakeCamera(0.5f, 0.2f); Destroy(gameObject); }