Update
This commit is contained in:
@@ -10,10 +10,9 @@ namespace OnlyScove.Scripts
|
||||
public virtual Vector2 MoveInput { get; protected set; }
|
||||
public virtual Vector2 LookInput { get; protected set; }
|
||||
public virtual Vector2 ScrollInput { get; protected set; }
|
||||
public virtual bool IsSprintHeld { get; protected set; } // Left Shift
|
||||
public virtual bool IsAttackHeld { get; protected set; } // Left Mouse Button
|
||||
public virtual bool IsSprintHeld { get; protected set; }
|
||||
public virtual bool IsAttackHeld { get; protected set; }
|
||||
|
||||
// THÊM HÀM NÀY ĐỂ ĐỒNG BỘ MẠNG
|
||||
public void ApplyNetworkInput(Vector2 move, bool isSprint)
|
||||
{
|
||||
MoveInput = move;
|
||||
@@ -21,15 +20,19 @@ namespace OnlyScove.Scripts
|
||||
}
|
||||
|
||||
// One-shot Events
|
||||
public event Action OnJumpEvent; // Space
|
||||
public event Action OnDodgeEvent; // Right Mouse Button (RMB)
|
||||
public event Action OnSprintEvent; // Left Shift
|
||||
public event Action OnAttackEvent; // Left Mouse Button (LMB)
|
||||
public event Action OnCrouchEvent; // C Key
|
||||
public event Action OnInteractEvent; // E Key
|
||||
public event Action OnNextInteractEvent; // R Key
|
||||
public event Action OnPreviousInteractEvent; // Q Key
|
||||
public event Action OnToggleViewEvent; // F2 - New event for toggling camera view
|
||||
public event Action OnJumpEvent;
|
||||
public event Action OnDodgeEvent;
|
||||
public event Action OnSprintEvent;
|
||||
public event Action OnAttackEvent;
|
||||
public event Action OnCrouchEvent;
|
||||
public event Action OnInteractEvent;
|
||||
public event Action OnNextInteractEvent;
|
||||
public event Action OnPreviousInteractEvent;
|
||||
public event Action OnToggleViewEvent;
|
||||
|
||||
// UI Events
|
||||
public event Action OnToggleSettingsEvent; // Cho Ctrl+O
|
||||
public event Action OnCancelEvent; // Cho phím ESC hoặc phím đóng UI
|
||||
|
||||
public void OnAttack(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -69,13 +72,9 @@ namespace OnlyScove.Scripts
|
||||
if (context.canceled) IsSprintHeld = false;
|
||||
}
|
||||
|
||||
// New method for ToggleView input
|
||||
public void OnToggleView(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnToggleViewEvent?.Invoke();
|
||||
}
|
||||
if (context.performed) OnToggleViewEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
@@ -95,13 +94,7 @@ namespace OnlyScove.Scripts
|
||||
|
||||
public void OnInteract(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Log($"[InputReader] Interaction State: {context.phase} | Started: {context.started} | Performed: {context.performed} | Canceled: {context.canceled}");
|
||||
|
||||
if (context.performed)
|
||||
{
|
||||
Debug.Log("[InputReader] Event OnInteractEvent triggered!");
|
||||
OnInteractEvent?.Invoke();
|
||||
}
|
||||
if (context.performed) OnInteractEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void OnNext(InputAction.CallbackContext context)
|
||||
@@ -113,5 +106,20 @@ namespace OnlyScove.Scripts
|
||||
{
|
||||
if (context.performed) OnPreviousInteractEvent?.Invoke();
|
||||
}
|
||||
|
||||
// UI Callbacks
|
||||
public void OnToggleSettings(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
Debug.Log("[InputReader] Toggle Settings Action Performed!");
|
||||
OnToggleSettingsEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCancel(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed) OnCancelEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user