|
@ -8,7 +8,7 @@ using NaughtyAttributes; |
|
|
public class CharacterInputController : MonoBehaviour |
|
|
public class CharacterInputController : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
[SerializeField,Header("References")] |
|
|
|
|
|
|
|
|
[SerializeField, Header("References")] |
|
|
private CharacterController2D m_characterController; |
|
|
private CharacterController2D m_characterController; |
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
[SerializeField] |
|
@ -17,7 +17,16 @@ public class CharacterInputController : MonoBehaviour |
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
private Reference<bool> m_noInputAllowed; |
|
|
private Reference<bool> m_noInputAllowed; |
|
|
|
|
|
|
|
|
[SerializeField,BoxGroup("Settings")] |
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
private Reference<bool> m_isPlayerDead; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
private Reference<bool> m_isVictory; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
private Animator m_animator; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Settings")] |
|
|
private float m_speed = 2.0f; |
|
|
private float m_speed = 2.0f; |
|
|
|
|
|
|
|
|
[ShowNonSerializedField] |
|
|
[ShowNonSerializedField] |
|
@ -28,6 +37,12 @@ public class CharacterInputController : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
|
|
{ |
|
|
|
|
|
m_isPlayerDead.OnValueChanged += OnDeath; |
|
|
|
|
|
m_isVictory.OnValueChanged += OnVictory; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void OnMove(InputAction.CallbackContext context) |
|
|
public void OnMove(InputAction.CallbackContext context) |
|
|
{ |
|
|
{ |
|
|
m_movement = context.ReadValue<Vector2>(); |
|
|
m_movement = context.ReadValue<Vector2>(); |
|
@ -45,12 +60,38 @@ public class CharacterInputController : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
m_characterController.Move(m_movement.x * m_speed, false, m_jump); |
|
|
m_characterController.Move(m_movement.x * m_speed, false, m_jump); |
|
|
m_playerInput.Value = m_movement.magnitude != 0 || m_jump; |
|
|
m_playerInput.Value = m_movement.magnitude != 0 || m_jump; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
m_characterController.Move(0, false, false); |
|
|
m_characterController.Move(0, false, false); |
|
|
m_playerInput.Value = false ; |
|
|
|
|
|
|
|
|
m_playerInput.Value = false; |
|
|
} |
|
|
} |
|
|
|
|
|
m_animator.SetBool("isMoving", m_playerInput); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnLandHappened() |
|
|
|
|
|
{ |
|
|
|
|
|
m_animator.SetTrigger("Land"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void OnJumpHappened() |
|
|
|
|
|
{ |
|
|
|
|
|
m_animator.SetTrigger("Land"); |
|
|
|
|
|
} |
|
|
|
|
|
public void OnDeath(bool value) |
|
|
|
|
|
{ |
|
|
|
|
|
if (value) |
|
|
|
|
|
m_animator.SetTrigger("Death"); |
|
|
|
|
|
else |
|
|
|
|
|
m_animator.SetTrigger("Respawn"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void OnVictory(bool value) |
|
|
|
|
|
{ |
|
|
|
|
|
if (value) |
|
|
|
|
|
m_animator.SetTrigger("Victory"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|