Attack and Health Updated

대쉬 공격과 엔티티 체력 및 사망 스크립트 작성 + 특수 타일 기초 기능
This commit is contained in:
백민승_crow 2026-01-22 21:57:04 +09:00
parent e19fd24f3f
commit 5edef59289
12 changed files with 564 additions and 311 deletions

View File

@ -104,8 +104,8 @@ GameObject:
- component: {fileID: 1665208702870125763}
- component: {fileID: 2556996269222904179}
- component: {fileID: 6376878406717916855}
- component: {fileID: 3588997328764402973}
- component: {fileID: 3365221526544536121}
- component: {fileID: 4035999004062947863}
- component: {fileID: 1888074432508430436}
m_Layer: 0
m_Name: Player
m_TagString: Player
@ -264,7 +264,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInput
m_Actions: {fileID: 0}
m_Actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
m_NotificationBehavior: 0
m_UIInputModule: {fileID: 0}
m_DeviceLostEvent:
@ -282,7 +282,7 @@ MonoBehaviour:
m_DefaultActionMap: Player
m_SplitScreenIndex: -1
m_Camera: {fileID: 0}
--- !u!114 &3588997328764402973
--- !u!114 &4035999004062947863
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -298,7 +298,13 @@ MonoBehaviour:
jumpSpeed: 18.2
jumpCutMultiplier: 0.3
minJumpDuration: 0.1
--- !u!114 &3365221526544536121
dashTime: 0.1
dashDistance: 5
enemyLayer:
serializedVersion: 2
m_Bits: 64
attackBoxSize: {x: 3, y: 1}
--- !u!114 &1888074432508430436
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -307,13 +313,13 @@ MonoBehaviour:
m_GameObject: {fileID: 9138407101546400895}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b80ed589ee3f55249848caed7062f270, type: 3}
m_Script: {fileID: 11500000, guid: 3eada057783728046bc1f3df10f17294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerAttack
normalAttackBoxSize: {x: 2, y: 1}
dashAttackBoxSize: {x: 2, y: 1}
dashAttackDistance: 5
attackOffset: 1
enemyLayer:
serializedVersion: 2
m_Bits: 64
m_EditorClassIdentifier: Assembly-CSharp::Entity
OnDeath:
m_PersistentCalls:
m_Calls: []
OnTakeDamage:
m_PersistentCalls:
m_Calls: []
data: {fileID: 0}

View File

@ -0,0 +1,160 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3345230653483034275
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3182903703610233758}
- component: {fileID: 3818235801779510969}
- component: {fileID: 3096000554608240826}
- component: {fileID: 4449206212094151330}
m_Layer: 6
m_Name: TestEntity
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3182903703610233758
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3345230653483034275}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.43, y: -0.11, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3818235801779510969
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3345230653483034275}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_Sprite: {fileID: 7482667652216324306, guid: 75f5f34dc1b5347e0b8351032682f224, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0
--- !u!61 &3096000554608240826
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3345230653483034275}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: 0.21133333}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.28866667}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &4449206212094151330
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3345230653483034275}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3eada057783728046bc1f3df10f17294, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Entity
OnDeath:
m_PersistentCalls:
m_Calls: []
OnTakeDamage:
m_PersistentCalls:
m_Calls: []
data: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2}

View File

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

View File

@ -119,6 +119,67 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &91367892
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1888074432508430436, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: data
value:
objectReference: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalPosition.x
value: -3.57
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
--- !u!1 &435424068
GameObject:
m_ObjectHideFlags: 0
@ -989,145 +1050,7 @@ TilemapCollider2D:
m_MaximumTileChangeCount: 1000
m_ExtrusionFactor: 0
m_UseDelaunayMesh: 0
--- !u!1 &1290102946
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1290102948}
- component: {fileID: 1290102947}
- component: {fileID: 1290102949}
m_Layer: 6
m_Name: Triangle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1290102947
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1290102946}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_Sprite: {fileID: 7482667652216324306, guid: 75f5f34dc1b5347e0b8351032682f224, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0
--- !u!4 &1290102948
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1290102946}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.43, y: -0.11, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &1290102949
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1290102946}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: 0.21133333}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.28866667}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!1001 &9062861311486568808
--- !u!1001 &1676748450
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
@ -1135,65 +1058,177 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.x
value: -3.1
value: 3.2039704
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: 2.3513205
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6376878406717916855, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_Actions
value:
objectReference: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
- target: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
- target: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_Name
value: Player
value: TestEntity (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
--- !u!1001 &1846315572
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.x
value: -1.5739294
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.y
value: 4.0376387
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_Name
value: TestEntity (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
--- !u!1001 &960162597646736108
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.x
value: -0.43
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.y
value: -0.11
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_Name
value: TestEntity
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 519420032}
- {fileID: 619394802}
- {fileID: 9062861311486568808}
- {fileID: 91367892}
- {fileID: 435424070}
- {fileID: 1290102948}
- {fileID: 960162597646736108}
- {fileID: 1846315572}
- {fileID: 1676748450}

View File

@ -20,7 +20,7 @@ public class Entity : MonoBehaviour
attackDamage = data.attackDamage;
}
public virtual void TakeDamge(float damage)
public virtual void TakeDamage(float damage)
{
currentHealth -= damage;
OnTakeDamage?.Invoke(damage);

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 39b051782604253409a851b6a1243199, type: 3}
m_Name: Player
m_EditorClassIdentifier: Assembly-CSharp::EntityData
entityName: Player
maxHealth: 10
attackDamage: 5

