コード例 #1
0
    void FixedUpdate()
    {
        if (BuffManager.playerMovementDebuff)
        {
            BuffManager.playerMovementDebuff = false;
            movementSpeed              = movementSpeed * 0.75f;
            BuffManager.debuffCounter += 1;
        }
        if (BuffManager.movementBuff)
        {
            BuffManager.movementBuff = false;
            movementSpeed            = movementSpeed * 1.2f;
            BuffManager.buffCounter += 1;
        }
        float moveVertical   = Input.GetAxis("Vertical");
        float moveHorizontal = Input.GetAxis("Horizontal");

        rigidBody.velocity = new Vector3(moveHorizontal * movementSpeed, moveVertical * movementSpeed, 0);
        if (rigidBody.velocity.x == 0 && rigidBody.velocity.y == 0)
        {
            audioSrc.FadeOut(2f);
        }
        else
        {
            audioSrc.volume = 1f;
            audioSrc.mute   = false;
        }
    }
コード例 #2
0
 public void PassToCombatTrack()
 {
     combatTrack.FadeIn(.5f, 1f);
     idleTrack.FadeOut(.5f);
     combatTrack.Play();
     PlayingIdleTrack   = false;
     PlayingCombatTrack = true;
 }
コード例 #3
0
ファイル: AgentAudio.cs プロジェクト: kikinna/Brndy
    private void StopSound(AudioSource audioSource, float fadeDuration = 0f)
    {
        if (audioSource == null)
        {
            return;
        }

        audioSource.FadeOut(fadeDuration, this);
    }
コード例 #4
0
 private void StopWithFadeOut()
 {
     //if (rocketSound.isPlaying)
     //{
     rocketSound.FadeOut(0.1f);
     //rocketSound.Stop();
     rocketSound.loop = false;
     //}
 }
コード例 #5
0
        /// <summary>
        /// Stop the current track.
        /// Will always be run on active instance, so it is safe to use in UnityEvents even if inactive.
        /// </summary>
        public void Stop()
        {
            if (inst != this)
            {
                inst.Stop();
                return;
            }

            if (!currentSource)
            {
                return;
            }

            if (fadeOut)
            {
                currentSource.FadeOut();
            }
            else
            {
                currentSource.Stop();
            }
            currentSource = null;
        }
コード例 #6
0
ファイル: AudioManager.cs プロジェクト: hetima333/Slimenator
 /// <summary>
 /// BGMのフェードアウト
 /// </summary>
 /// <param name="fadeTime">fade time</param>
 public void FadeOutBGM(float fadeTime, float endVolume = 0.0f)
 {
     StartCoroutine(_bgmSource.FadeOut(fadeTime, endVolume));
 }
コード例 #7
0
    private void Update()
    {
        if (raycastAimPlaneTransform != null)
        {
            raycastAimPlaneTransform.position = transform.position + initialRaycastAimPlanePosOffset;
        }

        if (!waitingForFallToGroundCheck)
        {
            CheckForGround();
        }
        else
        {
            if (rb.velocity.y < 0.0f)
            {
                waitingForFallToGroundCheck = false;
                isJumping = false;
            }
        }

        if (isGrounded)
        {
            if (!rollingAudioSource.FadeOutIsActive())
            {
                float volumeInterpValue = Mathf.Clamp(
                    rb.velocity.magnitude / maxSpeedForRollVolume,
                    0.0f, 1.0f);
                rollingAudioSource.volume = Mathf.Lerp(0.0f, 0.3f, volumeInterpValue);

                if (!rollingAudioSource.isPlaying)
                {
                    rollingAudioSource.Play();
                }
            }
        }
        else
        {
            if (rollingAudioSource.isPlaying && !rollingAudioSource.FadeOutIsActive())
            {
                rollingAudioSource.FadeOut();
            }
        }

        /*if (inputIsEnabled) {
         *              if (isGrounded) {
         *                      if (Input.GetButtonDown("Jump")) {
         *                              GeneralAudioPool.Instance.PlaySound(jumpAudioClip, 0.25f, Random.Range(0.9f, 1.1f));
         *
         *                              rb.AddForce(Vector3.up * initialJumpLaunchForce, ForceMode.Impulse);
         *                              waitingForFallToGroundCheck = true;
         *                              isGrounded = false;
         *
         *                              jumpActiveTimer = 0.0f;
         *                              isJumping = true;
         *                      }
         *              }
         *              if (Input.GetButtonUp("Jump")) {
         *                      isJumping = false;
         *              }
         *      }*/

        if (transform.position.y < yPosResetCutoff)
        {
            transform.position = initialPos;
            rb.velocity        = Vector3.zero;
            rb.angularVelocity = Vector3.zero;
        }

        if (Application.isEditor && !sceneIsLoading && Input.GetKeyDown(KeyCode.BackQuote))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            sceneIsLoading = true;
        }
    }
 public static IEnumerator FadeOutAsCoroutine(this AudioSource self, float duration)
 {
     self.FadeOut(duration);
     yield return(new WaitForSeconds(duration));
 }