diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 0c5d91359a5672cc5d35d9c99a0dd44d69f95713..d4423856b9e82c063c2731ea7badbab848e07b77 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -167,32 +167,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &111203058 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 5423466746631264166, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - m_PrefabInstance: {fileID: 4718921866596059802} - m_PrefabAsset: {fileID: 0} ---- !u!95 &111203062 -Animator: - serializedVersion: 5 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 111203058} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: 240e48418e1611c46a18fa4fd9cbe79f, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorStateOnDisable: 0 - m_WriteDefaultValuesOnDisable: 0 --- !u!1 &117855954 GameObject: m_ObjectHideFlags: 0 @@ -252,7 +226,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 675919035} - - {fileID: 1093326602} + - {fileID: 4061192957191616747} m_Father: {fileID: 484130345} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &117855958 @@ -414,23 +388,11 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &542408818 +--- !u!4 &542408818 stripped Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} + m_PrefabInstance: {fileID: 4169340464452295211} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1925035818} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.59, y: 0, z: 1.93} - m_LocalScale: {x: 5, y: 1, z: 5} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1167661571} - - {fileID: 1538428771} - m_Father: {fileID: 484130345} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &576314395 GameObject: m_ObjectHideFlags: 0 @@ -564,133 +526,11 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 126 m_CollisionDetection: 0 ---- !u!1 &675919034 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 675919035} - - component: {fileID: 675919038} - - component: {fileID: 675919037} - - component: {fileID: 675919036} - - component: {fileID: 675919039} - m_Layer: 6 - m_Name: Model - m_TagString: Player - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &675919035 +--- !u!4 &675919035 stripped Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} + m_PrefabInstance: {fileID: 4053253517607393480} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 675919034} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.75, z: 0} - m_LocalScale: {x: 0.4, y: 1.5, z: 0.4} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 117855957} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!95 &675919036 -Animator: - serializedVersion: 5 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 675919034} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: 90dd223aac3f61346bc92bf12b99b3c7, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorStateOnDisable: 0 - m_WriteDefaultValuesOnDisable: 0 ---- !u!23 &675919037 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 675919034} - 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: 10303, guid: 0000000000000000f000000000000000, type: 0} - 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!33 &675919038 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 675919034} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!65 &675919039 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 675919034} - 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!1 &705507993 GameObject: m_ObjectHideFlags: 0 @@ -787,8 +627,8 @@ Transform: m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!4 &766737620 stripped Transform: - m_CorrespondingSourceObject: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} - m_PrefabInstance: {fileID: 2131633842949370138} + m_CorrespondingSourceObject: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + m_PrefabInstance: {fileID: 1450041068962791888} m_PrefabAsset: {fileID: 0} --- !u!1 &770593019 GameObject: @@ -1137,11 +977,6 @@ MonoBehaviour: target: {fileID: 117855957} followingTime: 0.1 mouseSensitivity: 2 ---- !u!4 &1093326602 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - m_PrefabInstance: {fileID: 4718921866596059802} - m_PrefabAsset: {fileID: 0} --- !u!1 &1098815286 GameObject: m_ObjectHideFlags: 0 @@ -1175,7 +1010,7 @@ Transform: - {fileID: 705507995} - {fileID: 770593023} - {fileID: 576314396} - - {fileID: 1628232501} + - {fileID: 6199646963567315010} m_Father: {fileID: 239523007} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1098815288 @@ -1190,269 +1025,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c54dc993f0d1e36499ea37e182a87cbc, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &1167661570 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1167661571} - - component: {fileID: 1167661574} - - component: {fileID: 1167661573} - - component: {fileID: 1167661572} - m_Layer: 7 - m_Name: Model - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1167661571 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1167661570} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.75, z: 0} - m_LocalScale: {x: 0.4, y: 1.5, z: 0.4} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 542408818} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!95 &1167661572 -Animator: - serializedVersion: 5 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1167661570} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 0} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorStateOnDisable: 0 - m_WriteDefaultValuesOnDisable: 0 ---- !u!23 &1167661573 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1167661570} - 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: 10303, guid: 0000000000000000f000000000000000, type: 0} - 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!33 &1167661574 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1167661570} - m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1 &1538428770 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1538428771} - - component: {fileID: 1538428773} - - component: {fileID: 1538428772} - m_Layer: 7 - m_Name: Hitbox - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1538428771 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1538428770} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.59, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 542408818} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1538428772 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1538428770} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d305728f9c09ee84d861e4d2a18c0be0, type: 3} - m_Name: - m_EditorClassIdentifier: - damage: 0 - knockbackPower: 10 ---- !u!65 &1538428773 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1538428770} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 1 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Size: {x: 0.4, y: 1.5, z: 0.4} - m_Center: {x: 0, y: 0.75, z: 0} ---- !u!4 &1628232501 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} - m_PrefabInstance: {fileID: 8676018873226186172} - m_PrefabAsset: {fileID: 0} ---- !u!1 &1925035818 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 542408818} - - component: {fileID: 1925035821} - - component: {fileID: 1925035820} - - component: {fileID: 1925035819} - m_Layer: 7 - m_Name: Dummy - m_TagString: Enemy - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1925035819 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1925035818} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 36e5aa8cb18425941b8dede35c491e0e, type: 3} - m_Name: - m_EditorClassIdentifier: - Id: - knockbackResistance: 1 - baseSpeed: 0 - maxHealth: 100000 - health: 100000 - baseDamage: 0 ---- !u!54 &1925035820 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1925035818} - serializedVersion: 4 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_CenterOfMass: {x: 0, y: 0, z: 0} - m_InertiaTensor: {x: 1, y: 1, z: 1} - m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ImplicitCom: 1 - m_ImplicitTensor: 1 - m_UseGravity: 1 - m_IsKinematic: 0 - m_Interpolate: 0 - m_Constraints: 80 - m_CollisionDetection: 0 ---- !u!65 &1925035821 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1925035818} - 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: 0.4, y: 1.5, z: 0.4} - m_Center: {x: 0, y: 0.75, z: 0} --- !u!1 &2127634080 GameObject: m_ObjectHideFlags: 0 @@ -1498,7 +1070,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c051aae39aef0264ba144bc30cbe301e, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1001 &2131633842949370138 +--- !u!1001 &1450041068962791888 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 @@ -1506,47 +1078,47 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 2127634081} m_Modifications: - - target: {fileID: 1946870712216142017, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5383203518885919015, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_Name value: TestCollectible objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalPosition.x value: -1.597 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalPosition.y value: 0.843 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 4380898715013208265, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} + - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} @@ -1555,7 +1127,7 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} ---- !u!1001 &4718921866596059802 +--- !u!1001 &1974616678034099521 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 @@ -1563,131 +1135,240 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 117855957} m_Modifications: - - target: {fileID: 2635269686106844091, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - propertyPath: fireRange - value: 10 + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalPosition.x + value: 0.258 objectReference: {fileID: 0} - - target: {fileID: 2635269686106844091, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - propertyPath: BaseDamage - value: 10 + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalPosition.y + value: 0.889 objectReference: {fileID: 0} - - target: {fileID: 2635269686106844091, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - propertyPath: KnockbackPower - value: 10 + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalPosition.z + value: 0.375 objectReference: {fileID: 0} - - target: {fileID: 2635269686106844091, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - propertyPath: projectileSpeed - value: 50 + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 objectReference: {fileID: 0} - - target: {fileID: 3608611397487402253, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 5240801910879785525, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} propertyPath: m_Name value: TestWeapon objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} +--- !u!1001 &4053253517607393480 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 117855957} + m_Modifications: + - target: {fileID: 125248941348886635, guid: 71b1260932d07054caf2d52890e46704, type: 3} + propertyPath: m_Name + value: Model + objectReference: {fileID: 0} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalPosition.x - value: 0.258 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalPosition.y - value: 0.889 + value: 0.75 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalPosition.z - value: 0.375 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8728181779748450929, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + - target: {fileID: 1838854055268103909, guid: 71b1260932d07054caf2d52890e46704, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 5423466746631264166, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} - insertIndex: -1 - addedObject: {fileID: 111203062} - m_SourcePrefab: {fileID: 100100000, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} ---- !u!1001 &8676018873226186172 + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 71b1260932d07054caf2d52890e46704, type: 3} +--- !u!4 &4061192957191616747 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 1050311400148833009, guid: 1a7698227caac3d429dceb8aa5056502, type: 3} + m_PrefabInstance: {fileID: 1974616678034099521} + m_PrefabAsset: {fileID: 0} +--- !u!1001 &4169340464452295211 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 1098815287} + m_TransformParent: {fileID: 484130345} m_Modifications: - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 1629977785691913864, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalPosition.x - value: 3 + value: -1.59 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalPosition.z - value: 0 + value: 1.93 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 3345887698500519422, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 7848228299116585289, guid: c98b222ded23bb24690e674886e5741a, type: 3} + - target: {fileID: 8491347043216026353, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} + propertyPath: m_Name + value: Dummy + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} +--- !u!1001 &4779000661126631185 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 1098815287} + m_Modifications: + - target: {fileID: 6541102688641435260, guid: c98b222ded23bb24690e674886e5741a, type: 3} propertyPath: m_Name value: TestInteractable objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalPosition.x + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: c98b222ded23bb24690e674886e5741a, type: 3} +--- !u!4 &6199646963567315010 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} + m_PrefabInstance: {fileID: 4779000661126631185} + m_PrefabAsset: {fileID: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Config/CameraConfig.cs b/Assets/Scripts/Config/CameraConfig.cs index 3e8f2fd76b52948778907bea52026691f0fb9ed8..af1f52fbedc34edbca2a7fa7c3865b12c0dcfaa3 100644 --- a/Assets/Scripts/Config/CameraConfig.cs +++ b/Assets/Scripts/Config/CameraConfig.cs @@ -1,9 +1,11 @@ using UnityEngine; -public static class CameraConfig{ +// Configs should only contain constants and static readonly classes +public static class CameraConfig +{ // Movement lerp constants - public static readonly float DEFAULT_FOLLOWING_SPEED = 0.1f; + public const float DEFAULT_FOLLOWING_SPEED = 0.1f; // Offset for follow camera public static readonly Vector3 DEFAULT_CAMERA_OFFSET = new(0f, 0.2f, -2f); } \ No newline at end of file diff --git a/Assets/Scripts/Config/GameConfig.cs b/Assets/Scripts/Config/GameConfig.cs index d907e90332b78bd331188d3f29bd3d444f448c77..f02be23dbaa978c836bdc50e4460f0770acfb581 100644 --- a/Assets/Scripts/Config/GameConfig.cs +++ b/Assets/Scripts/Config/GameConfig.cs @@ -1,35 +1,41 @@ using System.Collections.Generic; -public static class GameConfig{ +// Configs should only contain constants and static readonly classes +public static class GameConfig +{ // Default damaged state delay value - public static readonly float DAMAGED_DELAY_DURATION = 1.0f; + public const float DAMAGED_DELAY_DURATION = 1.0f; // Movement lerp constants - public static readonly float MOVEMENT_SMOOTHING = 0.14f; - public static readonly float ROTATION_SMOOTHING = 720; - public static readonly float CAMERA_MOUSE_VERTICAL_MAX = 60; + public const float MOVEMENT_SMOOTHING = 0.14f; + public const float ROTATION_SMOOTHING = 720; + public const float CAMERA_MOUSE_VERTICAL_MAX = 60; // Difficulty multipliers - private static readonly DifficultyData EasyData = new(){ + private static readonly DifficultyData EasyData = new() + { EnemyDamageMultiplier = 0.5f, EnemyHealthMultiplier = 0.5f, PlayerDamageMultiplier = 2f, PlayerHealthMultiplier = 2f, }; - private static readonly DifficultyData MediumData = new(){ + private static readonly DifficultyData MediumData = new() + { EnemyDamageMultiplier = 0.5f, EnemyHealthMultiplier = 0.5f, PlayerDamageMultiplier = 2f, PlayerHealthMultiplier = 2f, }; - private static readonly DifficultyData HardData = new(){ + private static readonly DifficultyData HardData = new() + { EnemyDamageMultiplier = 2f, EnemyHealthMultiplier = 2f, PlayerDamageMultiplier = 0.5f, PlayerHealthMultiplier = 0.5f, }; - public static Dictionary<DifficultyType, DifficultyData> DIFFICULTY_MODIFIERS = new(){ + public static readonly Dictionary<DifficultyType, DifficultyData> DIFFICULTY_MODIFIERS = new() + { { DifficultyType.EASY, EasyData}, { DifficultyType.NORMAL, MediumData}, { DifficultyType.HARD, HardData} diff --git a/Assets/Scripts/Config/GameEnvironmentConfig.cs b/Assets/Scripts/Config/GameEnvironmentConfig.cs index 419338145faf806569c9810035f0d380b1cd399a..8cbed051d82d4441bdc8887bcd34bad97548c7ff 100644 --- a/Assets/Scripts/Config/GameEnvironmentConfig.cs +++ b/Assets/Scripts/Config/GameEnvironmentConfig.cs @@ -1,16 +1,17 @@ +// Configs should only contain constants and static readonly classes public static class GameEnvironmentConfig{ // Tags - public static readonly string TAG_UNTAGGED = "Untagged"; - public static readonly string TAG_PLAYER = "Player"; - public static readonly string TAG_ENEMY = "Enemy"; - public static readonly string TAG_COLLECTIBLES = "Collectibles"; - public static readonly string TAG_GROUND = "Ground"; + public const string TAG_UNTAGGED = "Untagged"; + public const string TAG_PLAYER = "Player"; + public const string TAG_ENEMY = "Enemy"; + public const string TAG_COLLECTIBLES = "Collectibles"; + public const string TAG_GROUND = "Ground"; // Layers - public static readonly string LAYER_PLAYER = "Player"; - public static readonly string LAYER_ENEMY = "Enemy"; - public static readonly string LAYER_PLAYER_ATTACK = "PlayerAttack"; - public static readonly string LAYER_ENEMY_ATTACK = "EnemyAttack"; - public static readonly string LAYER_ENVIRONMENT_ATTACK = "EnvironmentAttack"; - public static readonly string LAYER_COLLECTIBLE = "Collectible"; + public const string LAYER_PLAYER = "Player"; + public const string LAYER_ENEMY = "Enemy"; + public const string LAYER_PLAYER_ATTACK = "PlayerAttack"; + public const string LAYER_ENEMY_ATTACK = "EnemyAttack"; + public const string LAYER_ENVIRONMENT_ATTACK = "EnvironmentAttack"; + public const string LAYER_COLLECTIBLE = "Collectible"; } \ No newline at end of file diff --git a/Assets/Scripts/Core/Entities/Mobs/BossEntity.cs b/Assets/Scripts/Core/Entities/Mobs/BossEntity.cs index 21133940324fa79bcc982c4187d1a89928e36c2b..e85fc752cc586479ef76e37423d83139b853e005 100644 --- a/Assets/Scripts/Core/Entities/Mobs/BossEntity.cs +++ b/Assets/Scripts/Core/Entities/Mobs/BossEntity.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; -public abstract class BossEntity : EnemyEntity, IAccompaniable{ +public abstract class BossEntity : EnemyEntity, IAccompaniable +{ // Attributes private readonly List<Companions> companionList = new(); diff --git a/Assets/Scripts/Core/Entities/Mobs/Dummy/Dummy.cs b/Assets/Scripts/Core/Entities/Mobs/Dummy/Dummy.cs index b0db12c7c9a709a82cfce4f2c20e56533e443dc1..d33d6161740c242f0966949f3479f15aac1d9a8f 100644 --- a/Assets/Scripts/Core/Entities/Mobs/Dummy/Dummy.cs +++ b/Assets/Scripts/Core/Entities/Mobs/Dummy/Dummy.cs @@ -1,15 +1,17 @@ using UnityEngine; -public class Dummy : EnemyEntity{ +public class Dummy : EnemyEntity +{ // Static attributes - public static string ObjectIdPrefix = "Dummy"; + public const string ObjectIdPrefix = "Dummy"; // Attributes private DummyAnimationController animationController; public DummyStateController stateController; // Constructor - new protected void Start(){ + new protected void Start() + { base.Start(); SetIdPrefix(ObjectIdPrefix); stateController = new DummyStateController(this); diff --git a/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyAnimationController.cs b/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyAnimationController.cs index 2d47baaafca9453bf465a185297f8fa2fe0dda87..04783d5b91e747ae167f8ce377d8bd5fc3aca0cf 100644 --- a/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyAnimationController.cs +++ b/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyAnimationController.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class DummyAnimationController : AnimationController{ +public class DummyAnimationController : AnimationController +{ // Consts private const string HIT_TRIGGER = "hit_param"; @@ -8,18 +9,21 @@ public class DummyAnimationController : AnimationController{ private readonly Dummy dummy; // Constructor - public DummyAnimationController(Dummy dummy) : base(dummy) { + public DummyAnimationController(Dummy dummy) : base(dummy) + { this.dummy = dummy; dummy.OnDamagedEvent += IndicateDamaged; dummy.stateController.OnDamageDelayOverEvent += IndicateUnamaged; } // Functions - private void IndicateDamaged(){ + private void IndicateDamaged() + { meshRenderer.material.color = Color.red; } - private void IndicateUnamaged(){ + private void IndicateUnamaged() + { meshRenderer.material.color = Color.white; } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyStateController.cs b/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyStateController.cs index 60c91fb4c8e788537014ee47f39d572187341c5f..0f94ea237270b00df24219ae0d1d96c16db83df5 100644 --- a/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyStateController.cs +++ b/Assets/Scripts/Core/Entities/Mobs/Dummy/DummyStateController.cs @@ -1,9 +1,13 @@ -public class DummyStateController : DamageableEntityStateController{ +public class DummyStateController : DamageableEntityStateController +{ // Constructor - public DummyStateController(Dummy dummy) : base(dummy){} + public DummyStateController(Dummy dummy) : base(dummy) + { + } // Functions - public override int UpdateState(){ - return EntityState.IDLE; + public override int UpdateState() + { + return DefaultEntityState.IDLE; } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Entities/Mobs/EnemyEntity.cs b/Assets/Scripts/Core/Entities/Mobs/EnemyEntity.cs index 7570021eca691f94171112f09ffa3db7758f40a7..6008c0aa8275ac0448fac66011fae23d74e2b403 100644 --- a/Assets/Scripts/Core/Entities/Mobs/EnemyEntity.cs +++ b/Assets/Scripts/Core/Entities/Mobs/EnemyEntity.cs @@ -1,6 +1,8 @@ -public abstract class EnemyEntity : CombatantEntity { +public abstract class EnemyEntity : CombatantEntity +{ // Functions - new protected void Start(){ + new protected void Start() + { base.Start(); Health *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.instance.difficulty].EnemyHealthMultiplier; BaseDamage *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.instance.difficulty].EnemyDamageMultiplier; diff --git a/Assets/Scripts/Core/Entities/Pets/Companions.cs b/Assets/Scripts/Core/Entities/Pets/Companions.cs index 5cb61306d8b63be3013888c0083e7a628f942c41..32d59d5b681e1f2ee1114a12f6fa5eb453ff9381 100644 --- a/Assets/Scripts/Core/Entities/Pets/Companions.cs +++ b/Assets/Scripts/Core/Entities/Pets/Companions.cs @@ -1,7 +1,8 @@ using System; using UnityEngine; -public abstract class Companions : DamageableEntity { - // Functions - public virtual void Act(){} +public abstract class Companions : DamageableEntity +{ + // Abstract Functions + public abstract void Act(); } diff --git a/Assets/Scripts/Core/Game/Data/GameInput.cs b/Assets/Scripts/Core/Game/Data/GameInput.cs index d9b880e4d465c3ce4f251038754904e73d9e0f9c..ee3d3a64a83310c0e99fc0f0a23c772a72daa35f 100644 --- a/Assets/Scripts/Core/Game/Data/GameInput.cs +++ b/Assets/Scripts/Core/Game/Data/GameInput.cs @@ -1,8 +1,9 @@ using System; using UnityEngine; -public class GameInput : MonoBehaviour { - // Static instance +public class GameInput : MonoBehaviour +{ + // Static Instance public static GameInput instance; // Attributes @@ -12,7 +13,8 @@ public class GameInput : MonoBehaviour { [NonSerialized] public KeyCode interactButton = KeyCode.C; // Constructor - protected void Awake(){ + protected void Awake() + { instance = this; DontDestroyOnLoad(gameObject); } diff --git a/Assets/Scripts/Core/Game/Data/GameSaveData.cs b/Assets/Scripts/Core/Game/Data/GameSaveData.cs index 9bed0027dd6e0fdba119e6a553f711a49fb7f5b9..39ba72864816ea8b96659536e61c156bf7b70776 100644 --- a/Assets/Scripts/Core/Game/Data/GameSaveData.cs +++ b/Assets/Scripts/Core/Game/Data/GameSaveData.cs @@ -3,14 +3,17 @@ using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; -public class GameSaveData : MonoBehaviour { - // Attributes +public class GameSaveData : MonoBehaviour +{ + // Static Instance public static GameSaveData instance; + // Attributes public DifficultyType difficulty = DifficultyType.NORMAL; // Constructor - private void Awake(){ + private void Awake() + { instance = this; DontDestroyOnLoad(gameObject); } diff --git a/Assets/Scripts/Core/Game/GameCameraController.cs b/Assets/Scripts/Core/Game/GameCameraController.cs index f0f88a82871a77a0441cc6790f0ed86bbe3571d9..2c41bd6c7203e1c2412f9e353681e481c767601b 100644 --- a/Assets/Scripts/Core/Game/GameCameraController.cs +++ b/Assets/Scripts/Core/Game/GameCameraController.cs @@ -2,36 +2,44 @@ using System; using Unity.VisualScripting; using UnityEngine; -public class GameCameraController { +public class GameCameraController +{ // Attributes private Camera activeCamera; private CameraBehaviour behaviour; private CameraBehaviourType behaviourType; + + // Set-Getters public Transform Orientation => activeCamera.transform; // Constructor - public GameCameraController(Camera camera){ + public GameCameraController(Camera camera) + { activeCamera = camera; activeCamera.enabled = true; } // Functions - public void SwapCamera(Camera camera){ + public void SwapCamera(Camera camera) + { activeCamera.enabled = false; activeCamera = camera; activeCamera.enabled = true; } - public void ResetCameraBehaviour(){ + public void ResetCameraBehaviour() + { GameObject.Destroy(activeCamera.GetComponent<CameraBehaviour>()); behaviourType = CameraBehaviourType.NULL; behaviour = null; } - public void SetCameraBehaviour(CameraBehaviourType cameraBehaviourType){ + public void SetCameraBehaviour(CameraBehaviourType cameraBehaviourType) + { GameObject.Destroy(activeCamera.GetComponent<CameraBehaviour>()); - behaviour = cameraBehaviourType switch{ + behaviour = cameraBehaviourType switch + { CameraBehaviourType.STATIC => activeCamera.AddComponent<CameraStatic>(), CameraBehaviourType.FOLLOW => activeCamera.AddComponent<CameraFollowObject>(), CameraBehaviourType.MOUSE => activeCamera.AddComponent<CameraMouse>(), diff --git a/Assets/Scripts/Core/Game/GameController.cs b/Assets/Scripts/Core/Game/GameController.cs index 7a8863d18aaa0208a81577d58fdec3d06dff01f2..efebc945c8fd2d1b38a3cb91611137e7ee21341f 100644 --- a/Assets/Scripts/Core/Game/GameController.cs +++ b/Assets/Scripts/Core/Game/GameController.cs @@ -1,9 +1,12 @@ using System; using UnityEngine; -public class GameController : MonoBehaviour { - // Attributes +public class GameController : MonoBehaviour +{ + // Static Instance public static GameController instance; + + // Attributes public Player player; public GameCameraController mainCamera; public GameStateController stateController; @@ -13,16 +16,23 @@ public class GameController : MonoBehaviour { public bool IsPaused => Time.timeScale == 0; // Constructor - protected void Awake(){ - if(instance == null) instance = this; + protected void Awake() + { + if(instance == null) + { + instance = this; + } + mainCamera = new GameCameraController(GetComponentInChildren<Camera>()); stateController = new GameStateController(); data = GameSaveData.instance; } // Functions - protected void Update(){ - if(Input.GetKeyDown(GameInput.instance.backButton)){ + protected void Update() + { + if(Input.GetKeyDown(GameInput.instance.backButton)) + { stateController.HandleEscape(); } } diff --git a/Assets/Scripts/Core/Game/GameStateController.cs b/Assets/Scripts/Core/Game/GameStateController.cs index 91d3df00da802da5457f22b5507e6c9a82a70b95..df1ecb8f073b42a6d4b26f21c7ca69a365fd8e80 100644 --- a/Assets/Scripts/Core/Game/GameStateController.cs +++ b/Assets/Scripts/Core/Game/GameStateController.cs @@ -3,67 +3,57 @@ using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; -public class GameStateController{ +public class GameStateController +{ // Attributes private readonly Stack<GameState> gameStateStack = new(); event GameStateChangeEvent OnGameStateChange; + + // Events event Action OnPausedEvent; // Constructor - public GameStateController(){ + public GameStateController() + { gameStateStack.Push(GameState.NULL); gameStateStack.Push(GameState.RUNNING); - OnGameStateChange += LogGameStateStack; + OnGameStateChange += LogGameStateEvent; } // Functions - private void LogGameStateStack(GameStateChangeArgs e){ - Debug.Log(string.Format("GameState {0}; Current gamestate is {1}", e.EventType, e.NewGameState)); - } - - private void SetState(GameState gameState){ - //TODO: Review cutscenes and menu behaviour - Time.timeScale = gameState switch{ - GameState.PAUSED => 0, - GameState.RUNNING => 1, - GameState.CUTSCENE => 0, - GameState.MENU => 0, - _ => throw new Exception("Invalid gameState pushed to GameStateController, please refer to enum GameState for valid states"), - }; - Cursor.lockState = gameState switch { - GameState.PAUSED => CursorLockMode.None, - GameState.RUNNING => CursorLockMode.Locked, - GameState.CUTSCENE => CursorLockMode.Locked, - GameState.MENU => CursorLockMode.None, - _ => throw new Exception("Invalid gameState pushed to GameStateController, please refer to enum GameState for valid states"), - }; - } - - public void PushState(GameState gameState){ + public void PushState(GameState gameState) + { gameStateStack.Push(gameState); SetState(gameState); - OnGameStateChange?.Invoke(new GameStateChangeArgs( - StackChangeEventType.PUSH, - gameStateStack.Count, - gameState - )); + OnGameStateChange?.Invoke( + new GameStateChangeArgs( + StackChangeEventType.PUSH, + gameStateStack.Count, + gameState + ) + ); } - public void PopState(){ + public void PopState() + { gameStateStack.Pop(); GameState gameState = gameStateStack.Peek(); SetState(gameState); - OnGameStateChange?.Invoke(new GameStateChangeArgs( - StackChangeEventType.POP, - gameStateStack.Count, - gameState - )); + OnGameStateChange?.Invoke( + new GameStateChangeArgs( + StackChangeEventType.POP, + gameStateStack.Count, + gameState + ) + ); } - public void HandleEscape(){ - switch (gameStateStack.Peek()){ + public void HandleEscape() + { + switch (gameStateStack.Peek()) + { case GameState.RUNNING: PushState(GameState.PAUSED); OnPausedEvent?.Invoke(); @@ -79,4 +69,31 @@ public class GameStateController{ return; } } + + // Internal Functions + private void LogGameStateEvent(GameStateChangeArgs e) + { + Debug.Log(string.Format("GameState {0}; Current gamestate is {1}", e.EventType, e.NewGameState)); + } + + private void SetState(GameState gameState) + { + //TODO: Review cutscenes and menu behaviour + Time.timeScale = gameState switch + { + GameState.PAUSED => 0, + GameState.RUNNING => 1, + GameState.CUTSCENE => 0, + GameState.MENU => 0, + _ => throw new Exception("Invalid gameState pushed to GameStateController, please refer to enum GameState for valid states"), + }; + Cursor.lockState = gameState switch + { + GameState.PAUSED => CursorLockMode.None, + GameState.RUNNING => CursorLockMode.Locked, + GameState.CUTSCENE => CursorLockMode.Locked, + GameState.MENU => CursorLockMode.None, + _ => throw new Exception("Invalid gameState pushed to GameStateController, please refer to enum GameState for valid states"), + }; + } } diff --git a/Assets/Scripts/Core/Game/Managers/EntityManager.cs b/Assets/Scripts/Core/Game/Managers/EntityManager.cs index 0bf304d62065c88b677b0b4e99e9579ac446439e..933e4e714aa26a83b2d232da043ab945ffbf16c8 100644 --- a/Assets/Scripts/Core/Game/Managers/EntityManager.cs +++ b/Assets/Scripts/Core/Game/Managers/EntityManager.cs @@ -2,12 +2,14 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class EntityManager : BaseObjectManager{ +public class EntityManager : BaseObjectManager +{ // Static instance public static EntityManager instance; // Constructor - protected void Awake(){ + protected void Awake() + { instance = this; ManagerName = "Entity Manager"; } diff --git a/Assets/Scripts/Core/Game/Managers/EnvironmentManager.cs b/Assets/Scripts/Core/Game/Managers/EnvironmentManager.cs index 7f9623965889138cdae076d69f967a3f61601086..b06205ab9568e402bbdc2a56e288fa069c161804 100644 --- a/Assets/Scripts/Core/Game/Managers/EnvironmentManager.cs +++ b/Assets/Scripts/Core/Game/Managers/EnvironmentManager.cs @@ -2,12 +2,14 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class EnvironmentManager : BaseObjectManager{ +public class EnvironmentManager : BaseObjectManager +{ // Static instance public static EnvironmentManager instance; // Constructor - protected void Awake(){ + protected void Awake() + { instance = this; ManagerName = "Environment Manager"; } diff --git a/Assets/Scripts/Core/Game/Managers/ObjectManager.cs b/Assets/Scripts/Core/Game/Managers/ObjectManager.cs index 0882dd1253742d2aa9655cf54a66b520a26ef11c..ea2f62f614ab8d178d0a8b46058637deb1a9f7b6 100644 --- a/Assets/Scripts/Core/Game/Managers/ObjectManager.cs +++ b/Assets/Scripts/Core/Game/Managers/ObjectManager.cs @@ -1,11 +1,13 @@ using UnityEngine; -public class ObjectManager : BaseObjectManager{ +public class ObjectManager : BaseObjectManager +{ // Static Instance public static ObjectManager instance; // Constructor - protected void Awake(){ + protected void Awake() + { instance = this; ManagerName = "Object Manager"; } diff --git a/Assets/Scripts/Core/Objects/Collectibles/Collectible.cs b/Assets/Scripts/Core/Objects/Collectibles/Collectible.cs index 3c59fe0121db1a2d0ba267a649cab234c96081b6..2f55343027051087eb87c4e10d90081dd56d895b 100644 --- a/Assets/Scripts/Core/Objects/Collectibles/Collectible.cs +++ b/Assets/Scripts/Core/Objects/Collectibles/Collectible.cs @@ -2,14 +2,18 @@ using System; using System.Collections; using UnityEngine; -public abstract class Collectible : WorldObject { +public abstract class Collectible : WorldObject +{ // Attributes [SerializeField] float TimeToLive; + + // Events private event Action OnCollectEvent; private event Action OnTimeoutEvent; // Constructor - protected void Start(){ + protected void Start() + { OnCollectEvent += OnCollect; OnCollectEvent += OnCollectEnd; OnTimeoutEvent += OnTimeout; @@ -18,36 +22,42 @@ public abstract class Collectible : WorldObject { } // Functions - protected void OnTriggerEnter(Collider otherCollider){ + protected void OnTriggerEnter(Collider otherCollider) + { OnCollectEvent?.Invoke(); } - protected virtual void OnCollectEnd(){ + protected virtual void OnCollectEnd() + { Destroy(gameObject); } - protected IEnumerator Timeout(){ + protected IEnumerator Timeout() + { yield return new WaitForSeconds(TimeToLive); OnTimeoutEvent?.Invoke(); } - protected void OnTimeoutEnd(){ + protected void OnTimeoutEnd() + { Destroy(gameObject); } - public void AddOnTimeout(Action onTimeout){ + public void AddOnTimeout(Action onTimeout) + { OnTimeoutEvent -= OnTimeoutEnd; OnTimeoutEvent += onTimeout; OnTimeoutEvent += OnTimeoutEnd; } - public void RemoveOnTimeout(Action onTimeout){ + public void RemoveOnTimeout(Action onTimeout) + { OnTimeoutEvent -= OnTimeoutEnd; OnTimeoutEvent -= onTimeout; OnTimeoutEvent += OnTimeoutEnd; } // Abstract Functions - protected virtual void OnTimeout(){} + protected abstract void OnTimeout(); protected abstract void OnCollect(); } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Collectibles/TestCollectible/TestCollectible.cs b/Assets/Scripts/Core/Objects/Collectibles/TestCollectible/TestCollectible.cs index 2d334ba1432aef0e184ea33f101ffae9b963792f..33fea09227a10dbaeb1db1aa35d5a37576be24f6 100644 --- a/Assets/Scripts/Core/Objects/Collectibles/TestCollectible/TestCollectible.cs +++ b/Assets/Scripts/Core/Objects/Collectibles/TestCollectible/TestCollectible.cs @@ -1,21 +1,25 @@ using UnityEngine; -public class TestCollectible : Collectible{ - // Static attributes - public static string ObjectIdPrefix = "TestCollectible"; +public class TestCollectible : Collectible +{ + // Static Attributes + public const string ObjectIdPrefix = "TestCollectible"; // Constructor - protected new void Start(){ + protected new void Start() + { base.Start(); SetIdPrefix(ObjectIdPrefix); } // Functions - protected override void OnCollect(){ + protected override void OnCollect() + { Debug.Log("Test collectible collected"); } - protected override void OnTimeout(){ + protected override void OnTimeout() + { Debug.Log("Test collectible timeout"); } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Interactables/InteractableObject.cs b/Assets/Scripts/Core/Objects/Interactables/InteractableObject.cs index cbd1d37f8d6b6ff2113f2f22d134f8f1a0ea39d2..668b3c6396b95a584b43cf415fe846d3b228af17 100644 --- a/Assets/Scripts/Core/Objects/Interactables/InteractableObject.cs +++ b/Assets/Scripts/Core/Objects/Interactables/InteractableObject.cs @@ -1,19 +1,24 @@ using System; using UnityEngine; -public abstract class InteractableObject : MonoBehaviour, IInteractable{ - // Attributes +public abstract class InteractableObject : MonoBehaviour, IInteractable +{ + // Events public event Action OnInteractAreaExitEvent; public event Action OnInteractAreaEnterEvent; // Function - public abstract void Interact(); - public void InvokeOnInteractAreaEnterEvent(){ + public void InvokeOnInteractAreaEnterEvent() + { OnInteractAreaEnterEvent?.Invoke(); } - public void InvokeOnInteractAreaExitEvent(){ + public void InvokeOnInteractAreaExitEvent() + { OnInteractAreaExitEvent?.Invoke(); } + + // Abstract Functions + public abstract void Interact(); } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractable.cs b/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractable.cs index fb7f9c47602f95ebdd541eff6638c0b493a8949e..5d5164801a429ecf337e8c02b3b5b0efc687be74 100644 --- a/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractable.cs +++ b/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractable.cs @@ -1,17 +1,20 @@ using System; using UnityEngine; -public class TestInteractable : InteractableObject { +public class TestInteractable : InteractableObject +{ // Attributes private TestInteractableAnimationController animationController; // Constructor - protected void Start(){ + protected void Start() + { animationController = new TestInteractableAnimationController(this); } // Function - public override void Interact(){ + public override void Interact() + { Debug.Log("Test Interactable interacted"); } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractableAnimationController.cs b/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractableAnimationController.cs index be1a8021de3a9f8ea7be2b73dc3d1d3709cb058b..dd8ed88bfbc0913fb736099eb7815c3d9aba6d43 100644 --- a/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractableAnimationController.cs +++ b/Assets/Scripts/Core/Objects/Interactables/TestInteractable/TestInteractableAnimationController.cs @@ -1,24 +1,28 @@ using UnityEngine; -public class TestInteractableAnimationController : AnimationController{ +public class TestInteractableAnimationController : AnimationController +{ // Attributes private readonly TestInteractable testInteractable; // Constructor - public TestInteractableAnimationController(TestInteractable testInteractable) : base(testInteractable) { + public TestInteractableAnimationController(TestInteractable testInteractable) : base(testInteractable) + { this.testInteractable = testInteractable; testInteractable.OnInteractAreaEnterEvent += IndicateInteractable; testInteractable.OnInteractAreaExitEvent += IndicateUninteractable; } // Functions - private void IndicateInteractable(){ + private void IndicateInteractable() + { Debug.Log("Test Interactable is interactable now"); meshRenderer.material.color = Color.yellow; } - private void IndicateUninteractable(){ + private void IndicateUninteractable() + { Debug.Log("Test Interactable is uninteractable now"); meshRenderer.material.color = Color.white; } diff --git a/Assets/Scripts/Core/Objects/Weapons/NoWeapon/NoWeapon.cs b/Assets/Scripts/Core/Objects/Weapons/NoWeapon/NoWeapon.cs index 0037d614bdea2a728ecfc3ac40c4528b93f8a883..31cbc8cb0d233d52798e1ae24a073ceaaa83ff65 100644 --- a/Assets/Scripts/Core/Objects/Weapons/NoWeapon/NoWeapon.cs +++ b/Assets/Scripts/Core/Objects/Weapons/NoWeapon/NoWeapon.cs @@ -1,4 +1,10 @@ public class NoWeapon : WeaponObject{ - protected override void OnAttack(){} - protected override void OnAlternateAttack(){} + // Functions + protected override void OnAttack() + { + } + + protected override void OnAlternateAttack() + { + } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Weapons/ProjectileObject.cs b/Assets/Scripts/Core/Objects/Weapons/ProjectileObject.cs index 61959b6ffce02257287584f611d318276a8e355c..f1eb6c19bb259ee43dae26d003f7f1ddd01cc84c 100644 --- a/Assets/Scripts/Core/Objects/Weapons/ProjectileObject.cs +++ b/Assets/Scripts/Core/Objects/Weapons/ProjectileObject.cs @@ -1,6 +1,7 @@ using UnityEngine; -public abstract class ProjectileObject : AttackObject{ +public abstract class ProjectileObject : AttackObject +{ // Attributes protected float distanceTravelled = 0; protected Vector3 position; @@ -10,25 +11,35 @@ public abstract class ProjectileObject : AttackObject{ public bool through; // Constructor - protected new void Start(){ + protected new void Start() + { base.Start(); position = transform.position; } // Functions - protected void OnTriggerEnter(Collider otherCollider){ - if(Hit(otherCollider) && !through) Destroy(gameObject); + protected void OnTriggerEnter(Collider otherCollider) + { + if(Hit(otherCollider) && !through) + { + Destroy(gameObject); + } } - protected virtual void Move(){ + protected virtual void Move() + { transform.position += direction.normalized * speed / 100; } - protected void FixedUpdate(){ + protected void FixedUpdate() + { Move(); distanceTravelled += Vector3.Distance(transform.position, position); position = transform.position; - if(distanceTravelled >= travelDistance) Destroy(gameObject); + if(distanceTravelled >= travelDistance) + { + Destroy(gameObject); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestProjectile.cs b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestProjectile.cs index 8782c7f6d1da4ff63cf4293b829343b8a18f36d7..a17d8159b3ce225f22b7d21864966a42f1e6ba00 100644 --- a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestProjectile.cs +++ b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestProjectile.cs @@ -1 +1,3 @@ -public class TestProjectile : ProjectileObject{} \ No newline at end of file +public class TestProjectile : ProjectileObject +{ +} \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeapon.cs b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeapon.cs index 8071b066287b3c4c834b08d3149d7e94ec2fe05f..210c837e23e13f8908c0f6b4f6253074fe2ff83a 100644 --- a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeapon.cs +++ b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeapon.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class TestWeapon : WeaponObject{ +public class TestWeapon : WeaponObject +{ // Constants private static readonly string hitboxPrefab = "Prefabs/Weapons/TestWeapon/WeaponHitbox"; private static readonly string projectilePrefab = "Prefabs/Weapons/TestWeapon/TestProjectile"; @@ -11,13 +12,15 @@ public class TestWeapon : WeaponObject{ private TestWeaponAnimationController animationController; // Constructor - protected new void Start(){ + protected new void Start() + { base.Start(); animationController = new TestWeaponAnimationController(this); } // Function - protected override void OnAttack(){ + protected override void OnAttack() + { ProjectileObject attackProjectile = ObjectFactory.CreateAttackObject<ProjectileObject>( prefabPath: projectilePrefab, damage: MathUtils.CalculateDamage(bearer.BaseDamage, BaseDamage), @@ -28,6 +31,7 @@ public class TestWeapon : WeaponObject{ knockbackOrigin: transform.position - (bearer.Orientation.forward * projectileSpeed), objectName: "TestWeapon Projectile" ); + attackProjectile.travelDistance = fireRange; attackProjectile.speed = projectileSpeed; attackProjectile.direction = bearer.Orientation.forward; @@ -35,7 +39,8 @@ public class TestWeapon : WeaponObject{ ObjectFactory.DestroyObject(attackProjectile, 1f); } - protected override void OnAlternateAttack(){ + protected override void OnAlternateAttack() + { animationController.AnimateAlternateAttack(); AttackObject attackHitbox = ObjectFactory.CreateAttackObject( diff --git a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeaponAnimationController.cs b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeaponAnimationController.cs index 2d07d1305b6fceefc15cf74a10721f30e73ea75f..7b33a22e7e8ae56b0cf11b323c97c55bab814b7c 100644 --- a/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeaponAnimationController.cs +++ b/Assets/Scripts/Core/Objects/Weapons/TestWeapon/TestWeaponAnimationController.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class TestWeaponAnimationController : AnimationController{ +public class TestWeaponAnimationController : AnimationController +{ // Consts private const string ALTERNATE_ATTACK_TRIGGER = "AlternateAttack_param"; @@ -8,12 +9,14 @@ public class TestWeaponAnimationController : AnimationController{ private readonly TestWeapon testWeapon; // Constructor - public TestWeaponAnimationController(TestWeapon testWeapon) : base(testWeapon){ + public TestWeaponAnimationController(TestWeapon testWeapon) : base(testWeapon) + { this.testWeapon = testWeapon; } // Functions - public void AnimateAlternateAttack(){ + public void AnimateAlternateAttack() + { animator.SetBool(ALTERNATE_ATTACK_TRIGGER, true); } } \ No newline at end of file diff --git a/Assets/Scripts/Core/Objects/Weapons/WeaponObject.cs b/Assets/Scripts/Core/Objects/Weapons/WeaponObject.cs index 0c7194c757f6c5d4002904f592f8e8bdf8d94bbe..afb1784a83888ca7a932bac3be9a78bf94951c4e 100644 --- a/Assets/Scripts/Core/Objects/Weapons/WeaponObject.cs +++ b/Assets/Scripts/Core/Objects/Weapons/WeaponObject.cs @@ -2,7 +2,8 @@ using System; using System.Collections; using UnityEngine; -public abstract class WeaponObject : MonoBehaviour { +public abstract class WeaponObject : MonoBehaviour +{ // Attributes protected AttackObjectType bearerType; protected IArmed bearer; @@ -10,16 +11,30 @@ public abstract class WeaponObject : MonoBehaviour { [SerializeField] protected float KnockbackPower; [SerializeField] protected float AttackInterval; [SerializeField] protected float AlternateAttackInterval; + [SerializeField] private bool canAttack; + + // Events public event Action OnAttackEvent; public event Action OnAlternateAttackEvent; - [SerializeField] private bool canAttack; // Constructor - protected void Start(){ + protected void Start() + { bearer = GetComponentInParent<IArmed>(); - if(bearer is Player) bearerType = AttackObjectType.PLAYER; - else if(bearer is EnemyEntity) bearerType = AttackObjectType.ENEMY; - else bearerType = AttackObjectType.ENVIRONMENT; + + // Switch requires a constant, so can't use that here + if(bearer is Player) + { + bearerType = AttackObjectType.PLAYER; + } + else if(bearer is EnemyEntity) + { + bearerType = AttackObjectType.ENEMY; + } + else + { + bearerType = AttackObjectType.ENVIRONMENT; + } canAttack = true; OnAttackEvent += OnAttack; @@ -27,27 +42,41 @@ public abstract class WeaponObject : MonoBehaviour { } // Functions - public virtual bool Attack(){ - if(!canAttack) return false; + public virtual bool Attack() + { + if(!canAttack) + { + return false; + } + canAttack = false; StartCoroutine(DelayAttack(AttackInterval)); OnAttackEvent?.Invoke(); + return true; } - public virtual bool AlternateAttack(){ - if(!canAttack) return false; + public virtual bool AlternateAttack() + { + if(!canAttack) + { + return false; + } + canAttack = false; StartCoroutine(DelayAttack(AlternateAttackInterval)); OnAlternateAttackEvent?.Invoke(); + return true; } - protected abstract void OnAttack(); - protected abstract void OnAlternateAttack(); - - private IEnumerator DelayAttack(float time){ + private IEnumerator DelayAttack(float time) + { yield return new WaitForSeconds(time); canAttack = true; } + + // Abstract Functions + protected abstract void OnAttack(); + protected abstract void OnAlternateAttack(); } diff --git a/Assets/Scripts/Core/Player/Player.cs b/Assets/Scripts/Core/Player/Player.cs index 44c47ea373233f058fb038706f5b982da33ea963..4027f21ef6fda9041613b9a80ede349f5202900d 100644 --- a/Assets/Scripts/Core/Player/Player.cs +++ b/Assets/Scripts/Core/Player/Player.cs @@ -3,9 +3,10 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class Player : PlayerEntity { - // Static attributes - public static string ObjectIdPrefix = "Player"; +public class Player : PlayerEntity +{ + // Static Attributes + public const string ObjectIdPrefix = "Player"; // Attributes private PlayerAnimationController animationController; @@ -15,45 +16,61 @@ public class Player : PlayerEntity { public PlayerStats stats; // Constructor - new void Start(){ + new void Start() + { base.Start(); SetIdPrefix(ObjectIdPrefix); Health *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.instance.difficulty].PlayerHealthMultiplier; - Weapon = GetComponentInChildren<WeaponObject>(); stateController = new PlayerStateController(this); inputController = new PlayerInputController(this); movementController = new PlayerMovementController(this); animationController = new PlayerAnimationController(this); stats = new PlayerStats(this); + WeaponList.Add(GetComponentInChildren<WeaponObject>()); + WeaponIndex = 0; + GameController.instance.player = this; } // Functions - protected new void Update(){ + protected new void Update() + { base.Update(); inputController.HandleInputs(); } - protected new void FixedUpdate(){ + protected new void FixedUpdate() + { base.FixedUpdate(); movementController.HandleMovement(); - stateController.UpdateState(); } - protected void OnTriggerEnter(Collider otherCollider){ + protected void OnTriggerEnter(Collider otherCollider) + { otherCollider.transform.TryGetComponent<IInteractable>(out var interactable); - if(interactable == null) return; + + if(interactable == null) + { + return; + } + interactable.InvokeOnInteractAreaEnterEvent(); stateController.currentInteractables.Add(interactable); } - protected void OnTriggerExit(Collider otherCollider){ + protected void OnTriggerExit(Collider otherCollider) + { otherCollider.transform.TryGetComponent<IInteractable>(out var interactable); - if(interactable == null) return; + + if(interactable == null) + { + return; + } + interactable.InvokeOnInteractAreaExitEvent(); stateController.currentInteractables.Remove(interactable); } diff --git a/Assets/Scripts/Core/Player/PlayerAnimationController.cs b/Assets/Scripts/Core/Player/PlayerAnimationController.cs index ddaf7306aa370fbc499c050c4af9025ef4cfd418..7d32ee5b01b2e912afa1d675a7f7ef560d01a4b4 100644 --- a/Assets/Scripts/Core/Player/PlayerAnimationController.cs +++ b/Assets/Scripts/Core/Player/PlayerAnimationController.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class PlayerAnimationController : AnimationController{ +public class PlayerAnimationController : AnimationController +{ // Consts private const string IDLE_TRIGGER = "Idle_param"; private const string WALK_TRIGGER = "Walk_param"; @@ -11,14 +12,17 @@ public class PlayerAnimationController : AnimationController{ private readonly PlayerStateController playerStateController; // Constructor - public PlayerAnimationController(Player player) : base(player) { + public PlayerAnimationController(Player player) : base(player) + { this.player = player; player.stateController.OnStateChangeEvent += AnimateStates; } // Functions - public void AnimateStates(){ - switch (player.stateController.state){ + public void AnimateStates() + { + switch (player.stateController.state) + { case PlayerState.IDLE: animator.SetBool(IDLE_TRIGGER, true); break; diff --git a/Assets/Scripts/Core/Player/PlayerInputController.cs b/Assets/Scripts/Core/Player/PlayerInputController.cs index 39031e31d93b47a99765eeec1d7468695632f78d..0af72b06a3aadb53950e6b027c84e08cf6afe58e 100644 --- a/Assets/Scripts/Core/Player/PlayerInputController.cs +++ b/Assets/Scripts/Core/Player/PlayerInputController.cs @@ -1,37 +1,53 @@ using System; using UnityEngine; -public class PlayerInputController{ +public class PlayerInputController +{ // Attributes private readonly Player player; public float movementInputX; public float movementInputZ; // Constructor - public PlayerInputController(Player player){ + public PlayerInputController(Player player) + { this.player = player; } // Functions - public void HandleInputs(){ + public void HandleInputs() + { movementInputX = Input.GetAxisRaw("Horizontal"); movementInputZ = Input.GetAxisRaw("Vertical"); - if(Input.GetKeyDown(GameInput.instance.attackButton)){ + if(Input.GetKeyDown(GameInput.instance.attackButton)) + { Debug.Log("Player is Attacking"); - if(player.Weapon == null) return; + if(player.Weapon == null) + { + return; + } player.Weapon.Attack(); } - else if(Input.GetKeyDown(GameInput.instance.attackAlternateButton)){ + else if(Input.GetKeyDown(GameInput.instance.attackAlternateButton)) + { Debug.Log("Player is Attacking (alternate)"); - if(player.Weapon == null) return; + if(player.Weapon == null) + { + return; + } player.Weapon.AlternateAttack(); } - else if(Input.GetKeyDown(GameInput.instance.interactButton)){ + else if(Input.GetKeyDown(GameInput.instance.interactButton)) + { Debug.Log("Player is interacting"); - if(player.stateController.currentInteractables.Count == 0 ) return; + if(player.stateController.currentInteractables.Count == 0) + { + return; + } + IInteractable interactable = player.stateController.currentInteractables[player.stateController.currentInteractables.Count - 1]; interactable.Interact(); } diff --git a/Assets/Scripts/Core/Player/PlayerMovementController.cs b/Assets/Scripts/Core/Player/PlayerMovementController.cs index 474bb0aef3b0d21ac5ccd1c4a22392e187fa36a0..3b4bcbd8c2877e9813db4c2aa7dae0cb36376f27 100644 --- a/Assets/Scripts/Core/Player/PlayerMovementController.cs +++ b/Assets/Scripts/Core/Player/PlayerMovementController.cs @@ -1,33 +1,36 @@ using Unity.VisualScripting; using UnityEngine; -public class PlayerMovementController{ +public class PlayerMovementController +{ // Attributes private readonly Player player; private Vector3 axisX; private Vector3 axisZ; // Constructor - public PlayerMovementController(Player player){ + public PlayerMovementController(Player player) + { this.player = player; axisX = new(GameController.instance.mainCamera.Orientation.right.x, 0, GameController.instance.mainCamera.Orientation.right.z); axisZ = new(GameController.instance.mainCamera.Orientation.forward.x, 0, GameController.instance.mainCamera.Orientation.forward.z); } // Functions - private void HandleRotation(Vector3 moveDirection){ + private void HandleRotation(Vector3 moveDirection) + { Quaternion target = Quaternion.LookRotation(moveDirection, Vector3.up); - - // Note: this can be smoothened, for better or for worse player.transform.rotation = Quaternion.RotateTowards(player.transform.rotation, target, GameConfig.ROTATION_SMOOTHING * Time.deltaTime); } - private void SnapshotCameraOrientation(){ + private void SnapshotCameraOrientation() + { axisX = new(GameController.instance.mainCamera.Orientation.right.x, 0, GameController.instance.mainCamera.Orientation.right.z); axisZ = new(GameController.instance.mainCamera.Orientation.forward.x, 0, GameController.instance.mainCamera.Orientation.forward.z); } - public void HandleMovement(){ + public void HandleMovement() + { float inputX = player.inputController.movementInputX; float inputZ = player.inputController.movementInputZ; @@ -42,6 +45,9 @@ public class PlayerMovementController{ velocity.z = modifierVector.z; player.Rigidbody.velocity = Vector3.SmoothDamp(player.Rigidbody.velocity, velocity, ref dampVelocity, GameConfig.MOVEMENT_SMOOTHING); - if(movementVector != Vector3.zero) HandleRotation(movementVector); + if(movementVector != Vector3.zero) + { + HandleRotation(movementVector); + } } } diff --git a/Assets/Scripts/Core/Player/PlayerState.cs b/Assets/Scripts/Core/Player/PlayerState.cs index c7fe2ab70397ef91a9dbc7cf67951daed3edf980..ae2cabe725e58e79124948e0f8733d6e0a2cdfcc 100644 --- a/Assets/Scripts/Core/Player/PlayerState.cs +++ b/Assets/Scripts/Core/Player/PlayerState.cs @@ -1 +1,3 @@ -public class PlayerState : EntityState {} +public class PlayerState : DefaultEntityState +{ +} diff --git a/Assets/Scripts/Core/Player/PlayerStateController.cs b/Assets/Scripts/Core/Player/PlayerStateController.cs index 60cec8c2be7d7aa0da5923622e4214b484441ae5..d964474eaa4c3ec7b0dd33f1b265f1a9a3494958 100644 --- a/Assets/Scripts/Core/Player/PlayerStateController.cs +++ b/Assets/Scripts/Core/Player/PlayerStateController.cs @@ -1,37 +1,50 @@ using System.Collections.Generic; using UnityEngine; -public class PlayerStateController : DamageableEntityStateController { +public class PlayerStateController : DamageableEntityStateController +{ // Attributes private readonly Player player; public List<IInteractable> currentInteractables = new(); // Contstructor - public PlayerStateController(Player player) : base(player){ + public PlayerStateController(Player player) : base(player) + { this.player = player; } // Functions - private bool DetectWalking(){ + private bool DetectWalking() + { return Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0; } - private bool DetectSprinting(){ + private bool DetectSprinting() + { return (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0) && Input.GetKey(KeyCode.LeftShift); } - public override int UpdateState(){ + public override int UpdateState() + { int initialState = state; - if(DetectSprinting()){ + if(DetectSprinting()) + { state = PlayerState.SPRINTING; } - else if(DetectWalking()){ + else if(DetectWalking()) + { state = PlayerState.WALKING; - } else{ + } + else + { state = PlayerState.IDLE; } - if(initialState != state) InvokeOnStateChanged(); + if(initialState != state) + { + InvokeOnStateChanged(); + } + return state; } } diff --git a/Assets/Scripts/Core/Player/PlayerStats.cs b/Assets/Scripts/Core/Player/PlayerStats.cs index b2a23fb4796821331e31b998e46a073ab9f35f2f..0209a225254b31379ab4cc7518f87c563c2f23e7 100644 --- a/Assets/Scripts/Core/Player/PlayerStats.cs +++ b/Assets/Scripts/Core/Player/PlayerStats.cs @@ -1,31 +1,37 @@ using UnityEngine; -public class PlayerStats { +public class PlayerStats +{ // Attributes private readonly Player player; public float sprintModifier = 1.5f; // Set-Getters - public float Health { + public float Health + { get => player.Health; set => player.Health = value; } - public float MaxHealth { + public float MaxHealth + { get => player.MaxHealth; set => player.MaxHealth = value; } - public float BaseDamage { + public float BaseDamage + { get => player.BaseDamage; set => player.BaseDamage = value; } - public float MaxSpeed => player.stateController.state switch{ + public float MaxSpeed => player.stateController.state switch + { PlayerState.WALKING => player.BaseSpeed, PlayerState.SPRINTING => player.BaseSpeed * sprintModifier, _ => 0 }; // Constructor - public PlayerStats(Player player){ + public PlayerStats(Player player) + { this.player = player; } } diff --git a/Assets/Scripts/Core/UI/Camera/CameraFollowObject.cs b/Assets/Scripts/Core/UI/Camera/CameraFollowObject.cs index a6b068e5ecc4a49edc48ecc08d0db605b06a8989..ce5dc902d5158ab85b47c8d6a34f3e63453dea82 100644 --- a/Assets/Scripts/Core/UI/Camera/CameraFollowObject.cs +++ b/Assets/Scripts/Core/UI/Camera/CameraFollowObject.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class CameraFollowObject : CameraBehaviour { +public class CameraFollowObject : CameraBehaviour +{ // Attributes public Transform target; public float followingTime = CameraConfig.DEFAULT_FOLLOWING_SPEED; @@ -8,13 +9,19 @@ public class CameraFollowObject : CameraBehaviour { protected Vector3 velocity; // Constructor - protected void Start(){ + protected void Start() + { offset = transform.position - target.position; } // Functions - protected void FixedUpdate(){ - if(GameController.instance.IsPaused) return; + protected void FixedUpdate() + { + if(GameController.instance.IsPaused) + { + return; + } + Vector3 targetPosition = target.position + offset; transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, followingTime); } diff --git a/Assets/Scripts/Core/UI/Camera/CameraMouse.cs b/Assets/Scripts/Core/UI/Camera/CameraMouse.cs index 347e3c2d03a5c1dfd2b6139808d1bbf8aa999d77..39b532a7b6ff6f0752a80a486916c44637708635 100644 --- a/Assets/Scripts/Core/UI/Camera/CameraMouse.cs +++ b/Assets/Scripts/Core/UI/Camera/CameraMouse.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class CameraMouse : CameraFollowObject { +public class CameraMouse : CameraFollowObject +{ // Attributes public float mouseSensitivity = 1f; private Vector2 mouseTurn; @@ -8,14 +9,22 @@ public class CameraMouse : CameraFollowObject { private Vector3 targetPosition; private Quaternion targetRotation; - protected new void Start(){ + // Constructor + protected new void Start() + { base.Start(); Cursor.lockState = CursorLockMode.Locked; initialRotation = transform.rotation; } - protected void Update(){ - if(GameController.instance.IsPaused) return; + // Functions + protected void Update() + { + if(GameController.instance.IsPaused) + { + return; + } + mouseTurn.x += Input.GetAxis("Mouse X"); mouseTurn.y += Input.GetAxis("Mouse Y"); @@ -28,12 +37,16 @@ public class CameraMouse : CameraFollowObject { targetPosition = target.position + rotation * offset; bool hit = Physics.Linecast(target.position, targetPosition, out RaycastHit hitLocation, 1); - if (hit) targetPosition = hitLocation.point; + if (hit) + { + targetPosition = hitLocation.point; + } targetRotation = rotation; } - protected new void FixedUpdate(){ + protected new void FixedUpdate() + { transform.forward = offset.normalized; transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, followingTime); transform.localRotation = targetRotation; diff --git a/Assets/Scripts/Core/UI/Camera/CameraStatic.cs b/Assets/Scripts/Core/UI/Camera/CameraStatic.cs index c88e88fa927b4dcdd3b8bfb56aa3294d165321a9..9d70441d4aefa7ff65b4cec8c39c8b94308d2baf 100644 --- a/Assets/Scripts/Core/UI/Camera/CameraStatic.cs +++ b/Assets/Scripts/Core/UI/Camera/CameraStatic.cs @@ -1,3 +1,5 @@ using UnityEngine; -public class CameraStatic : CameraBehaviour {} +public class CameraStatic : CameraBehaviour +{ +} diff --git a/Assets/Scripts/Library/BaseClasses/AttackHitbox.cs b/Assets/Scripts/Library/BaseClasses/AttackHitbox.cs index a94558608d089fe3e7d595fa3f25096eef3359b9..ec80ad2b1363d8f594734e60057039febe30f223 100644 --- a/Assets/Scripts/Library/BaseClasses/AttackHitbox.cs +++ b/Assets/Scripts/Library/BaseClasses/AttackHitbox.cs @@ -1,9 +1,11 @@ using System; using UnityEngine; -public class AttackHitbox : AttackObject{ +public class AttackHitbox : AttackObject +{ // Functions - protected void OnTriggerStay(Collider otherCollider){ + protected void OnTriggerStay(Collider otherCollider) + { Hit(otherCollider); } } diff --git a/Assets/Scripts/Library/BaseClasses/BaseObjectManager.cs b/Assets/Scripts/Library/BaseClasses/BaseObjectManager.cs index 18fcc3b802ca034e6685a92714e0a7d700b6dadc..2114ae6362d74220e6dfb7f4f52d80c4fe51f67e 100644 --- a/Assets/Scripts/Library/BaseClasses/BaseObjectManager.cs +++ b/Assets/Scripts/Library/BaseClasses/BaseObjectManager.cs @@ -1,36 +1,51 @@ using System.Collections.Generic; using UnityEngine; -public class BaseObjectManager : MonoBehaviour{ +public class BaseObjectManager : MonoBehaviour +{ // Attributes protected string ManagerName = "Manager"; // Functions - public virtual void LogObjects(){ + public virtual void LogObjects() + { WorldObject[] worldObjects = GetComponentsInChildren<WorldObject>(); + string idArray = "["; - for (int i = 0; i < worldObjects.Length; i++){ - idArray += worldObjects[i].Id; - if(i != worldObjects.Length - 1) idArray += ","; + for (int i = 0; i < worldObjects.Length; i++) + { + idArray += worldObjects[i].id; + if(i != worldObjects.Length - 1) + { + idArray += ","; + } } idArray += "]"; Debug.Log(string.Format("Object ids in {0}: {1}", ManagerName, idArray)); } - public virtual WorldObject[] GetWorldObjects(){ + public virtual WorldObject[] GetWorldObjects() + { return GetComponentsInChildren<WorldObject>(); } - public virtual WorldObject GetWorldObject(string id){ + public virtual WorldObject GetWorldObject(string id) + { WorldObject[] worldObjects = GetComponentsInChildren<WorldObject>(); - for (int i = 0; i < worldObjects.Length; i++){ - if(worldObjects[i].Id == id) return worldObjects[i]; + + for (int i = 0; i < worldObjects.Length; i++) + { + if(worldObjects[i].id == id) + { + return worldObjects[i]; + } } return null; } - public virtual void RemoveWorldObject(string id){ + public virtual void RemoveWorldObject(string id) + { WorldObject worldObject = GetWorldObject(id); Destroy(worldObject.gameObject); } diff --git a/Assets/Scripts/Library/BaseClasses/Controller/AnimationController.cs b/Assets/Scripts/Library/BaseClasses/Controller/AnimationController.cs index d9c668ff2097b040e7e63d055034961d63061feb..411af95c4ea42553f273342c422c600c5e3da0c7 100644 --- a/Assets/Scripts/Library/BaseClasses/Controller/AnimationController.cs +++ b/Assets/Scripts/Library/BaseClasses/Controller/AnimationController.cs @@ -1,18 +1,31 @@ using UnityEngine; -public abstract class AnimationController { +public abstract class AnimationController +{ // Attributes public Transform model; public MeshRenderer meshRenderer; public Animator animator; - public AnimationController(MonoBehaviour animable){ + // Constructor + public AnimationController(MonoBehaviour animable) + { model = animable.transform.Find("Model"); animator = model.GetComponent<Animator>(); meshRenderer = model.GetComponent<MeshRenderer>(); - if(model == null) Debug.LogWarning("Animated object of " + animable.name + " does not have a model"); - if(animator == null) Debug.LogWarning("Animated object of " + animable.name + " does not have an animator in its model"); - if(meshRenderer == null) Debug.LogWarning("Animated object of " + animable.name + " does not have an meshRenderer in its model"); + if(model == null) + { + Debug.LogWarning("Animated object of " + animable.name + " does not have a model"); + } + if(animator == null) + { + Debug.LogWarning("Animated object of " + animable.name + " does not have an animator in its model"); + } + if(meshRenderer == null) + { + Debug.LogWarning("Animated object of " + animable.name + " does not have an meshRenderer in its model"); + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Library/BaseClasses/Controller/DamageableEntityStateController.cs b/Assets/Scripts/Library/BaseClasses/Controller/DamageableEntityStateController.cs index 4a5a18d5e6a29458906f080b3da7d6f3be8de7bf..ef1fe50d2fe59b756be3e42d588f22310cd684f3 100644 --- a/Assets/Scripts/Library/BaseClasses/Controller/DamageableEntityStateController.cs +++ b/Assets/Scripts/Library/BaseClasses/Controller/DamageableEntityStateController.cs @@ -2,20 +2,25 @@ using System; using System.Collections; using UnityEngine; -public abstract class DamageableEntityStateController : EntityStateController { +public abstract class DamageableEntityStateController : EntityStateController +{ // Attributes private readonly DamageableEntity Entity; private float damagedDelay; + + // Events public event Action OnDamageDelayOverEvent; // Set-Getters - public float DamagedDelay { + public float DamagedDelay + { get => damagedDelay; set => damagedDelay = value <= 0? GameConfig.DAMAGED_DELAY_DURATION : value; } // Constructor - public DamageableEntityStateController(DamageableEntity entity, float delay = 0){ + public DamageableEntityStateController(DamageableEntity entity, float delay = 0) + { Entity = entity; DamagedDelay = delay; @@ -25,24 +30,29 @@ public abstract class DamageableEntityStateController : EntityStateController { } // Functions - private IEnumerator WaitDamagedDelay(){ - if (!Entity.Dead){ + private IEnumerator WaitDamagedDelay() + { + if (!Entity.Dead) + { yield return new WaitForSeconds(DamagedDelay); Entity.Damageable = true; InvokeDamageDelayOver(); } } - private void InvokeDamageDelayOver(){ + private void InvokeDamageDelayOver() + { OnDamageDelayOverEvent?.Invoke(); } - private void OnDamaged(){ + private void OnDamaged() + { Entity.Damageable = false; Entity.StartCoroutine(WaitDamagedDelay()); } - private void OnDamageDelayOver(){ + private void OnDamageDelayOver() + { Entity.Damageable = true; } } diff --git a/Assets/Scripts/Library/BaseClasses/Controller/EntityStateController.cs b/Assets/Scripts/Library/BaseClasses/Controller/EntityStateController.cs index 6af8f29a7defcc294bd13cfa36addd26357c4c33..f24fa0dad08e48d71472e127ba2e1a7593274803 100644 --- a/Assets/Scripts/Library/BaseClasses/Controller/EntityStateController.cs +++ b/Assets/Scripts/Library/BaseClasses/Controller/EntityStateController.cs @@ -1,14 +1,19 @@ using System; -public abstract class EntityStateController{ +public abstract class EntityStateController +{ // Attributes public int state; + + // Events public event Action OnStateChangeEvent; // Functions - protected void InvokeOnStateChanged(){ + protected void InvokeOnStateChanged() + { OnStateChangeEvent?.Invoke(); } + // Abstract Functions public abstract int UpdateState(); } diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/AttackObject.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/AttackObject.cs index 6ce9b0b2f8ab682cc791facd1dcb238e65e590a3..78046ffe94eadecc6d1575d909098cb05f9d107b 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/AttackObject.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/AttackObject.cs @@ -2,11 +2,14 @@ using System; using UnityEngine; // TODO: Review whether attack object should be classified as a world object -public class AttackObject : MonoBehaviour, IAttack{ +public class AttackObject : MonoBehaviour, IDamaging, IKnockback +{ // Attributes private Vector3 knockbackOffset; [SerializeField] private float damage; [SerializeField] private float knockbackPower; + + // Events public event Action OnDamageEvent; // Set-Getters @@ -25,33 +28,45 @@ public class AttackObject : MonoBehaviour, IAttack{ // Constructor - protected void Start(){ - if(KnockbackOrigin == null) KnockbackOrigin = Vector3.zero; + protected void Start() + { + if(KnockbackOrigin == null) + { + KnockbackOrigin = Vector3.zero; + } } // Functions - public void Knockback(IRigid rigidObject){ + public void Knockback(IRigid rigidObject) + { var knockbackModifier = (-1) * knockbackPower / rigidObject.KnockbackResistance; Vector3 knockbackVector = MathUtils.GetDirectionVectorFlat(KnockbackOrigin, rigidObject.Position) * knockbackModifier; rigidObject.Rigidbody.AddForce(knockbackVector, ForceMode.Impulse); } - protected bool Hit(Collider otherCollider){ - + protected bool Hit(Collider otherCollider) + { // Note: Hitboxes are traditionally placed within a model, therefore we get the damageable component from its parent Transform objectParent = otherCollider.transform.parent; objectParent.TryGetComponent<IDamageable>(out var damageableObject); - if(damageableObject == null) return true; + if(damageableObject == null) + { + return true; + } - if(damageableObject.Damageable){ + if(damageableObject.Damageable) + { Debug.Log(string.Format("Hit in hitbox of {0} by {1} with damage of {2}", transform.name, objectParent.name, Damage)); damageableObject.InflictDamage(Damage); OnDamageEvent?.Invoke(); objectParent.TryGetComponent<IRigid>(out var rigidObject); - if(rigidObject != null) Knockback(rigidObject); + if(rigidObject != null) + { + Knockback(rigidObject); + } return true; } diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/CombatantEntity.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/CombatantEntity.cs index d279af8e045a326979212af0edca5b0eec1a90d4..e497fd035afed95ad4428c740d6187a7eaf73921 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/CombatantEntity.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/CombatantEntity.cs @@ -1,24 +1,40 @@ using System; +using System.Collections.Generic; using UnityEngine; -public class CombatantEntity : DamageableEntity, IArmed{ +public class CombatantEntity : DamageableEntity, IArmed +{ // Attributes [SerializeField] private float baseDamage; - private WeaponObject weapon; + private readonly List<WeaponObject> weaponList = new(); + private int weaponIndex; // Set-Getters - public float BaseDamage { + public List<WeaponObject> WeaponList => weaponList; + public WeaponObject Weapon => weaponList.Count > 0? weaponList[WeaponIndex] : null; + public Transform Orientation => transform; + public float BaseDamage + { get => baseDamage; set => baseDamage = value; } - public WeaponObject Weapon { - get => weapon; - set => weapon = value; + public int WeaponIndex + { + get => weaponIndex; + set + { + // Switch requires a constant, so can't use that here + if(value == weaponList.Count) weaponIndex = 0; + else if(value == -1) weaponIndex = weaponList.Count - 1; + else if(-1 < value && value < weaponList.Count) weaponIndex = value; + else weaponIndex = 0; + } } - public Transform Orientation => transform; + // Functions // TODO: Test then decide whether to destroy/disable previous weapon - public void SwapWeapon(WeaponObject newWeapon){ - Weapon = newWeapon; - } + // public void SwapWeapon(WeaponObject newWeapon) + // { + // ActiveWeapon = newWeapon; + // } } diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/DamageableEntity.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/DamageableEntity.cs index a5aacf5121cd32190bb276cb73ca56a83fee9c9c..f76eb9999dca47c479e252ff45b2b33f519b1dbb 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/DamageableEntity.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/DamageableEntity.cs @@ -1,55 +1,54 @@ using System; using UnityEngine; -public class DamageableEntity : WorldEntity, IDamageable{ +public class DamageableEntity : WorldEntity, IDamageable +{ // Attributes private bool damageable = true; [SerializeField] private float maxHealth; [SerializeField] private float health; + + // Events public event Action OnDeathEvent; public event Action OnDamagedEvent; public event Action OnHealEvent; // Set-Getters - public float MaxHealth { + public bool Dead => health <= 0; + public float MaxHealth + { get => maxHealth; set => maxHealth = value > 0? value : 0; } - public float Health { + public float Health + { get => health; set => health = value > 0? (value > MaxHealth? MaxHealth : value) : 0; } - public bool Damageable { + public bool Damageable + { get => damageable; set => damageable = value; } - public bool Dead => health <= 0; // Functions - public float InflictDamage(float damage){ + public float InflictDamage(float damage) + { Health -= damage; OnDamagedEvent?.Invoke(); - if(Dead) OnDeathEvent?.Invoke(); + if(Dead) + { + OnDeathEvent?.Invoke(); + } return Health; } - public float InflictHeal(float heal){ + public float InflictHeal(float heal) + { Health += heal; OnHealEvent?.Invoke(); return Health; } - - protected new void Start(){ - base.Start(); - } - - protected new void Update(){ - base.Update(); - } - - protected new void FixedUpdate(){ - base.FixedUpdate(); - } } diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/PlayerEntity.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/PlayerEntity.cs index 3d34d7f37d18f353276bef1d32690639e6ceeab7..deb2db64dc408d5dc58650f5b2beb98ba2f98ece 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/PlayerEntity.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/PlayerEntity.cs @@ -1,7 +1,10 @@ using System.Collections.Generic; -public class PlayerEntity : CombatantEntity, IAccompaniable{ +public class PlayerEntity : CombatantEntity, IAccompaniable +{ // Attributes - private readonly List<Companions> companionList = new(); + protected readonly List<Companions> companionList = new(); + + // Set-Getters public List<Companions> Companions => companionList; } diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs index 32010031f9b90d1048ed3457c804ecd66b27d680..c7796b95fbd87773773ea5c52ada8210fea0e7f7 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs @@ -1,6 +1,7 @@ using UnityEngine; -public class WorldEntity : WorldObject, IRigid { +public class WorldEntity : WorldObject, IRigid +{ // Attributes [SerializeField] private float knockbackResistance; [SerializeField] private float baseSpeed; @@ -9,28 +10,36 @@ public class WorldEntity : WorldObject, IRigid { // Set-Getters public Rigidbody Rigidbody => rigidbody; public Vector3 Position => transform.position; - public float KnockbackResistance { + public float KnockbackResistance + { get => knockbackResistance <= 0? 1 : knockbackResistance; set => knockbackResistance = value; } - public float BaseSpeed { + public float BaseSpeed + { get => baseSpeed; set => baseSpeed = value < 0? 0 : value; } // Constructor - protected void Start(){ + protected void Start() + { rigidbody = GetComponent<Rigidbody>(); - if(rigidbody == null) Debug.LogWarning("Rigid entity " + name + " does not have a rigidbody"); + if(rigidbody == null) + { + Debug.LogWarning("Rigid entity " + name + " does not have a rigidbody"); + } } // Functions - protected void Refresh(){ + protected void Refresh() + { Rigidbody.AddForce(Vector2.zero); } - protected void Smoothen(){ + protected void Smoothen() + { Vector3 dampVelocity = Vector3.zero; Vector3 velocity = Rigidbody.velocity; velocity.x = 0; @@ -38,11 +47,19 @@ public class WorldEntity : WorldObject, IRigid { Rigidbody.velocity = Vector3.SmoothDamp(Rigidbody.velocity, velocity, ref dampVelocity, GameConfig.MOVEMENT_SMOOTHING); } - protected void Update(){ - if(GameController.instance.IsPaused) return; + protected void Update() + { + if(GameController.instance.IsPaused) + { + return; + } } - protected void FixedUpdate(){ - if(GameController.instance.IsPaused) return; + protected void FixedUpdate() + { + if(GameController.instance.IsPaused) + { + return; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Library/BaseClasses/EntityObject/WorldObject.cs b/Assets/Scripts/Library/BaseClasses/EntityObject/WorldObject.cs index 222cc81df20319a5e7ba4a5b246916b2be52eee3..9780bd38f85691d83ca6f1050656797ee3937f66 100644 --- a/Assets/Scripts/Library/BaseClasses/EntityObject/WorldObject.cs +++ b/Assets/Scripts/Library/BaseClasses/EntityObject/WorldObject.cs @@ -1,25 +1,36 @@ using UnityEngine; -public class WorldObject : MonoBehaviour{ +public class WorldObject : MonoBehaviour +{ // Attributes private static int autoIncrement = 0; - private int NumberId; - private string Prefix; - public string Id; + private int numberId; + private string prefix; + public string id; + + // Set-Getters public Vector3 Front => transform.rotation * Vector3.forward; public Quaternion Rotation => transform.rotation; // Constructor - protected void Awake(){ - NumberId = autoIncrement; - Id = NumberId.ToString(); + protected void Awake() + { + numberId = autoIncrement; + id = numberId.ToString(); autoIncrement++; } // Functions - protected void SetIdPrefix(string prefix){ - Prefix = prefix; - if(Prefix == "") Id = NumberId.ToString(); - else Id = Prefix + "_" + Id; + protected void SetIdPrefix(string prefix) + { + this.prefix = prefix; + if(this.prefix == "") + { + id = numberId.ToString(); + } + else + { + id = this.prefix + "_" + id; + } } } diff --git a/Assets/Scripts/Library/CameraBehaviour/CameraBehaviour.cs b/Assets/Scripts/Library/CameraBehaviour/CameraBehaviour.cs index be1ead9e89e836d1ab6b277b251a427e2bbe40f9..af26786e7ae0a6099a108c6f91fa44442b90c897 100644 --- a/Assets/Scripts/Library/CameraBehaviour/CameraBehaviour.cs +++ b/Assets/Scripts/Library/CameraBehaviour/CameraBehaviour.cs @@ -1,3 +1,5 @@ using UnityEngine; -public abstract class CameraBehaviour : MonoBehaviour {} +public abstract class CameraBehaviour : MonoBehaviour +{ +} diff --git a/Assets/Scripts/Library/DataTypes/DifficultyData.cs b/Assets/Scripts/Library/DataTypes/DifficultyData.cs index a08615d65ef1bfa7bdf8e511a29a8e1baf2a0103..3b0a3f52d7c600bc334987960dc1e67d39609dbf 100644 --- a/Assets/Scripts/Library/DataTypes/DifficultyData.cs +++ b/Assets/Scripts/Library/DataTypes/DifficultyData.cs @@ -1,4 +1,5 @@ -public class DifficultyData{ +public class DifficultyData +{ public float EnemyHealthMultiplier { get; set; } public float EnemyDamageMultiplier { get; set; } public float PlayerHealthMultiplier { get; set; } diff --git a/Assets/Scripts/Library/Enum/AttackObjectType.cs b/Assets/Scripts/Library/Enum/AttackObjectType.cs index 070c57a8522c0b64b6271d342af779926adba0e9..103641dae7b7ee2947bafce28de6fc0982897775 100644 --- a/Assets/Scripts/Library/Enum/AttackObjectType.cs +++ b/Assets/Scripts/Library/Enum/AttackObjectType.cs @@ -1,4 +1,5 @@ -public enum AttackObjectType { +public enum AttackObjectType +{ PLAYER, ENEMY, ENVIRONMENT diff --git a/Assets/Scripts/Library/Enum/CameraBehaviourType.cs b/Assets/Scripts/Library/Enum/CameraBehaviourType.cs index 708d015eb5afad73aca4ae1ef536dd4a1f6638cb..9520ce60f04a0c25005480672fe78002a8652169 100644 --- a/Assets/Scripts/Library/Enum/CameraBehaviourType.cs +++ b/Assets/Scripts/Library/Enum/CameraBehaviourType.cs @@ -1,4 +1,5 @@ -public enum CameraBehaviourType{ +public enum CameraBehaviourType +{ NULL, STATIC, FOLLOW, diff --git a/Assets/Scripts/Library/Enum/DifficultyType.cs b/Assets/Scripts/Library/Enum/DifficultyType.cs index fe61e48f5e68c1e29582008554f09f72841e5c73..ccdda1503d704b5b1fc4eaec8dac2cd0b5e2648e 100644 --- a/Assets/Scripts/Library/Enum/DifficultyType.cs +++ b/Assets/Scripts/Library/Enum/DifficultyType.cs @@ -1,4 +1,5 @@ -public enum DifficultyType{ +public enum DifficultyType +{ EASY, NORMAL, HARD diff --git a/Assets/Scripts/Library/Enum/GameEventType.cs b/Assets/Scripts/Library/Enum/GameEventType.cs index 3c20968a882131224d2c076737a2ee15838246b4..705d2394aa84ddbce4a489b65a26c48527e2c184 100644 --- a/Assets/Scripts/Library/Enum/GameEventType.cs +++ b/Assets/Scripts/Library/Enum/GameEventType.cs @@ -1,3 +1,3 @@ -public enum GameEventType{ - CHEAT +public enum GameEventType +{ } diff --git a/Assets/Scripts/Library/Enum/GameState.cs b/Assets/Scripts/Library/Enum/GameState.cs index c4de8375045c1139a65d923f50a4d2c5bb1c8b70..8a37a088cd5493bf981504cd069ec2c32f67c289 100644 --- a/Assets/Scripts/Library/Enum/GameState.cs +++ b/Assets/Scripts/Library/Enum/GameState.cs @@ -1,4 +1,5 @@ -public enum GameState { +public enum GameState +{ NULL, RUNNING, MENU, diff --git a/Assets/Scripts/Library/Enum/Inheritable.meta b/Assets/Scripts/Library/Enum/Inheritable.meta new file mode 100644 index 0000000000000000000000000000000000000000..dd65d5b12a13d33849d16c6970e11ada54ec48f2 --- /dev/null +++ b/Assets/Scripts/Library/Enum/Inheritable.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d79e30ca3dee2349891f36a3c3dbeca +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Library/Enum/EntityState.cs b/Assets/Scripts/Library/Enum/Inheritable/DefaultEntityState.cs similarity index 82% rename from Assets/Scripts/Library/Enum/EntityState.cs rename to Assets/Scripts/Library/Enum/Inheritable/DefaultEntityState.cs index a319ccb93b5b04be257306ccaba18aa6226950ba..5babf367963f75d9f6add5775bc38cdbf95de94e 100644 --- a/Assets/Scripts/Library/Enum/EntityState.cs +++ b/Assets/Scripts/Library/Enum/Inheritable/DefaultEntityState.cs @@ -1,4 +1,5 @@ -public class EntityState { +public class DefaultEntityState +{ public const int NULL = 0; public const int IDLE = 1; public const int WALKING = 2; diff --git a/Assets/Scripts/Library/Enum/EntityState.cs.meta b/Assets/Scripts/Library/Enum/Inheritable/DefaultEntityState.cs.meta similarity index 100% rename from Assets/Scripts/Library/Enum/EntityState.cs.meta rename to Assets/Scripts/Library/Enum/Inheritable/DefaultEntityState.cs.meta diff --git a/Assets/Scripts/Library/Enum/StackChangeEventType.cs b/Assets/Scripts/Library/Enum/StackChangeEventType.cs index 97aa2a78650342af6464f82137c1f8ef312c48a8..df0213537e83dd7ac99d9da6e91bc7d3110fdb98 100644 --- a/Assets/Scripts/Library/Enum/StackChangeEventType.cs +++ b/Assets/Scripts/Library/Enum/StackChangeEventType.cs @@ -1,4 +1,5 @@ -public enum StackChangeEventType{ +public enum StackChangeEventType +{ PUSH, POP } diff --git a/Assets/Scripts/Library/Events/GameEvent.cs b/Assets/Scripts/Library/Events/GameEvent.cs index 18321f6cf04ded4ce82e77e2bcc7d86b40d01d9b..ff20a5d248a9cab40aa6ecc700b4d7d14680a460 100644 --- a/Assets/Scripts/Library/Events/GameEvent.cs +++ b/Assets/Scripts/Library/Events/GameEvent.cs @@ -1,8 +1,13 @@ using System; -public class GameEventArgs : EventArgs{ +public class GameEventArgs : EventArgs +{ + // Arguments public GameEventType EventType { get; } - public GameEventArgs(GameEventType eventType){ + + // Constructor + public GameEventArgs(GameEventType eventType) + { EventType = eventType; } } diff --git a/Assets/Scripts/Library/Events/GameStateChangeEvent.cs b/Assets/Scripts/Library/Events/GameStateChangeEvent.cs index a485da400892fe153f96e32e319c0452608b6d06..00933ce37afba463e1094cd58e4d3d2dae544d29 100644 --- a/Assets/Scripts/Library/Events/GameStateChangeEvent.cs +++ b/Assets/Scripts/Library/Events/GameStateChangeEvent.cs @@ -1,6 +1,12 @@ -public class GameStateChangeArgs : StackChangeEventArgs<GameState>{ +public class GameStateChangeArgs : StackChangeEventArgs<GameState> +{ + // Arguments public GameState NewGameState => Value; - public GameStateChangeArgs(StackChangeEventType eventType, int index, GameState NewGameState) : base(eventType, index, NewGameState){} + + // Constructor + public GameStateChangeArgs(StackChangeEventType eventType, int index, GameState NewGameState) : base(eventType, index, NewGameState) + { + } } public delegate void GameStateChangeEvent(GameStateChangeArgs e); diff --git a/Assets/Scripts/Library/Events/InteractAreaExitEvent.cs b/Assets/Scripts/Library/Events/InteractAreaExitEvent.cs new file mode 100644 index 0000000000000000000000000000000000000000..901ac0a3f9f51928a469d64ad616dea555ebb0dc --- /dev/null +++ b/Assets/Scripts/Library/Events/InteractAreaExitEvent.cs @@ -0,0 +1,6 @@ +using System; + +public class InteractAreaExitArgs : EventArgs +{ +} +public delegate void InteractAreaExitEvent(InteractAreaExitArgs e); \ No newline at end of file diff --git a/Assets/Scripts/Library/Interfaces/IAttack.cs.meta b/Assets/Scripts/Library/Events/InteractAreaExitEvent.cs.meta similarity index 83% rename from Assets/Scripts/Library/Interfaces/IAttack.cs.meta rename to Assets/Scripts/Library/Events/InteractAreaExitEvent.cs.meta index 032c39d8a64a984a1cdaf08e9c31004ab47982ed..1fa2f6a77b0e3795e38a3d31f31077efa1e8ccf2 100644 --- a/Assets/Scripts/Library/Interfaces/IAttack.cs.meta +++ b/Assets/Scripts/Library/Events/InteractAreaExitEvent.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6b2ca8f784afa944a8843724ccc1ea6b +guid: c8cd2d5f19abe754e98f4b45e9635c6c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Library/Events/StackChangeEvent.cs b/Assets/Scripts/Library/Events/StackChangeEvent.cs index e0a968d6e3fa9ea6ff3b7a762d394fa5f6e32685..8295f13c5e195238ffc0725fc01779302760ed52 100644 --- a/Assets/Scripts/Library/Events/StackChangeEvent.cs +++ b/Assets/Scripts/Library/Events/StackChangeEvent.cs @@ -1,11 +1,15 @@ using System; -public class StackChangeEventArgs<T> : EventArgs{ +public class StackChangeEventArgs<T> : EventArgs +{ + // Arguments public StackChangeEventType EventType { get; } public int Index { get; } public T Value { get; } - public StackChangeEventArgs(StackChangeEventType eventType, int index, T value){ + // Constructor + public StackChangeEventArgs(StackChangeEventType eventType, int index, T value) + { EventType = eventType; Index = index; Value = value; diff --git a/Assets/Scripts/Library/Interfaces/IAccompanied.cs b/Assets/Scripts/Library/Interfaces/IAccompanied.cs index 826e646834e0fcf67cdf32949b41ab668b1a5e70..58fa3698db4db9a20604e6d233e7ad0cec4403e6 100644 --- a/Assets/Scripts/Library/Interfaces/IAccompanied.cs +++ b/Assets/Scripts/Library/Interfaces/IAccompanied.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; -public interface IAccompaniable{ +public interface IAccompaniable +{ + // Set-Getters public List<Companions> Companions { get; } } diff --git a/Assets/Scripts/Library/Interfaces/IAnimated.cs b/Assets/Scripts/Library/Interfaces/IAnimated.cs index 57a11d7b9fcad48f3ef8d9e63154825e41d41231..c3a19b1de32a5d76258b02bcfca3b2e508a49c4b 100644 --- a/Assets/Scripts/Library/Interfaces/IAnimated.cs +++ b/Assets/Scripts/Library/Interfaces/IAnimated.cs @@ -1,6 +1,8 @@ using UnityEngine; -public interface IAnimated{ +public interface IAnimated +{ + // Set-Getters Transform Model {get;} MeshRenderer MeshRenderer {get;} Animator Animator {get;} diff --git a/Assets/Scripts/Library/Interfaces/IArmed.cs b/Assets/Scripts/Library/Interfaces/IArmed.cs index c75a4e51e7a658a84666bd4871813753c4adca43..1a3b44ae987722bf1ef2a354d02a465660af173c 100644 --- a/Assets/Scripts/Library/Interfaces/IArmed.cs +++ b/Assets/Scripts/Library/Interfaces/IArmed.cs @@ -1,7 +1,9 @@ +using System.Collections.Generic; using UnityEngine; -public interface IArmed{ +public interface IArmed +{ public float BaseDamage { get; set; } - public WeaponObject Weapon { get; set; } + public WeaponObject Weapon { get; } public Transform Orientation { get; } } diff --git a/Assets/Scripts/Library/Interfaces/IAttack.cs b/Assets/Scripts/Library/Interfaces/IAttack.cs deleted file mode 100644 index 3076aabbf95bfe87a8c71e6d2584c41acc3ac4ad..0000000000000000000000000000000000000000 --- a/Assets/Scripts/Library/Interfaces/IAttack.cs +++ /dev/null @@ -1 +0,0 @@ -public interface IAttack : IDamaging, IKnockback{} \ No newline at end of file diff --git a/Assets/Scripts/Library/Interfaces/ICutscene.cs b/Assets/Scripts/Library/Interfaces/ICutscene.cs index d6ee87039dd44e006eed4c5f40b3f1a30440d74c..071d596083b9c2887482bb296d02e7a8aaecbbc0 100644 --- a/Assets/Scripts/Library/Interfaces/ICutscene.cs +++ b/Assets/Scripts/Library/Interfaces/ICutscene.cs @@ -1,3 +1,5 @@ -public interface ICutscene{ +public interface ICutscene +{ + // Functions public void Skip(); } diff --git a/Assets/Scripts/Library/Interfaces/IDamageable.cs b/Assets/Scripts/Library/Interfaces/IDamageable.cs index 9a1c05fb5498edfc203b9a2f961a23120bef8b72..60bdbff7ad2468e3ad9330fed748bd8cfd5e3dc9 100644 --- a/Assets/Scripts/Library/Interfaces/IDamageable.cs +++ b/Assets/Scripts/Library/Interfaces/IDamageable.cs @@ -1,15 +1,19 @@ using System; -public interface IDamageable{ +public interface IDamageable +{ + // Set-Getters float MaxHealth {get; set;} float Health {get; set;} bool Damageable {get; set; } bool Dead {get;} + // Events event Action OnDeathEvent; event Action OnDamagedEvent; event Action OnHealEvent; + // Functions float InflictDamage(float damage); float InflictHeal(float heal); } diff --git a/Assets/Scripts/Library/Interfaces/IDamaging.cs b/Assets/Scripts/Library/Interfaces/IDamaging.cs index 5b11e94d07b9b383d077d6f15f831bad21134d26..62ada3348a59b59383540589ac4973525ca91fd0 100644 --- a/Assets/Scripts/Library/Interfaces/IDamaging.cs +++ b/Assets/Scripts/Library/Interfaces/IDamaging.cs @@ -1,6 +1,10 @@ using System; -public interface IDamaging{ +public interface IDamaging +{ + // Set-Getters float Damage{get; set;} + + // Events event Action OnDamageEvent; } diff --git a/Assets/Scripts/Library/Interfaces/IInteractable.cs b/Assets/Scripts/Library/Interfaces/IInteractable.cs index 60759163a6541e313e1936d517530912034370df..6ca1e1ad86e37c8aa5a780194f4e20eabaf8cd16 100644 --- a/Assets/Scripts/Library/Interfaces/IInteractable.cs +++ b/Assets/Scripts/Library/Interfaces/IInteractable.cs @@ -1,9 +1,13 @@ using System; -public interface IInteractable{ - public void Interact(); +public interface IInteractable +{ + // Events public event Action OnInteractAreaExitEvent; public event Action OnInteractAreaEnterEvent; + + // Functions public void InvokeOnInteractAreaExitEvent(); public void InvokeOnInteractAreaEnterEvent(); + public void Interact(); } \ No newline at end of file diff --git a/Assets/Scripts/Library/Interfaces/IKnockback.cs b/Assets/Scripts/Library/Interfaces/IKnockback.cs index ef009a40a0d95ff6c339dcfe8d7ae0fcd7248dc8..e6fbaa7aac62a3b03dac021e96777ff2c5345425 100644 --- a/Assets/Scripts/Library/Interfaces/IKnockback.cs +++ b/Assets/Scripts/Library/Interfaces/IKnockback.cs @@ -1,8 +1,12 @@ using System; using UnityEngine; -public interface IKnockback{ +public interface IKnockback +{ + // Set-Getters public Vector3 KnockbackOrigin{get; set;} public float KnockbackPower{get; set;} + + // Functions public void Knockback(IRigid rigidObject); } diff --git a/Assets/Scripts/Library/Interfaces/IMenu.cs b/Assets/Scripts/Library/Interfaces/IMenu.cs index a03457e55d4b6289739b229adb089fcc0b751458..426ce81425d1ecf69b2e1d838081008ebbfd8969 100644 --- a/Assets/Scripts/Library/Interfaces/IMenu.cs +++ b/Assets/Scripts/Library/Interfaces/IMenu.cs @@ -1,3 +1,5 @@ -public interface IMenu{ +public interface IMenu +{ + // Functions public void Close(); } diff --git a/Assets/Scripts/Library/Interfaces/IRigid.cs b/Assets/Scripts/Library/Interfaces/IRigid.cs index 2fd374b09d5600d0777be3d7ca6e2632721f5077..8cea356917c2f88bfb3ce7ee17360e3626552284 100644 --- a/Assets/Scripts/Library/Interfaces/IRigid.cs +++ b/Assets/Scripts/Library/Interfaces/IRigid.cs @@ -2,7 +2,9 @@ using UnityEngine; -public interface IRigid{ +public interface IRigid +{ + // Set-Getters public Rigidbody Rigidbody {get;} public Vector3 Position {get;} public float BaseSpeed {get; set;} diff --git a/Assets/Scripts/Library/Util/MathUtil.cs b/Assets/Scripts/Library/Util/MathUtil.cs index 7188bcf23b740d57dc42d60401e40cca2f111a7e..80348b7d5524d4bd76f8e549fe0bc804746d4287 100644 --- a/Assets/Scripts/Library/Util/MathUtil.cs +++ b/Assets/Scripts/Library/Util/MathUtil.cs @@ -1,13 +1,17 @@ using UnityEngine; -public static class MathUtils{ - public static Vector3 GetDirectionVectorFlat(Vector3 origin, Vector3 target){ +// Util contains static functions +public static class MathUtils +{ + public static Vector3 GetDirectionVectorFlat(Vector3 origin, Vector3 target) + { Vector3 direction = new(origin.x - target.x, 0, origin.z - target.z); return direction.normalized; } // TODO: Tweak, add an interesting equation, maybe? - public static float CalculateDamage(float characterDamageStat, float weaponDamageStat){ + public static float CalculateDamage(float characterDamageStat, float weaponDamageStat) + { return characterDamageStat + weaponDamageStat; } } diff --git a/Assets/Scripts/Library/Util/ObjectFactory.cs b/Assets/Scripts/Library/Util/ObjectFactory.cs index 917786c986ada01705e1fa5e169e4f05adf544a0..8cb2285ce8fe1eb435e58df98919c61bfa3f6914 100644 --- a/Assets/Scripts/Library/Util/ObjectFactory.cs +++ b/Assets/Scripts/Library/Util/ObjectFactory.cs @@ -2,28 +2,10 @@ using System.Collections; using UnityEditor.Experimental.GraphView; using UnityEngine; -public static class ObjectFactory{ - // Internal functions - private static GameObject CreateObject( - GameObject gameObject, - Transform parent = null, - Vector3? position = null, - Vector3? scale = null, - Quaternion? rotation = null, - int renderingOrder = 0, - string objectName = "Unnamed Object" - ){ - GameObject returnObject = parent == null? GameObject.Instantiate(gameObject, ObjectManager.instance.transform) : GameObject.Instantiate(gameObject, parent); - if(position != null) returnObject.transform.position = position.Value; - if(rotation != null) returnObject.transform.rotation *= rotation.Value; - if(scale != null) returnObject.transform.localScale = Vector3.Scale(returnObject.transform.localScale, scale.Value); - if(returnObject.TryGetComponent<Renderer>(out var renderer)) renderer.sortingOrder = renderingOrder; - returnObject.name = objectName; - - return returnObject; - } - - // External functions +// Util contains static functions +public static class ObjectFactory +{ + // Functions public static GameObject CreateObject( string prefabPath, Transform parent = null, @@ -32,9 +14,15 @@ public static class ObjectFactory{ Quaternion? rotation = null, int renderingOrder = 0, string objectName = "Unnamed Object" - ){ + ) + { GameObject prefabObject = Resources.Load<GameObject>(prefabPath); - if(prefabObject == null) Debug.LogError("Prefab not found: " + prefabPath); + + if(prefabObject == null) + { + Debug.LogError("Prefab not found: " + prefabPath); + } + return CreateObject(prefabObject, parent, position, scale, rotation, renderingOrder, objectName); } @@ -46,9 +34,23 @@ public static class ObjectFactory{ Quaternion? rotation = null, int renderingOrder = 0, string objectName = "Unnamed Object" - ) where T : MonoBehaviour { - GameObject prefabObject = CreateObject(prefabPath, parent == null? ObjectManager.instance.transform : parent, position, scale, rotation, renderingOrder, objectName); - if(!prefabObject.TryGetComponent<T>(out var UnityObject)) Debug.LogError("Loaded prefab is not a a valid type: " + prefabPath); + ) where T : MonoBehaviour + { + GameObject prefabObject = CreateObject( + prefabPath, + parent == null? ObjectManager.instance.transform : parent, + position, + scale, + rotation, + renderingOrder, + objectName + ); + + if(!prefabObject.TryGetComponent<T>(out var UnityObject)) + { + Debug.LogError("Loaded prefab is not a a valid type: " + prefabPath); + } + return UnityObject; } @@ -64,14 +66,24 @@ public static class ObjectFactory{ Quaternion? rotation = null, int renderingOrder = 0, string objectName = "Unnamed Object" - ){ - AttackObject attackObject = CreateObject<AttackObject>(prefabPath, parent == null? ObjectManager.instance.transform : parent, position, scale, rotation, renderingOrder, objectName); + ) + { + AttackObject attackObject = CreateObject<AttackObject>( + prefabPath, + parent == null? ObjectManager.instance.transform : parent, + position, + scale, + rotation, + renderingOrder, + objectName + ); attackObject.Damage = damage; attackObject.KnockbackPower = knockbackPower; attackObject.KnockbackOrigin = knockbackOrigin; - switch (type){ + switch (type) + { case AttackObjectType.PLAYER: attackObject.gameObject.layer = LayerMask.NameToLayer(GameEnvironmentConfig.LAYER_PLAYER_ATTACK); attackObject.Damage *= GameConfig.DIFFICULTY_MODIFIERS[GameSaveData.instance.difficulty].PlayerDamageMultiplier; @@ -103,9 +115,27 @@ public static class ObjectFactory{ Quaternion? rotation = null, int renderingOrder = 0, string objectName = "Unnamed Object" - ) where T : AttackObject { - AttackObject attackObject = CreateAttackObject(prefabPath, damage, knockbackPower, knockbackOrigin, type, parent, position, scale, rotation, renderingOrder, objectName); - if(!attackObject.TryGetComponent<T>(out var UnityObject)) Debug.LogError("Loaded prefab is not a a valid type: " + prefabPath); + ) where T : AttackObject + { + AttackObject attackObject = CreateAttackObject( + prefabPath, + damage, + knockbackPower, + knockbackOrigin, + type, + parent, + position, + scale, + rotation, + renderingOrder, + objectName + ); + + if(!attackObject.TryGetComponent<T>(out var UnityObject)) + { + Debug.LogError("Loaded prefab is not a a valid type: " + prefabPath); + } + return UnityObject; } @@ -118,8 +148,18 @@ public static class ObjectFactory{ int renderingOrder = 0, string objectName = "Unnamed Object" ){ - Collectible collectible = CreateObject<Collectible>(prefabPath, ObjectManager.instance.transform, position, scale, rotation, renderingOrder, objectName); + Collectible collectible = CreateObject<Collectible>( + prefabPath, + ObjectManager.instance.transform, + position, + scale, + rotation, + renderingOrder, + objectName + ); + collectible.gameObject.layer = LayerMask.NameToLayer(GameEnvironmentConfig.LAYER_COLLECTIBLE); + return collectible; } @@ -131,16 +171,63 @@ public static class ObjectFactory{ int renderingOrder = 0, string objectName = "Unnamed Object" ){ - WorldEntity prefabObject = CreateObject<WorldEntity>(prefabPath, EntityManager.instance.transform, position, scale, rotation, renderingOrder, objectName); + WorldEntity prefabObject = CreateObject<WorldEntity>( + prefabPath, + EntityManager.instance.transform, + position, + scale, + rotation, + renderingOrder, + objectName + ); + return prefabObject; } - public static void DestroyObject(MonoBehaviour gameObject, float delay = 0){ + public static void DestroyObject(MonoBehaviour gameObject, float delay = 0) + { if(gameObject == null) return; GameController.instance.StartCoroutine(DestroyWithDelay(gameObject.gameObject, delay)); } - private static IEnumerator DestroyWithDelay(GameObject gameObject, float delay){ + // Internal functions + private static GameObject CreateObject( + GameObject gameObject, + Transform parent = null, + Vector3? position = null, + Vector3? scale = null, + Quaternion? rotation = null, + int renderingOrder = 0, + string objectName = "Unnamed Object" + ) + { + GameObject createdObject = parent == null? + GameObject.Instantiate(gameObject, ObjectManager.instance.transform) : + GameObject.Instantiate(gameObject, parent); + + if(position != null) + { + createdObject.transform.position = position.Value; + } + if(rotation != null) + { + createdObject.transform.rotation *= rotation.Value; + } + if(scale != null) + { + createdObject.transform.localScale = Vector3.Scale(createdObject.transform.localScale, scale.Value); + } + if(createdObject.TryGetComponent<Renderer>(out var renderer)) + { + renderer.sortingOrder = renderingOrder; + } + createdObject.name = objectName; + + return createdObject; + } + + private static IEnumerator DestroyWithDelay(GameObject gameObject, float delay) + { yield return new WaitForSeconds(delay); GameObject.Destroy(gameObject); }