View File

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

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 39b051782604253409a851b6a1243199, type: 3}
m_Name: TestEntity
m_EditorClassIdentifier: Assembly-CSharp::EntityData
entityName: Test
maxHealth: 3
attackDamage: 0

View File

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

View File

@ -1,112 +0,0 @@
using System.Collections;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerAttack : MonoBehaviour
{
[SerializeField] private Vector2 normalAttackBoxSize = new Vector2(2, 1);
[SerializeField] private Vector2 dashAttackBoxSize = new Vector2(2, 1);
[SerializeField] private float dashAttackDistance = 5f;
[SerializeField] private float attackOffset = 1.0f;
[SerializeField] private LayerMask enemyLayer;
[SerializeField] private float dashSpeed = 15f;
private float normalAttackAngle = 0f;
private Vector2 dashAttackDirection = Vector2.zero;
private Vector2 attackOrigin;
public bool isDashing { get; private set; } = false;
private Camera cam;
private Rigidbody2D rb;
private void Start()
{
cam = Camera.main;
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
if(!isDashing)
SetAttackAngle();
}
private void OnAttack(InputValue value)
{
if (!value.isPressed || isDashing) return;
if (Mouse.current.leftButton.isPressed)
{
Debug.Log("일반공격");
NormalAttack();
}
if (Mouse.current.rightButton.isPressed)
{
Debug.Log("대쉬공격");
StartCoroutine(DashAttackRoutine());
}
}
private void SetAttackAngle()
{
Vector2 mousePositionVector = cam.ScreenToWorldPoint(Mouse.current.position.value);
Vector2 direction = (mousePositionVector - (Vector2)transform.position).normalized;
normalAttackAngle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
dashAttackDirection = direction;
attackOrigin = (Vector2)transform.position + (direction * attackOffset);
}
private void NormalAttack()
{
Collider2D[] enemies = Physics2D.OverlapBoxAll(attackOrigin, normalAttackBoxSize, normalAttackAngle, enemyLayer);
foreach (Collider2D target in enemies)
{
Debug.Log("일반공격 적중: " + target.name);
}
}
private IEnumerator DashAttackRoutine()
{
isDashing = true;
rb.linearVelocity = Vector2.zero;
float dashDuration = dashAttackDistance / dashSpeed;
float elapsedTime = 0f;
rb.linearVelocity = dashAttackDirection * dashSpeed;
Debug.Log(dashAttackDirection);
float originGravity = rb.gravityScale;
rb.gravityScale = 0;
while (elapsedTime < dashDuration)
{
Vector2 currentOrigin = (Vector2)transform.position + (dashAttackDirection * attackOffset);
RaycastHit2D[] enemies = Physics2D.BoxCastAll(currentOrigin, dashAttackBoxSize, normalAttackAngle, dashAttackDirection, 0f, enemyLayer);
foreach (RaycastHit2D target in enemies)
{
Debug.Log("대쉬 공격 적중: " + target.collider.name);
Destroy(target.collider.gameObject);
}
elapsedTime += Time.deltaTime;
yield return null;
}
rb.linearVelocity = Vector2.zero;
isDashing = false;
rb.gravityScale = originGravity;
}
private void OnDrawGizmos()
{
Vector2 drawStartPos = Application.isPlaying ? attackOrigin : (Vector2)transform.position + (Vector2.right * attackOffset);
Gizmos.color = new Color(1, 0, 0, 0.5f);
Gizmos.matrix = Matrix4x4.TRS(drawStartPos, Quaternion.Euler(0, 0, normalAttackAngle), Vector3.one);
Gizmos.DrawCube(Vector3.zero, normalAttackBoxSize);
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: b80ed589ee3f55249848caed7062f270

View File

@ -1,43 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private Rigidbody2D _rigidbody;
private PlayerAttack _playerAttack;
private Vector2 inputVector;
private Camera _camera;
private int maxJumpCount = 2;
private int currentJumpCount = 2;
private bool isGrounded;
private bool isDashing;
private Vector2 inputVector;
private float jumpStartTime;
private Coroutine jumpCutRoutine;
private List<GameObject> dashHitEnemies = new List<GameObject>();
[SerializeField] private float moveSpeed = 9f;
[SerializeField] private float jumpSpeed = 18.2f;
[SerializeField] private float jumpCutMultiplier = 0.3f;
[SerializeField] private float minJumpDuration = 0.1f;
[SerializeField] private float dashTime = 0.5f;
[SerializeField] private float dashDistance = 5f;
private float _jumpStartTime;
[SerializeField] private LayerMask enemyLayer;
[SerializeField] private Vector2 attackBoxSize = new Vector2(1f, 1f);
private void Start()
{
_rigidbody = gameObject.GetComponent<Rigidbody2D>();
_playerAttack = gameObject.GetComponent<PlayerAttack>();
_camera = Camera.main;
}
private void FixedUpdate()
{
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.25f, LayerMask.GetMask("Ground"));
Debug.DrawRay(transform.position, Vector2.down * 1.25f, Color.red);
if (isGrounded && _rigidbody.linearVelocity.y <= 0.1f)
{
currentJumpCount = maxJumpCount;
}
isGrounded = CheckGround();
MovePlayer();
InitJumpCount();
if(!_playerAttack.isDashing)
{
MovePlayer();
}
Debug.DrawRay(transform.position, Vector2.down * 1.25f, Color.red);
}
private void OnMove(InputValue value)
@ -46,6 +53,21 @@ public class PlayerController : MonoBehaviour
inputVector = new Vector2(input.x * moveSpeed, 0);
}
private void OnAttack(InputValue value)
{
if (isDashing) return;
if (value.isPressed)
{
if (Mouse.current.leftButton.isPressed)
{
NormalAttack();
} else if (Mouse.current.rightButton.isPressed)
{
DashAttack();
}
}
}
private void OnJump(InputValue value)
{
if (value.isPressed)
@ -53,15 +75,15 @@ public class PlayerController : MonoBehaviour
if (currentJumpCount > 0)
{
currentJumpCount--;
_jumpStartTime = Time.time;
StopAllCoroutines();
jumpStartTime = Time.time;
if (jumpCutRoutine != null) StopCoroutine(jumpCutRoutine);
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, 0);
_rigidbody.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
}
}
else
{
float timeElapsed = Time.time - _jumpStartTime;
float timeElapsed = Time.time - jumpStartTime;
if (timeElapsed >= minJumpDuration)
{
@ -70,11 +92,73 @@ public class PlayerController : MonoBehaviour
else
{
float delay = minJumpDuration - timeElapsed;
StartCoroutine(DelayedJumpCut(delay));
jumpCutRoutine = StartCoroutine(DelayedJumpCut(delay));
}
}
}
private void NormalAttack()
{
float angle = GetMouseAngle();
Vector2 direction = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
Vector2 originPosition = (Vector2)transform.position + (direction * 1);
Collider2D[] enemise = Physics2D.OverlapBoxAll(originPosition, attackBoxSize, angle, enemyLayer);
foreach (Collider2D enemy in enemise)
{
Debug.Log(enemy.name);
enemy.gameObject.GetComponent<Entity>().TakeDamage(10);
}
}
private void DashAttack()
{
if (isDashing) return;
StartCoroutine(DashPlayerRoutine());
}
private IEnumerator DashPlayerRoutine()
{
isDashing = true;
_rigidbody.linearVelocity = Vector2.zero;
dashHitEnemies.Clear();
Vector2 mousePos = _camera.ScreenToWorldPoint(Mouse.current.position.ReadValue());
Vector2 direction = (mousePos - (Vector2)transform.position).normalized;
if (isGrounded && mousePos.y < transform.position.y)
{
direction = new Vector2(Mathf.Sign(direction.x), 0);
}
Vector2 startPos = _rigidbody.position;
Vector2 targetPos = startPos + (direction * dashDistance);
float dashTimer = 0f;
while (dashTimer < dashTime)
{
dashTimer += Time.deltaTime;
float t = dashTimer / dashTime;
_rigidbody.MovePosition(Vector2.Lerp(startPos, targetPos, t));
yield return null;
}
isDashing = false;
}
private void MovePlayer()
{
if(!isDashing)
_rigidbody.linearVelocity = new Vector2(inputVector.x, _rigidbody.linearVelocity.y);
}
private float GetMouseAngle()
{
Vector2 tempVect = _camera.ScreenToWorldPoint(Mouse.current.position.ReadValue()) - transform.position;
return Mathf.Atan2(tempVect.y, tempVect.x) * Mathf.Rad2Deg;
}
private void CutJumpVelocity()
{
if (_rigidbody.linearVelocity.y > 0)
@ -89,8 +173,33 @@ public class PlayerController : MonoBehaviour
CutJumpVelocity();
}
private void MovePlayer()
private bool CheckGround()
{
_rigidbody.linearVelocity = new Vector2(inputVector.x, _rigidbody.linearVelocity.y);
return Physics2D.Raycast(transform.position, Vector2.down, 1.25f, LayerMask.GetMask("Ground"));
}
private void InitJumpCount()
{
if (isGrounded && _rigidbody.linearVelocity.y <= 0.1f)
{
currentJumpCount = maxJumpCount;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (isDashing)
{
if ((enemyLayer.value & (1 << collision.gameObject.layer)) > 0)
{
if (!dashHitEnemies.Contains(collision.gameObject))
{
dashHitEnemies.Add(collision.gameObject);
Debug.Log(collision.gameObject.name + " 대쉬 피격");
collision.gameObject.GetComponent<Entity>().TakeDamage(10);
}
}
}
}
}