# 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": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Dash",
"type": "Button",
"id": "0c7ad5ea-040a-4fd6-a521-426bd58696dc",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@ -46,6 +55,17 @@
"isComposite": true,
"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",
"id": "d2581a9b-1d11-4566-b27d-b92aff5fabbc",
@ -57,6 +77,17 @@
"isComposite": false,
"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",
"id": "fcfe95b8-67b9-4526-84b5-5d0bc98d6400",
@ -71,7 +102,7 @@
{
"name": "",
"id": "27687542-09ec-47b5-8f6c-5c672da72b21",
"path": "<Keyboard>/space",
"path": "<Keyboard>/k",
"interactions": "",
"processors": "",
"groups": "",
@ -82,7 +113,7 @@
{
"name": "",
"id": "d68d6dd4-a961-418c-aac8-c8fd27de4477",
"path": "<Mouse>/leftButton",
"path": "<Keyboard>/j",
"interactions": "",
"processors": "",
"groups": "",
@ -92,12 +123,12 @@
},
{
"name": "",
"id": "0c24d2fb-36e8-4e61-9816-56c589a0da18",
"path": "<Mouse>/rightButton",
"id": "885a072f-b502-448c-9b4b-7ef0c24462ec",
"path": "<Keyboard>/l",
"interactions": "",
"processors": "",
"groups": "",
"action": "Attack",
"action": "Dash",
"isComposite": false,
"isPartOfComposite": false
}

View File

@ -127,10 +127,22 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
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}
propertyPath: data
value:
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}
propertyPath: m_LocalPosition.x
value: 0
@ -171,6 +183,14 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 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}
propertyPath: m_Name
value: Player
@ -181,6 +201,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1
addedObject: {fileID: 519420032}
- targetCorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1
addedObject: {fileID: 1840358744}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 9138407101546400895, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
insertIndex: -1
@ -202,7 +225,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &306394115
Transform:
m_ObjectHideFlags: 0
@ -465,6 +488,63 @@ Transform:
m_Children: []
m_Father: {fileID: 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
Transform:
m_CorrespondingSourceObject: {fileID: 4539706167822133972, guid: ae58a5fa402b1d941b0878d356d1389d, type: 3}
@ -482,146 +562,126 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b68250b34a148164d9a00b31f0af63d8, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Player
currentHp: 0
maxHp: 10
maxJumpCount: 1
moveSpeed: 9
jumpSpeed: 18.2
jumpCutMultiplier: 0.3
attackBoxSize: {x: 3, y: 1}
jumpSpeed: 5
attackSlowDuration: 0.5
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:
serializedVersion: 2
m_Bits: 64
dashTime: 0.5
dashDistance: 5
--- !u!1 &1117392520 stripped
obstacleLayer:
serializedVersion: 2
m_Bits: 8
groundLayer:
serializedVersion: 2
m_Bits: 72
--- !u!1 &1840358743
GameObject:
m_CorrespondingSourceObject: {fileID: 3345230653483034275, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
m_PrefabInstance: {fileID: 960162597646736108}
m_PrefabAsset: {fileID: 0}
--- !u!212 &1117392523 stripped
SpriteRenderer:
m_CorrespondingSourceObject: {fileID: 3818235801779510969, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
m_PrefabInstance: {fileID: 960162597646736108}
m_PrefabAsset: {fileID: 0}
--- !u!50 &1117392525
Rigidbody2D:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1117392520}
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:
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: 1117392520}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e036d2115ad53f48ba9c059c6cea1bb, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::GroundEnemyMovement
data: {fileID: 11400000, guid: a5edb67c4940a4e4692478c7267fc1f8, type: 2}
rigidBody: {fileID: 1117392525}
spriteRenderer: {fileID: 1117392523}
Speed: 3
startDirection: 1.5
--- !u!1001 &960162597646736108
PrefabInstance:
m_ObjectHideFlags: 0
m_GameObject: {fileID: 1840358743}
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3096000554608240826, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_IsTrigger
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.x
value: -7.42
objectReference: {fileID: 0}
- target: {fileID: 3182903703610233758, guid: a5f5cf89603320347975ecc8f39129b7, type: 3}
propertyPath: m_LocalPosition.y
value: -0.66
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}
- 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}
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:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1840358743}
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: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 0.12481479, b: 0, 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!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 619394802}
- {fileID: 91367892}
- {fileID: 960162597646736108}
- {fileID: 306394115}
- {fileID: 974281701}

View File

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

View File

@ -1,16 +1,7 @@
using System;
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")]
public class EntityData : ScriptableObject
{
public string name;
public string entityName;
public int maxHealth;
public int attackDamage;
}

View File

