Projext/Assets/Scripts/Player/Controller/PlayerInput.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2026-01-29 06:58:38 +00:00
using UnityEngine;
2026-01-29 06:58:38 +00:00
public class PlayerInput : MonoBehaviour
{
[SerializeField] private PlayerHealth health;
[SerializeField] private PlayerMovement movement;
[SerializeField] private PlayerAim aim;
[SerializeField] private PlayerInteraction interaction;
[SerializeField] private PlayerAttack attack;
[SerializeField] private PlayerStatsUI statsUI;
2026-01-30 03:24:13 +00:00
2026-01-29 06:58:38 +00:00
private void Update()
{
if (health != null && health.IsDead) return;
2026-01-30 03:24:13 +00:00
if (Input.GetKeyDown(KeyCode.C) && statsUI != null) statsUI.ToggleWindow();
2026-01-30 03:24:13 +00:00
2026-01-29 06:58:38 +00:00
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
bool sprint = Input.GetKey(KeyCode.LeftShift);
if (movement != null)
{
movement.SetMoveInput(new Vector3(h, 0, v).normalized, sprint);
// ⭐ [추가] Space 키를 누르면 대시 실행
if (Input.GetKeyDown(KeyCode.Space)) movement.AttemptDash();
}
2026-01-29 06:58:38 +00:00
if (aim != null) aim.RotateTowardsMouse();
if (Input.GetKeyDown(KeyCode.F) && interaction != null) interaction.TryInteract();
2026-01-30 03:24:13 +00:00
2026-01-29 06:58:38 +00:00
if (attack != null)
{
if (Input.GetMouseButtonDown(1)) attack.StartCharging();
if (Input.GetMouseButtonUp(1)) attack.CancelCharging();
if (Input.GetMouseButtonDown(0))
{
if (Input.GetMouseButton(1)) attack.ReleaseAttack();
else attack.PerformNormalAttack();
}
}
}
}