88 lines
2.0 KiB
C#
88 lines
2.0 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Events;
|
|||
|
|
|
|||
|
|
[CreateAssetMenu(fileName = "MovementInputData", menuName = "FirstPersonController/Data/MovementInputData", order = 1)]
|
|||
|
|
public class MovementInputData : ScriptableObject
|
|||
|
|
{
|
|||
|
|
[System.NonSerialized] public readonly UnityEvent JumpEvent = new UnityEvent();
|
|||
|
|
|
|||
|
|
#region Data
|
|||
|
|
Vector2 m_inputVector;
|
|||
|
|
|
|||
|
|
bool m_isRunning;
|
|||
|
|
bool m_isCrouching;
|
|||
|
|
|
|||
|
|
bool m_crouchClicked;
|
|||
|
|
bool m_jumpClicked;
|
|||
|
|
|
|||
|
|
bool m_runClicked;
|
|||
|
|
bool m_runReleased;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Properties
|
|||
|
|
public Vector2 InputVector => m_inputVector;
|
|||
|
|
public bool HasInput => m_inputVector != Vector2.zero;
|
|||
|
|
public float InputVectorX
|
|||
|
|
{
|
|||
|
|
get => m_inputVector.x;
|
|||
|
|
set => m_inputVector.x = !UIManager.Instance.ChatBox.UsingChatBox && Player.Instance.IsAlive() ? value : 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public float InputVectorY
|
|||
|
|
{
|
|||
|
|
get => m_inputVector.y;
|
|||
|
|
set => m_inputVector.y = !UIManager.Instance.ChatBox.UsingChatBox && Player.Instance.IsAlive() ? value : 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool runPressed
|
|||
|
|
{
|
|||
|
|
get => m_isRunning;
|
|||
|
|
set => m_isRunning = !UIManager.Instance.ChatBox.UsingChatBox && Player.Instance.IsAlive() ? value : false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool IsCrouching
|
|||
|
|
{
|
|||
|
|
get => m_isCrouching;
|
|||
|
|
set => m_isCrouching = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool CrouchClicked
|
|||
|
|
{
|
|||
|
|
get => m_crouchClicked;
|
|||
|
|
set => m_crouchClicked = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool JumpClicked
|
|||
|
|
{
|
|||
|
|
get => m_jumpClicked;
|
|||
|
|
set => m_jumpClicked = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool RunClicked
|
|||
|
|
{
|
|||
|
|
get => m_runClicked;
|
|||
|
|
set => m_runClicked = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool RunReleased
|
|||
|
|
{
|
|||
|
|
get => m_runReleased;
|
|||
|
|
set => m_runReleased = value;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Custom Methods
|
|||
|
|
public void ResetInput()
|
|||
|
|
{
|
|||
|
|
m_inputVector = Vector2.zero;
|
|||
|
|
|
|||
|
|
m_isRunning = false;
|
|||
|
|
m_isCrouching = false;
|
|||
|
|
|
|||
|
|
m_crouchClicked = false;
|
|||
|
|
m_jumpClicked = false;
|
|||
|
|
m_runClicked = false;
|
|||
|
|
m_runReleased = false;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|