// 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) { fallDistance = 0; animator.SetFloat("FallDistance", fallDistance); audioPlayer.Play(CharacterAudio.AudioType.Falling, true); }
// 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 (character == null) { character = animator.GetComponent <CharacterController2D>(); } audioPlayer.Play(CharacterAudio.AudioType.WallSlide, true); effecter.DoEffect(CharacterEffect.EffectType.WallSlideDust, true); }
// 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) { audioPlayer.Play(CharacterAudio.AudioType.Landing, true); var shakePreset = ProCamera2DShake.Instance.ShakePresets[1]; ProCamera2DShake.Instance.Shake(shakePreset); }
void Movement(float horizontalInput, bool dash) { if (canMove) { // rb.velocity = new Vector2(horizontalInput * speed, rb.velocity.y); // 实现贴图的x轴翻转 ※现在 因为horizontalInput会在update里面乘以速度,所以反转的方法单独设立 Flip() // if (horizontalInput != 0) // { // transform.localScale = new Vector3(horizontalInput, 1, 1); //} if (dash && canDash && !isWallSliding) { //m_Rigidbody2D.AddForce(new Vector2(transform.localScale.x * m_DashForce, 0f)); StartCoroutine(DashCooldown()); } if (isDashing) { rb.velocity = new Vector2(transform.localScale.x * dashForce, 0); audioEffectPlayer.Play(CharacterAudio.AudioType.Dash, true); } else if (isOnGround || airControl) { if (rb.velocity.y < -limitFallSpeed) { rb.velocity = new Vector2(rb.velocity.x, -limitFallSpeed); } // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(horizontalInput, rb.velocity.y); // And then smoothing it out and applying it to the character rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref velocity, m_MovementSmoothing); // If the input is moving the player right and the player is facing left... if (horizontalInput > 0 && !facingRight && !isWallSliding) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (horizontalInput < 0 && facingRight && !isWallSliding) { // ... flip the player. Flip(); } } } }
private void Jump_started(InputAction.CallbackContext context) { if (data.GetDeadStatement()) { return; } if (isSliding && !isOnGround) { StartCoroutine(GrabWallJump()); } else { if (!gameManager.IsEnableInput()) { return; } counter = Time.time; if (jumpCount <= 1) { ++jumpCount; if (jumpCount == 1) { // Set animator animator.SetTrigger(animatorJumpTrigger); // Play audio audioEffectPlayer.Play(CharacterAudio.AudioType.Jump, true); } else if (jumpCount == 2) { animator.SetTrigger(animatorDoubleJumpTrigger); effecter.DoEffect(CharacterEffect.EffectType.DoubleJump, true); // Play audio audioEffectPlayer.Play(CharacterAudio.AudioType.HeroWings, true); } else { return; } // 跳跃键被按下 jumpInput = true; } } }
// 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) { // 相机震动 var shakePreset = ProCamera2DShake.Instance.ShakePresets[2]; ProCamera2DShake.Instance.Shake(shakePreset); if (sound == null) { FindObjectOfType <CharacterAudio>().Play(CharacterAudio.AudioType.HardLanding, true); } else { sound.Play(CharacterAudio.AudioType.HardLanding, true); } }
protected override void Update() { base.Update(); if (PotentialStates.Length > 0 && stackOfStates.GetCurrentState() == null) { State idle = PotentialStates.FirstOrDefault(x => x.StateName == StateNames.IdleState); if (idle) { stackOfStates.PushState(idle); } } //audio queue if (!CharacterAudio) { return; } var AiStateAudio = Audio.FirstOrDefault(x => x.StateName == stackOfStates.GetCurrentState().StateName); if (AiStateAudio.Clips != null && AiStateAudio.Clips.Length > 0) { if (nextAudioQueueTime <= 0.0f) { nextAudioQueueTime = Random.Range(AiStateAudio.MinQueueTime, AiStateAudio.MaxQueueTime); } if (audioQueueTimer >= nextAudioQueueTime && !CharacterAudio.isPlaying) { //pick random audio clip int audioClipIndex = Random.Range(0, AiStateAudio.Clips.Length); CharacterAudio.clip = AiStateAudio.Clips[audioClipIndex]; CharacterAudio.Play(); nextAudioQueueTime = 0.0f; audioQueueTimer = 0.0f; } audioQueueTimer += Time.deltaTime; } }
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { if (sound == null) { FindObjectOfType <CharacterAudio>().Play(CharacterAudio.AudioType.HardLanding, true); } else { sound.Play(CharacterAudio.AudioType.HardLanding, true); } // 相机震动 var shakePreset = ProCamera2DShake.Instance.ShakePresets[0]; ProCamera2DShake.Instance.Shake(shakePreset); GameObject flock = GameObject.Find("Flock"); if (flock != null) { flockParticle = GameObject.Find("Flock").GetComponent <ParticleSystem>(); flockParticle.Play(); } FindObjectOfType <SoulOrb>().DelayShowOrb(2); }
// 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) { audioPlayer.Play(CharacterAudio.AudioType.WallJump, true); }
private IEnumerator Routine_Intarval() { if (_Agent.pathStatus == NavMeshPathStatus.PathInvalid) { yield return(new WaitForSeconds(1.0f)); yield break; } _Agent.isStopped = true; //ランダムに次のモーションを設定 { List <eCharaState> table = new List <eCharaState>(); for (int i = 0; i < _Rate_Idle; ++i) { table.Add(eCharaState.isWaiting); } for (int i = 0; i < _Rate_Unique; ++i) { table.Add(eCharaState.inUnique); } for (int i = 0; i < _Rate_Happy; ++i) { table.Add(eCharaState.inHappy); } for (int i = 0; i < _Rate_Angry; ++i) { table.Add(eCharaState.inAngry); } for (int i = 0; i < _Rate_Sad; ++i) { table.Add(eCharaState.inSad); } for (int i = 0; i < _Rate_Funny; ++i) { table.Add(eCharaState.inFunny); } if (table.Count > 0) { _CharaState = table[Random.Range(0, table.Count)]; } else { _CharaState = eCharaState.isWaiting; } } if (_CharaState == eCharaState.isWaiting) { //待機中 _Animator.SetTrigger(_ID_Idle); float ElapsedSeconds = Random.Range(_MinMoveInterval, _MaxMoveInterval); while (ElapsedSeconds > 0.0f) { ElapsedSeconds -= Time.deltaTime; yield return(null); } } else if (_CharaState == eCharaState.inUnique) { //特殊モーション _Animator.SetTrigger(_ID_Unique); //変わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_UniqueState) { yield return(null); } if (_CharaAudio) { _CharaAudio.Play(CharacterAudio.eAudioType.Unique); } //終わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_UniqueState) { yield return(null); } } else if (_CharaState == eCharaState.inHappy) { //喜モーション _Animator.SetTrigger(_ID_Happy); //変わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_HappyState) { yield return(null); } if (_CharaAudio) { _CharaAudio.Play(CharacterAudio.eAudioType.Happy); } //終わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_HappyState) { yield return(null); } } else if (_CharaState == eCharaState.inAngry) { //怒モーション _Animator.SetTrigger(_ID_Angry); //変わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_AngryState) { yield return(null); } if (_CharaAudio) { _CharaAudio.Play(CharacterAudio.eAudioType.Angry); } //終わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_AngryState) { yield return(null); } } else if (_CharaState == eCharaState.inSad) { //哀モーション _Animator.SetTrigger(_ID_Sad); //変わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_SadState) { yield return(null); } if (_CharaAudio) { _CharaAudio.Play(CharacterAudio.eAudioType.Sad); } //終わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_SadState) { yield return(null); } } else if (_CharaState == eCharaState.inHappy) { //楽モーション _Animator.SetTrigger(_ID_Funny); //変わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_FunnyState) { yield return(null); } if (_CharaAudio) { _CharaAudio.Play(CharacterAudio.eAudioType.Happy); } //終わるまで待機 while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_FunnyState) { yield return(null); } } _MoveState = eMoveState.isMoving; }
// 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) { audioPlayer.Play(CharacterAudio.AudioType.FoorstepsWalk, true); effecter.DoEffect(CharacterEffect.EffectType.RoarDustLil, true); }