|
@ -34,6 +34,7 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
private LineRenderer m_lineRenderer; |
|
|
private LineRenderer m_lineRenderer; |
|
|
private AudioSource m_audioSource; |
|
|
private AudioSource m_audioSource; |
|
|
|
|
|
private Transform m_OldChildParent; |
|
|
|
|
|
|
|
|
private Vector3 preyeetPosition; |
|
|
private Vector3 preyeetPosition; |
|
|
|
|
|
|
|
@ -46,9 +47,10 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
public void Hold(GameObject child) |
|
|
public void Hold(GameObject child) |
|
|
{ |
|
|
{ |
|
|
m_audioSource.clip = childClips[Random.Range(0,childClips.Length)]; |
|
|
|
|
|
|
|
|
m_audioSource.clip = childClips[Random.Range(0, childClips.Length)]; |
|
|
|
|
|
|
|
|
_child = child; |
|
|
_child = child; |
|
|
|
|
|
m_OldChildParent = _child.transform.parent; |
|
|
_child.transform.parent = parent.transform; |
|
|
_child.transform.parent = parent.transform; |
|
|
_child.GetComponent<YeetHandle>().held = true; |
|
|
_child.GetComponent<YeetHandle>().held = true; |
|
|
_child.GetComponent<YeetHandle>().lastHeld = parent; |
|
|
_child.GetComponent<YeetHandle>().lastHeld = parent; |
|
@ -73,12 +75,12 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
public void Yeet() |
|
|
public void Yeet() |
|
|
{ |
|
|
{ |
|
|
m_audioSource.clip = yeetClips[Random.Range(0,yeetClips.Length)]; |
|
|
|
|
|
|
|
|
m_audioSource.clip = yeetClips[Random.Range(0, yeetClips.Length)]; |
|
|
|
|
|
|
|
|
m_YeetAnimator.SetBool("Yeet", false); |
|
|
m_YeetAnimator.SetBool("Yeet", false); |
|
|
m_YeetAnimator.SetBool("Carry", false); |
|
|
m_YeetAnimator.SetBool("Carry", false); |
|
|
|
|
|
|
|
|
_child.transform.parent = null; |
|
|
|
|
|
|
|
|
_child.transform.parent = m_OldChildParent; |
|
|
_child.transform.rotation = parent.transform.rotation; |
|
|
_child.transform.rotation = parent.transform.rotation; |
|
|
_child.GetComponent<YeetHandle>().held = false; |
|
|
_child.GetComponent<YeetHandle>().held = false; |
|
|
|
|
|
|
|
@ -93,20 +95,20 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
void Start() |
|
|
void Start() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Update() |
|
|
void Update() |
|
|
{ |
|
|
{ |
|
|
switch(yeetState) |
|
|
|
|
|
|
|
|
switch (yeetState) |
|
|
{ |
|
|
{ |
|
|
case YeetState.Yeeting: |
|
|
case YeetState.Yeeting: |
|
|
m_time -= Time.deltaTime; |
|
|
m_time -= Time.deltaTime; |
|
|
|
|
|
|
|
|
if(m_time <= 0f) |
|
|
|
|
|
|
|
|
if (m_time <= 0f) |
|
|
{ |
|
|
{ |
|
|
Debug.Log("YeetController.Update: Yeet finished"); |
|
|
Debug.Log("YeetController.Update: Yeet finished"); |
|
|
yeetState = YeetState.Unheld; |
|
|
|
|
|
|
|
|
yeetState = YeetState.Unheld; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case YeetState.Preyeet: |
|
|
case YeetState.Preyeet: |
|
@ -155,31 +157,36 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider collider) |
|
|
private void OnTriggerEnter(Collider collider) |
|
|
{ |
|
|
{ |
|
|
Debug.Log("PlayerInputController.OnTriggerEnter: arrived"); |
|
|
|
|
|
m_child = collider.gameObject; |
|
|
m_child = collider.gameObject; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void OnTriggerExit(Collider collider) |
|
|
private void OnTriggerExit(Collider collider) |
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
m_child = null; |
|
|
m_child = null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void OnYeet(InputAction.CallbackContext args) |
|
|
private void OnYeet(InputAction.CallbackContext args) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Debug.Log($"Player Yeeting: {args.phase}"); |
|
|
|
|
|
|
|
|
parent = m_body; |
|
|
parent = m_body; |
|
|
switch (yeetState) |
|
|
switch (yeetState) |
|
|
{ |
|
|
{ |
|
|
case YeetController.YeetState.Unheld: |
|
|
case YeetController.YeetState.Unheld: |
|
|
if(m_child) |
|
|
|
|
|
|
|
|
if (m_child/* && args.phase == InputActionPhase.Performed*/) |
|
|
Hold(m_child); |
|
|
Hold(m_child); |
|
|
// Grab nearest baby
|
|
|
// Grab nearest baby
|
|
|
break; |
|
|
break; |
|
|
case YeetState.Preyeet: |
|
|
case YeetState.Preyeet: |
|
|
Yeet(); |
|
|
|
|
|
|
|
|
/*if (args.phase == InputActionPhase.Performed)*/ |
|
|
|
|
|
Yeet(); |
|
|
break; |
|
|
break; |
|
|
case YeetController.YeetState.Held: |
|
|
case YeetController.YeetState.Held: |
|
|
|
|
|
if (args.phase == InputActionPhase.Started) |
|
|
|
|
|
Preyeet(); |
|
|
// Yeet baby
|
|
|
// Yeet baby
|
|
|
Preyeet(); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
case YeetController.YeetState.Yeeting: |
|
|
case YeetController.YeetState.Yeeting: |
|
|
// Cooldown?
|
|
|
// Cooldown?
|
|
@ -189,11 +196,13 @@ public class YeetController : InputBehaviour |
|
|
|
|
|
|
|
|
public override void RegisterInput(PlayerInput playerInput) |
|
|
public override void RegisterInput(PlayerInput playerInput) |
|
|
{ |
|
|
{ |
|
|
playerInput.currentActionMap.FindAction("Yeet").performed += OnYeet; |
|
|
|
|
|
|
|
|
playerInput.currentActionMap.FindAction("Yeet").canceled += OnYeet; |
|
|
|
|
|
playerInput.currentActionMap.FindAction("Yeet").started += OnYeet; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void UnregisterInput(PlayerInput playerInput) |
|
|
public override void UnregisterInput(PlayerInput playerInput) |
|
|
{ |
|
|
{ |
|
|
playerInput.currentActionMap.FindAction("Yeet").performed -= OnYeet; |
|
|
|
|
|
|
|
|
playerInput.currentActionMap.FindAction("Yeet").canceled -= OnYeet; |
|
|
|
|
|
playerInput.currentActionMap.FindAction("Yeet").started -= OnYeet; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |