Projext/Assets/5.TestScript/PlayerInput.cs
2026-01-30 12:24:13 +09:00

39 lines
1.4 KiB
C#

using UnityEngine;
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; // ⭐ 추가: UI 매니저 연결
private void Update()
{
if (health != null && health.IsDead) return;
// ⭐ [추가] C키를 누르면 상태창 토글
if (Input.GetKeyDown(KeyCode.C) && statsUI != null)
{
statsUI.ToggleWindow();
}
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);
if (aim != null) aim.RotateTowardsMouse();
if (Input.GetKeyDown(KeyCode.F) && interaction != null) interaction.TryInteract();
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();
}
}
}
}