# Conflicts:
#	Assets/Scripts/EntityData/TestEntity.asset
#	Assets/Scripts/Monster/GroundEnemyMovement.cs
#	Assets/Scripts/Player/Player.cs
#	Assets/Scripts/Player/PlayerController.cs
This commit is contained in:
정세윤_crow 2026-01-27 21:17:01 +09:00
commit e211e4f846
7 changed files with 404 additions and 260 deletions

View File

@ -32,6 +32,15 @@
"processors": "", "processors": "",
"interactions": "", "interactions": "",
"initialStateCheck": false "initialStateCheck": false
},
{
"name": "Dash",
"type": "Button",
"id": "0c7ad5ea-040a-4fd6-a521-426bd58696dc",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
} }
], ],
"bindings": [ "bindings": [
@ -46,6 +55,17 @@
"isComposite": true, "isComposite": true,
"isPartOfComposite": false "isPartOfComposite": false
}, },
{
"name": "Up",
"id": "e481446d-e3f2-4bf3-ab59-1e0f848c6b3a",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{ {
"name": "left", "name": "left",
"id": "d2581a9b-1d11-4566-b27d-b92aff5fabbc", "id": "d2581a9b-1d11-4566-b27d-b92aff5fabbc",
@ -57,6 +77,17 @@
"isComposite": false, "isComposite": false,
"isPartOfComposite": true "isPartOfComposite": true
}, },
{
"name": "Down",
"id": "7cb0e82f-c756-48a7-9b9b-339ce8666d02",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{ {
"name": "right", "name": "right",
"id": "fcfe95b8-67b9-4526-84b5-5d0bc98d6400", "id": "fcfe95b8-67b9-4526-84b5-5d0bc98d6400",
@ -71,7 +102,7 @@
{ {
"name": "", "name": "",
"id": "27687542-09ec-47b5-8f6c-5c672da72b21", "id": "27687542-09ec-47b5-8f6c-5c672da72b21",
"path": "<Keyboard>/space", "path": "<Keyboard>/k",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "",
@ -82,7 +113,7 @@
{ {
"name": "", "name": "",
"id": "d68d6dd4-a961-418c-aac8-c8fd27de4477", "id": "d68d6dd4-a961-418c-aac8-c8fd27de4477",
"path": "<Mouse>/leftButton", "path": "<Keyboard>/j",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "",
@ -92,12 +123,12 @@
}, },
{ {
"name": "", "name": "",
"id": "0c24d2fb-36e8-4e61-9816-56c589a0da18", "id": "885a072f-b502-448c-9b4b-7ef0c24462ec",
"path": "<Mouse>/rightButton", "path": "<Keyboard>/l",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "",
"action": "Attack", "action": "Dash",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
} }

View File

@ -127,10 +127,22 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 1470778168392290969, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_FlipX
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1470778168392290969, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_FlipY
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1888074432508430436, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} - target: {fileID: 1888074432508430436, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: data propertyPath: data
value: value:
objectReference: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2} objectReference: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2}
- target: {fileID: 2556996269222904179, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_GravityScale
value: 3
objectReference: {fileID: 0}
- target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} - target: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0 value: 0
@ -171,6 +183,14 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7073821485941705831, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_FlipX
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7073821485941705831, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_FlipY
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} - target: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Player value: Player
@ -181,6 +201,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} - targetCorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1 insertIndex: -1
addedObject: {fileID: 519420032} addedObject: {fileID: 519420032}
- targetCorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1
addedObject: {fileID: 1840358744}
m_AddedComponents: m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} - targetCorrespondingSourceObject: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1 insertIndex: -1
@ -202,7 +225,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &306394115 --- !u!4 &306394115
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -465,6 +488,63 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &974281701
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6341745752034328576, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_Name
value: StartPoint
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6865574070306004691, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f14d701489108ef4aa0c2a723a069b8b, type: 3}
--- !u!4 &1052407366 stripped --- !u!4 &1052407366 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3} m_CorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
@ -482,146 +562,126 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b68250b34a148164d9a00b31f0af63d8, type: 3} m_Script: {fileID: 11500000, guid: b68250b34a148164d9a00b31f0af63d8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Player m_EditorClassIdentifier: Assembly-CSharp::Player
currentHp: 0
maxHp: 10
maxJumpCount: 1
moveSpeed: 9 moveSpeed: 9
jumpSpeed: 18.2 jumpSpeed: 5
jumpCutMultiplier: 0.3 attackSlowDuration: 0.5
attackBoxSize: {x: 3, y: 1} airMoveMultiplier: 0.4
fallSpeedClamp: -3
attackCooldown: 0.4
dashTime: 0.2
dashDistance: 5
comboAttackSizes:
- {x: 1.5, y: 1}
- {x: 2, y: 1.5}
- {x: 3, y: 2}
enemyLayer: enemyLayer:
serializedVersion: 2 serializedVersion: 2
m_Bits: 64 m_Bits: 64
dashTime: 0.5 obstacleLayer:
dashDistance: 5 serializedVersion: 2
--- !u!1 &1117392520 stripped m_Bits: 8
groundLayer:
serializedVersion: 2
m_Bits: 72
--- !u!1 &1840358743
GameObject: GameObject:
m_CorrespondingSourceObject: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_ObjectHideFlags: 0
m_PrefabInstance: {fileID: 960162597646736108} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!212 &1117392523 stripped serializedVersion: 6
m_Component:
- component: {fileID: 1840358744}
- component: {fileID: 1840358745}
m_Layer: 0
m_Name: Square
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1840358744
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1840358743}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.47, y: 0.37, z: 0}
m_LocalScale: {x: 0.43, y: 0.55, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1052407366}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1840358745
SpriteRenderer: SpriteRenderer:
m_CorrespondingSourceObject: {fileID: 3818235801779510969, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} serializedVersion: 2
m_PrefabInstance: {fileID: 960162597646736108}
m_PrefabAsset: {fileID: 0}
--- !u!50 &1117392525
Rigidbody2D:
serializedVersion: 5
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1117392520} m_GameObject: {fileID: 1840358743}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 2
--- !u!114 &1117392526
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1117392520}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_CastShadows: 0
m_Script: {fileID: 11500000, guid: 7e036d2115ad53f48ba9c059c6cea1bb, type: 3} m_ReceiveShadows: 0
m_Name: m_DynamicOccludee: 1
m_EditorClassIdentifier: Assembly-CSharp::GroundEnemyMovement m_StaticShadowCaster: 0
data: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2} m_MotionVectors: 1
rigidBody: {fileID: 1117392525} m_LightProbeUsage: 1
spriteRenderer: {fileID: 1117392523} m_ReflectionProbeUsage: 1
Speed: 3 m_RayTracingMode: 0
startDirection: 1.5 m_RayTraceProcedural: 0
--- !u!1001 &960162597646736108 m_RayTracingAccelStructBuildFlagsOverride: 0
PrefabInstance: m_RayTracingAccelStructBuildFlags: 1
m_ObjectHideFlags: 0 m_SmallMeshCulling: 1
serializedVersion: 2 m_ForceMeshLod: -1
m_Modification: m_MeshLodSelectionBias: 0
serializedVersion: 3 m_RenderingLayerMask: 1
m_TransformParent: {fileID: 0} m_RendererPriority: 0
m_Modifications: m_Materials:
- target: {fileID: 3096000554608240826, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
propertyPath: m_IsTrigger m_StaticBatchInfo:
value: 1 firstSubMesh: 0
objectReference: {fileID: 0} subMeshCount: 0
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_StaticBatchRoot: {fileID: 0}
propertyPath: m_LocalPosition.x m_ProbeAnchor: {fileID: 0}
value: -7.42 m_LightProbeVolumeOverride: {fileID: 0}
objectReference: {fileID: 0} m_ScaleInLightmap: 1
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_ReceiveGI: 1
propertyPath: m_LocalPosition.y m_PreserveUVs: 0
value: -0.66 m_IgnoreNormalsForChartDetection: 0
objectReference: {fileID: 0} m_ImportantGI: 0
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_StitchLightmapSeams: 1
propertyPath: m_LocalPosition.z m_SelectedEditorRenderState: 0
value: 0 m_MinimumChartSize: 4
objectReference: {fileID: 0} m_AutoUVMaxDistance: 0.5
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_AutoUVMaxAngle: 89
propertyPath: m_LocalRotation.w m_LightmapParameters: {fileID: 0}
value: 1 m_GlobalIlluminationMeshLod: 0
objectReference: {fileID: 0} m_SortingLayerID: 0
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_SortingLayer: 0
propertyPath: m_LocalRotation.x m_SortingOrder: 0
value: 0 m_MaskInteraction: 0
objectReference: {fileID: 0} m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_Color: {r: 1, g: 0.12481479, b: 0, a: 1}
propertyPath: m_LocalRotation.y m_FlipX: 0
value: 0 m_FlipY: 0
objectReference: {fileID: 0} m_DrawMode: 0
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_Size: {x: 1, y: 1}
propertyPath: m_LocalRotation.z m_AdaptiveModeThreshold: 0.5
value: 0 m_SpriteTileMode: 0
objectReference: {fileID: 0} m_WasSpriteAssigned: 1
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3} m_SpriteSortPoint: 0
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}
- target: {fileID: 4449206212094151330, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 4449206212094151330, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
insertIndex: -1
addedObject: {fileID: 1117392526}
- targetCorrespondingSourceObject: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
insertIndex: -1
addedObject: {fileID: 1117392525}
m_SourcePrefab: {fileID: 100100000, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_Roots: m_Roots:
- {fileID: 619394802} - {fileID: 619394802}
- {fileID: 91367892} - {fileID: 91367892}
- {fileID: 960162597646736108}
- {fileID: 306394115} - {fileID: 306394115}
- {fileID: 974281701}

View File

@ -12,6 +12,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 39b051782604253409a851b6a1243199, type: 3} m_Script: {fileID: 11500000, guid: 39b051782604253409a851b6a1243199, type: 3}
m_Name: TestEntity m_Name: TestEntity
m_EditorClassIdentifier: Assembly-CSharp::EntityData m_EditorClassIdentifier: Assembly-CSharp::EntityData
name: entityName:
maxHealth: 3 maxHealth: 3
attackDamage: 5 attackDamage: 2

View File

@ -1,16 +1,7 @@
using System;
using UnityEngine; using UnityEngine;
public class NewMonoBehaviourScript : MonoBehaviour public class Item
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{ {
} }
// Update is called once per frame
void Update()
{
}
}

