AnimationClip GetAnimClipFromMovePos(EPlayerMovementPosition _movePos) { switch (_movePos) { case EPlayerMovementPosition.LowerLeft: return(LowerLeftClip); case EPlayerMovementPosition.Left: return(LeftClip); case EPlayerMovementPosition.UpperLeft: return(UpperLeftClip); case EPlayerMovementPosition.LowerRight: return(LowerRightClip); case EPlayerMovementPosition.Right: return(RightClip); case EPlayerMovementPosition.UpperRight: return(UpperRightClip); default: return(null); } }
string GetAnimTriggerFromMovePos(EPlayerMovementPosition _movePos) { switch (_movePos) { case EPlayerMovementPosition.LowerLeft: return(LowerLeftTrigger); case EPlayerMovementPosition.Left: return(LeftTrigger); case EPlayerMovementPosition.UpperLeft: return(UpperLeftTrigger); case EPlayerMovementPosition.LowerRight: return(LowerRightTrigger); case EPlayerMovementPosition.Right: return(RightTrigger); case EPlayerMovementPosition.UpperRight: return(UpperRightTrigger); default: return(null); } }
public void CallOnPlayerMoveEnd(EPlayerMovementPosition _movePos) { _bPlayerIsMoving = false; if (OnPlayerMoveEnd != null) { OnPlayerMoveEnd(_movePos); } }
public void CallOnPlayerMoveStart(EPlayerMovementPosition _movePos) { _bPlayerIsMoving = true; if (OnPlayerMoveStart != null) { OnPlayerMoveStart(_movePos); } }
void StartPlayingAnimation(EPlayerMovementPosition _movePos) { if (bHasAnimClips == false) { Debug.LogError("No Animation Clips On Player Animations"); return; } myAnimator.SetBool(IsMovingAnimParameter, true); StartCoroutine(PlayAnimationCoroutine(_movePos)); }
IEnumerator PlayAnimationCoroutine(EPlayerMovementPosition _movePos) { var _clip = GetAnimClipFromMovePos(_movePos); var _trigger = GetAnimTriggerFromMovePos(_movePos); if (_clip != null) { myAnimator.SetTrigger(_trigger); yield return(new WaitForSeconds( Mathf.Min(_clip.length, longestAnimationTimeInSeconds))); } myEventHandler.CallOnPlayerMoveEnd(_movePos); }
void OnPlayerEndMove(EPlayerMovementPosition _movePos) { switch (_movePos) { case EPlayerMovementPosition.LowerLeft: this.transform.position = this.transform.position + new Vector3(-MovementSpeed, -MovementSpeed, 0); break; case EPlayerMovementPosition.Left: this.transform.position = this.transform.position + new Vector3(-MovementSpeed, 0, 0); break; case EPlayerMovementPosition.UpperLeft: this.transform.position = this.transform.position + new Vector3(-MovementSpeed, MovementSpeed, 0); break; case EPlayerMovementPosition.LowerRight: this.transform.position = this.transform.position + new Vector3(MovementSpeed, -MovementSpeed, 0); break; case EPlayerMovementPosition.Right: this.transform.position = this.transform.position + new Vector3(MovementSpeed, 0, 0); break; case EPlayerMovementPosition.UpperRight: this.transform.position = this.transform.position + new Vector3(MovementSpeed, MovementSpeed, 0); break; default: break; } }
void OnStopMoving(EPlayerMovementPosition _movePos) { myAnimator.SetBool(IsMovingAnimParameter, false); myAnimator.SetTrigger(IdleTrigger); }
void OnPlayerMove(EPlayerMovementPosition _movePos) { myAudioSource.clip = JumpSound; myAudioSource.Play(); }