// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) //{ // //} // OnStateExit is called when a transition ends and the state machine finishes evaluating this state override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!PhotonNetwork.isMasterClient) { return; } if (owner == null) { owner = animator.GetComponent <TDS_Enemy>(); } owner.SetAnimationState((int)EnemyAnimationState.Idle); owner.StartCoroutine(owner.ApplyRecoveryTime(recoveryTime)); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!PhotonNetwork.isMasterClient) { return; } if (!owner) { owner = animator.GetComponent <TDS_Enemy>(); } if (!owner) { return; } if (animator.GetFloat("animationState") != 0) { owner.SetAnimationState(0); } attackingCoroutine = owner.StartCoroutine(owner.CastAttack()); }
private IEnumerator DashingCoroutine(TDS_Enemy _caster) { if (!PhotonNetwork.isMasterClient) { yield break; } _caster.GetComponent <Animator>().ResetTrigger("StopDashing"); Vector3 _originalPosition = _caster.transform.position; Vector3 _endPosition = _originalPosition; if (isDashingForward) { _endPosition += (_caster.IsFacingRight ? Vector3.right : -Vector3.right) * dashingDistance; } else { _endPosition -= (_caster.IsFacingRight ? Vector3.right : -Vector3.right) * dashingDistance; } _endPosition.x = Mathf.Clamp(_endPosition.x, TDS_Camera.Instance.CurrentBounds.XMin + _caster.Agent.Radius, TDS_Camera.Instance.CurrentBounds.XMax - _caster.Agent.Radius); if (_caster is TDS_MightyMan _mightyManIn) { _mightyManIn.IsDashing = true; } while (_caster.IsAttacking && Vector3.Distance(_caster.transform.position, _endPosition) > 0) { _caster.transform.position = Vector3.MoveTowards(_caster.transform.position, _endPosition, Time.deltaTime * dashingSpeed * 10); yield return(null); } if (_caster is TDS_MightyMan _mightyManOut) { _mightyManOut.IsDashing = false; } _caster.SetAnimationState((int)EnemyAnimationState.StopDashing); if (_caster.IsAttacking) { _caster.StopAttack(); } }
/// <summary> /// Stop the spinning Animation /// -> Stop the attack in the animation /// </summary> private void StopSpinning() { caster.SetAnimationState((int)EnemyAnimationState.StopDashing); }