View File

@ -3,7 +3,7 @@ using UnityEngine;
[CreateAssetMenu(fileName = "EntityData", menuName = "Scriptable Objects/EntityData")] [CreateAssetMenu(fileName = "EntityData", menuName = "Scriptable Objects/EntityData")]
public class EntityData : ScriptableObject public class EntityData : ScriptableObject
{ {
public string name; public string entityName;
public int maxHealth; public int maxHealth;
public int attackDamage; public int attackDamage;
} }

View File

@ -1,121 +1,159 @@
using System; using System.Collections;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
public class Player : MonoBehaviour public class Player : MonoBehaviour
{ {
private Camera _camera; private Rigidbody2D _rigidbody;
private Rigidbody2D _rigidbody2D;
[SerializeField] int currentHp;
private int currentJumpCount;
private int comboStep;
[SerializeField] private int currentHp; private Vector2 inputVector;
[SerializeField] private int maxHp = 10;
private int maxJumpCount = 2;
private int currentJumpCount = 2;
private float moveX;
private bool isGrounded; private bool isGrounded;
private bool isDashing; private bool isDashing;
private bool isAirAttackSlow;
private bool pendingAirAttackSlow;
private float attackSlowTimer;
private float attackCooldownTimer;
private Coroutine jumpCutRoutine;
private List<GameObject> dashHitEnemies = new List<GameObject>(); private List<GameObject> dashHitEnemies = new List<GameObject>();
[SerializeField] private int maxHp = 100;
[SerializeField] private int maxJumpCount = 1;
[SerializeField] private float moveSpeed = 9f; [SerializeField] private float moveSpeed = 9f;
[SerializeField] private float jumpSpeed = 18.2f; [SerializeField] private float jumpSpeed = 18.2f;
[SerializeField] private float jumpCutMultiplier = 0.3f;
[SerializeField] private Vector2 attackBoxSize = new Vector2(1f, 1f); [SerializeField] private float attackSlowDuration = 0.5f;
[SerializeField] private LayerMask enemyLayer; [SerializeField] private float airMoveMultiplier = 0.4f;
[SerializeField] private float fallSpeedClamp = -3f;
[SerializeField] private float attackCooldown = 0.4f;
[SerializeField] private float dashTime = 0.5f; [SerializeField] private float dashTime = 0.5f;
[SerializeField] private float dashDistance = 5f; [SerializeField] private float dashDistance = 5f;
private Rigidbody2D _rigidbody; [SerializeField] private Vector2[] comboAttackSizes =
{
new Vector2(1.5f, 1f),
new Vector2(2f, 1.5f),
new Vector2(3f, 2f)
};
[SerializeField] private LayerMask enemyLayer;
[SerializeField] private LayerMask obstacleLayer;
[SerializeField] private LayerMask groundLayer;
private void Start() private void Start()
{ {
_rigidbody = GetComponent<Rigidbody2D>();
currentHp = maxHp; currentHp = maxHp;
_rigidbody = gameObject.GetComponent<Rigidbody2D>(); currentJumpCount = maxJumpCount;
_camera = Camera.main;
} }
public void Jump() private void Update()
{ {
if (currentJumpCount > 0) if (attackCooldownTimer > 0f)
attackCooldownTimer -= Time.deltaTime;
if (isAirAttackSlow)
{ {
currentJumpCount--; attackSlowTimer -= Time.deltaTime;
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, 0); if (attackSlowTimer <= 0f)
_rigidbody.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse); {
isAirAttackSlow = false;
pendingAirAttackSlow = false;
}
} }
} }
public void MoveUpdate() private void FixedUpdate()
{ {
if (!isDashing) if (pendingAirAttackSlow && _rigidbody.linearVelocity.y < 0f)
{ {
_rigidbody.linearVelocity = new Vector2(moveX * moveSpeed, _rigidbody.linearVelocity.y); pendingAirAttackSlow = false;
isAirAttackSlow = true;
attackSlowTimer = attackSlowDuration;
}
if (isAirAttackSlow && _rigidbody.linearVelocity.y < fallSpeedClamp)
{
_rigidbody.linearVelocity = new Vector2(
_rigidbody.linearVelocity.x,
fallSpeedClamp
);
} }
} }
public void SetXVector(InputValue value) public void SetXVector(InputValue value)
{ {
moveX = value.Get<Vector2>().x; inputVector = value.Get<Vector2>();
}
public void MoveUpdate()
{
if (isDashing) return;
float multiplier = isAirAttackSlow ? airMoveMultiplier : 1f;
_rigidbody.linearVelocity = new Vector2(
inputVector.x * moveSpeed * multiplier,
_rigidbody.linearVelocity.y
);
}
public void Jump()
{
if (currentJumpCount <= 0) return;
currentJumpCount--;
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, 0f);
_rigidbody.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
} }
public void NormalAttack() public void NormalAttack()
{ {
float angle = GetMouseAngle(); if (isDashing) return;
Vector2 direction = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad)); if (attackCooldownTimer > 0f) return;
Vector2 originPosition = (Vector2)transform.position + (direction * 1);
Collider2D[] enemise = Physics2D.OverlapBoxAll(originPosition, attackBoxSize, angle, enemyLayer);
Debug.Log(angle);
if (enemise.Length > 0)
{
foreach (Collider2D enemy in enemise)
{
//Debug.Log(enemy.name);
enemy.gameObject.GetComponent<Entity>().TakeDamage(10);
}
if (angle > -110 && angle < -70)
{
_rigidbody.linearVelocity = new Vector2(-_rigidbody.linearVelocity.x, 20f);
} attackCooldownTimer = attackCooldown;
Vector2 boxSize = comboAttackSizes[comboStep];
float dir = inputVector.x != 0 ? Mathf.Sign(inputVector.x) : Mathf.Sign(transform.localScale.x);
Vector2 origin = (Vector2)transform.position + new Vector2(dir * boxSize.x, 0f);
Collider2D[] enemies = Physics2D.OverlapBoxAll(origin, boxSize, 0f, enemyLayer);
foreach (Collider2D enemy in enemies)
{
Vector2 toEnemy = (enemy.transform.position - transform.position).normalized;
float dist = Vector2.Distance(transform.position, enemy.transform.position);
if (!Physics2D.Raycast(transform.position, toEnemy, dist, obstacleLayer))
{
enemy.GetComponent<Entity>()?.TakeDamage(10);
} }
} }
private void CutJumpVelocity() comboStep = (comboStep + 1) % comboAttackSizes.Length;
{
if (_rigidbody.linearVelocity.y > 0)
{
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, _rigidbody.linearVelocity.y * jumpCutMultiplier);
}
}
private IEnumerator DelayedJumpCut(float delay) if (!isGrounded)
{ {
yield return new WaitForSeconds(delay); if (_rigidbody.linearVelocity.y < 0f)
CutJumpVelocity(); {
isAirAttackSlow = true;
attackSlowTimer = attackSlowDuration;
} }
else
public void CheckGround()
{ {
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.25f, LayerMask.GetMask("Ground")); pendingAirAttackSlow = true;
if (isGrounded)
{
currentJumpCount = maxJumpCount;
} }
} }
private float GetMouseAngle()
{
Vector2 tempVect = _camera.ScreenToWorldPoint(Mouse.current.position.ReadValue()) - transform.position;
return Mathf.Atan2(tempVect.y, tempVect.x) * Mathf.Rad2Deg;
} }
public void DashAttack() public void DashAttack()
@ -131,28 +169,31 @@ public class Player : MonoBehaviour
private IEnumerator DashPlayerRoutine() private IEnumerator DashPlayerRoutine()
{ {
isDashing = true; isDashing = true;
isAirAttackSlow = false;
pendingAirAttackSlow = false;
attackSlowTimer = 0f;
attackCooldownTimer = 0f;
_rigidbody.linearVelocity = Vector2.zero; _rigidbody.linearVelocity = Vector2.zero;
dashHitEnemies.Clear(); dashHitEnemies.Clear();
Vector2 mousePos = _camera.ScreenToWorldPoint(Mouse.current.position.ReadValue()); Vector2 direction = inputVector.normalized;
Vector2 direction = (mousePos - (Vector2)transform.position).normalized; if (direction == Vector2.zero)
direction = new Vector2(Mathf.Sign(transform.localScale.x), 0f);
if (isGrounded && mousePos.y < transform.position.y) if (isGrounded && direction.y < 0)
{ direction.y = 0f;
direction = new Vector2(Mathf.Sign(direction.x), 0);
}
Vector2 startPos = _rigidbody.position; Vector2 startPos = _rigidbody.position;
Vector2 targetPos = startPos + (direction * dashDistance); Vector2 targetPos = startPos + direction * dashDistance;
float dashTimer = 0f; float timer = 0f;
while (dashTimer < dashTime) while (timer < dashTime)
{ {
dashTimer += Time.deltaTime; timer += Time.deltaTime;
float t = dashTimer / dashTime; float t = timer / dashTime;
_rigidbody.MovePosition(Vector2.Lerp(startPos, targetPos, t)); _rigidbody.MovePosition(Vector2.Lerp(startPos, targetPos, t));
yield return null; yield return null;
} }
@ -161,15 +202,40 @@ public class Player : MonoBehaviour
public void AttackOnDash(Collider2D collision) public void AttackOnDash(Collider2D collision)
{ {
if ((enemyLayer.value & (1 << collision.gameObject.layer)) > 0) if ((enemyLayer.value & (1 << collision.gameObject.layer)) == 0) return;
{ if (dashHitEnemies.Contains(collision.gameObject)) return;
if (!dashHitEnemies.Contains(collision.gameObject))
{
dashHitEnemies.Add(collision.gameObject); dashHitEnemies.Add(collision.gameObject);
Debug.Log(collision.gameObject.name + " 대쉬 피격"); collision.GetComponent<Entity>()?.TakeDamage(10);
collision.gameObject.GetComponent<Entity>().TakeDamage(10);
} }
public void CheckGround()
{
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.25f, groundLayer);
if (isGrounded)
{
currentJumpCount = maxJumpCount;
isAirAttackSlow = false;
pendingAirAttackSlow = false;
attackSlowTimer = 0f;
} }
}
public void Heal(int value)
{
if (value <= 0) return;
currentHp += value;
if (currentHp > maxHp)
currentHp = maxHp;
}
public void TakeDamage(int damage)
{
currentHp -= damage;
if (currentHp <= 0)
Destroy(gameObject);
} }
public bool IsDashing() public bool IsDashing()
@ -177,27 +243,22 @@ public class Player : MonoBehaviour
return isDashing; return isDashing;
} }
public void Heal(int heal) private void OnDrawGizmos()
{ {
if (heal < 0) if (comboAttackSizes == null || comboAttackSizes.Length == 0) return;
Gizmos.color = Color.red;
int stepIndex = (comboStep < comboAttackSizes.Length) ? comboStep : 0;
Vector2 boxSize = comboAttackSizes[stepIndex];
float dir = Mathf.Sign(transform.localScale.x);
if (Application.isPlaying && inputVector.x != 0)
{ {
return; dir = Mathf.Sign(inputVector.x);
} }
currentHp += heal; Vector2 origin = (Vector2)transform.position + new Vector2(dir * boxSize.x, 0f);
if (currentHp > maxHp) Gizmos.DrawWireCube(origin, boxSize);
{
currentHp = maxHp;
}
}
public void TakeDamage(int playerAttackDamage)
{
currentHp -= playerAttackDamage;
if (currentHp <= 0)
{
currentHp = 0;
Destroy(gameObject);
}
} }
} }

View File

@ -36,17 +36,18 @@ public class PlayerController : MonoBehaviour
} }
if (value.isPressed) if (value.isPressed)
{
if (Mouse.current.leftButton.isPressed)
{ {
player.NormalAttack(); player.NormalAttack();
} }
else if (Mouse.current.rightButton.isPressed) }
private void OnDash(InputValue value)
{
if (value.isPressed)
{ {
player.DashAttack(); player.DashAttack();
} }
} }
}
private void OnJump(InputValue value) private void OnJump(InputValue value)
{ {