@ -1,123 +1,161 @@
using System;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class Player : MonoBehaviour
{
private Camera _camera;
private Rigidbody2D _rigidbody2D;
private Rigidbody2D _rigidbody;
[SerializeField] int currentHp;
private int currentJumpCount;
private int comboStep;
[SerializeField] private int currentHp;
[SerializeField] private int maxHp = 10;
private int maxJumpCount = 2;
private int currentJumpCount = 2;
private float moveX;
private Vector2 inputVector;
private bool isGrounded;
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>();
[SerializeField] private int maxHp = 100;
[SerializeField] private int maxJumpCount = 1;
[SerializeField] private float moveSpeed = 9f;
[SerializeField] private float jumpSpeed = 18.2f;
[SerializeField] private float jumpCutMultiplier = 0.3f;
[SerializeField] private Vector2 attackBoxSize = new Vector2(1f, 1f);
[SerializeField] private LayerMask enemyLayer;
[SerializeField] private float attackSlowDuration = 0.5f;
[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 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()
{
_rigidbody = GetComponent<Rigidbody2D>();
currentHp = maxHp;
_rigidbody = gameObject.GetComponent<Rigidbody2D>();
_camera = Camera.main;
currentJumpCount = maxJumpCount;
}
public void Jump()
private void Update()
{
if (currentJumpCount > 0)
if (attackCooldownTimer > 0f)
attackCooldownTimer -= Time.deltaTime;
if (isAirAttackSlow)
{
currentJumpCount--;
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, 0);
_rigidbody.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
attackSlowTimer -= Time.deltaTime;
if (attackSlowTimer <= 0f)
{
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)
{
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()
{
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);
Debug.Log(angle);
if (enemise.Length > 0)
if (isDashing) return;
if (attackCooldownTimer > 0f) return;
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)
{
foreach (Collider2D enemy in enemise)
{
//Debug.Log(enemy.name);
enemy.gameObject.GetComponent<Entity>().TakeDamage(10);
}
if (angle > -110 && angle < -70)
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))
{
_rigidbody.linearVelocity = new Vector2(-_rigidbody.linearVelocity.x, 20f);
enemy.GetComponent<Entity>()?.TakeDamage(10);
}
}
}
private void CutJumpVelocity()
{
if (_rigidbody.linearVelocity.y > 0)
comboStep = (comboStep + 1) % comboAttackSizes.Length;
if (!isGrounded)
{
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, _rigidbody.linearVelocity.y * jumpCutMultiplier);
if (_rigidbody.linearVelocity.y < 0f)
{
isAirAttackSlow = true;
attackSlowTimer = attackSlowDuration;
}
else
{
pendingAirAttackSlow = true;
}
}
}
private IEnumerator DelayedJumpCut(float delay)
{
yield return new WaitForSeconds(delay);
CutJumpVelocity();
}
public void CheckGround()
{
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.25f, LayerMask.GetMask("Ground"));
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()
{
if (isDashing)
@ -131,28 +169,31 @@ public class Player : MonoBehaviour
private IEnumerator DashPlayerRoutine()
{
isDashing = true;
isAirAttackSlow = false;
pendingAirAttackSlow = false;
attackSlowTimer = 0f;
attackCooldownTimer = 0f;
_rigidbody.linearVelocity = Vector2.zero;
dashHitEnemies.Clear();
Vector2 mousePos = _camera.ScreenToWorldPoint(Mouse.current.position.ReadValue());
Vector2 direction = (mousePos - (Vector2)transform.position).normalized;
Vector2 direction = inputVector.normalized;
if (direction == Vector2.zero)
direction = new Vector2(Mathf.Sign(transform.localScale.x), 0f);
if (isGrounded && mousePos.y < transform.position.y)
{
direction = new Vector2(Mathf.Sign(direction.x), 0);
}
if (isGrounded && direction.y < 0)
direction.y = 0f;
Vector2 startPos = _rigidbody.position;
Vector2 targetPos = startPos + (direction * dashDistance);
Vector2 targetPos = startPos + direction * dashDistance;
float dashTimer = 0f;
while (dashTimer < dashTime)
float timer = 0f;
while (timer < dashTime)
{
dashTimer += Time.deltaTime;
float t = dashTimer / dashTime;
timer += Time.deltaTime;
float t = timer / dashTime;
_rigidbody.MovePosition(Vector2.Lerp(startPos, targetPos, t));
yield return null;
}
@ -161,43 +202,63 @@ public class Player : MonoBehaviour
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;
dashHitEnemies.Add(collision.gameObject);
collision.GetComponent<Entity>()?.TakeDamage(10);
}
public void CheckGround()
{
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.25f, groundLayer);
if (isGrounded)
{
if (!dashHitEnemies.Contains(collision.gameObject))
{
dashHitEnemies.Add(collision.gameObject);
Debug.Log(collision.gameObject.name + " 대쉬 피격");
collision.gameObject.GetComponent<Entity>().TakeDamage(10);
}
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()
{
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;
if (currentHp > maxHp)
{
currentHp = maxHp;
}
Vector2 origin = (Vector2)transform.position + new Vector2(dir * boxSize.x, 0f);
Gizmos.DrawWireCube(origin, boxSize);
}
public void TakeDamage(int playerAttackDamage)
{
currentHp -= playerAttackDamage;
if (currentHp <= 0)
{
currentHp = 0;
Destroy(gameObject);
}
}
}
}

View File

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