private void Go() { if (m_destroyed) { return; } BuildBgmList(); if (!m_source) { return; } m_source.enabled = true; m_source.volume = 0; m_source.Play(); m_realVolume = fadeInVolume; var v = m_realVolume; #if UNITY_EDITOR if (Game.started) #endif v *= SettingsManager.realBgmVolume; m_tweener = m_source.DOFade(v, fadeInDuration).SetEase(Ease.InExpo).OnUpdate(TweenUpdate); }
public void Play(string name, bool isTween = false) { if (!_clipDic.ContainsKey(name)) { _clipDic.Add(name, Resources.Load <AudioClip>(_audioPath + name)); } AudioClip clip; if (_clipDic.TryGetValue(name, out clip)) { Source.clip = clip; Source.Play(); if (isTween) { Source.volume = 0; Source.DOFade(1, 0.5f); } else { Source.volume = 1; } } }
void Start() { blackFade.DOFade(0f, 1.2f); menuMusic.volume = 0; menuMusic.DOFade(musicVolume, 1.2f); creditsMusic.volume = 0; Cursor.visible = true; hatOrderForThisRun = new GameObject[hatPrefabs.Length]; for (int i = 0; i < hatPrefabs.Length; i++) { hatOrderForThisRun[i] = hatPrefabs[i]; } hatOrderForThisRun.Shuffle(); scrollSpeed = 0; cam = Camera.main; if (lockFPS) { Application.targetFrameRate = fps; timeBetweenNodes = 1f / fps; } meterText.enabled = false; Pause(); }
public void PlayRandomBgmNRest(List <string> names) { m_CurrentBgmNRestNames = names; if (!m_BgmRestPlaying) { m_BgmRestPausing = false; m_TrackBgmNRest.Stop(); m_BgmRestPlaying = true; int idx = Random.Range(0, m_CurrentBgmNRestNames.Count); m_CurrentBgmNRestName = m_CurrentBgmNRestNames[idx]; StartCoroutine("CheckRandomBgmStatus"); } else if (m_BgmRestPlaying && m_BgmRestPausing) { if (!m_BgmRestResting) { m_TrackBgmNRest.Play(); } m_BgmRestPausing = false; } m_TrackBgmNRest.volume = 0; if (m_Twr != null) { m_Twr.Kill(); } //m_Twr = HOTween.To (m_TrackBgmNRest, 0.2f, new TweenParms () // .Prop ("volume", m_CurrentBgmVol / 100.0f) // .Ease (EaseType.Linear) // ); m_Twr = m_TrackBgmNRest.DOFade(m_CurrentBgmVol / 100.0f, 0.2f); }
public void On() { if (m_turnOffSeq != null) { m_turnOffSeq.Kill(); m_turnOffSeq = null; } m_body.DOShakePosition(1.0f, 0.1f, 20, 90, false, false).SetLoops(-1); m_turnOnSeq = DOTween.Sequence(); m_turnOnSeq.AppendCallback(() => { m_audioSource1.volume = 1.0f; m_audioSource1.clip = m_clips[0]; m_audioSource1.Play(); }); m_turnOnSeq.AppendInterval(m_clips[0].length - 1.0f); m_turnOnSeq.AppendCallback(() => { m_audioSource2.clip = m_clips[1]; m_audioSource2.volume = 0.0f; m_audioSource2.Play(); m_audioSource2.loop = true; }).Append(m_audioSource2.DOFade(1.0f, 1.0f)); }
public void SetBackground(AudioId id) { var items = _audioLibrary.items.FindAll((obj) => obj.id == id); if (items.Count > 0) { var item = items[0]; var clip = item.clip; if (!_backgroundSource.isPlaying) { _backgroundSource.clip = clip; _backgroundSource.volume = item.volume; _backgroundSource.Play(); } else if (_backgroundSource.isPlaying && _backgroundSource.clip != clip) { DOTween.Kill(_backgroundSource); _backgroundSource.DOFade(0f, FADE_DURATION).OnComplete(() => { _backgroundSource.clip = clip; _backgroundSource.Play(); _backgroundSource.DOFade(item.volume, FADE_DURATION); }); } } else { StopBackground(); Log.WarningFormat("[AudioServiceComponent] Could not find audio clip with id={0}", id); } }
void Begin() { flag = false; switch (a) { case 0: DOTween.Sequence().Append(logo.DOMoveY(3, 1f)) .Append(titlebgm.DOFade(0, 1.5f)).AppendCallback(() => { titlebgm.gameObject.SetActive(false); }) .Insert(1f, a1.DOFade(0, 1f)) .Insert(1f, a2.DOFade(0, 1f)).Insert(1f, a3.DOFade(0, 1f)) .Insert(1f, arrow.gameObject.GetComponent <SpriteRenderer>().DOFade(0, 1f)) .AppendCallback(() => { gameObject.SetActive(false); story.SetActive(true); }); break; case 1: DOTween.Sequence().Append(logo.DOMoveY(3, 1f)) .Append(titlebgm.DOFade(0, 2f)).AppendCallback(() => { titlebgm.gameObject.SetActive(false); }) .Insert(1f, a1.DOFade(0, 2f)) .Insert(1f, a2.DOFade(0, 2f)).Insert(1f, a3.DOFade(0, 2f)) .Insert(1f, arrow.gameObject.GetComponent <SpriteRenderer>().DOFade(0, 2f)) .AppendCallback(() => { gameObject.SetActive(false); SceneManager.LoadScene("levelEditor"); Debug.Log("Continue Game;"); }); break; case 2: Application.Quit(); break; } }
public void PlayCrowdEffect(CrowdEffects crowdEffectID) { switch (crowdEffectID) { case CrowdEffects.CrowdStart: audioCrowdStart.volume = 1; audioCrowdStart.Play(); audioCrowdStart.DOFade(0f, encounterConstants.CrowdStartDuration).SetDelay(encounterConstants.CrowdStartDelay); break; case CrowdEffects.CrowdIdle: audioCrowdBG.volume = 0; audioCrowdBG.Play(); audioCrowdBG.DOFade(1f, encounterConstants.CrowdSoundTransition); audioCrowdSet.DOFade(0f, encounterConstants.CrowdSoundTransition).OnComplete(() => { audioCrowdSet.Stop(); }); break; case CrowdEffects.CrowdSet: audioCrowdSet.volume = 0; audioCrowdSet.Play(); audioCrowdSet.DOFade(1f, encounterConstants.CrowdSoundTransition); audioCrowdBG.DOFade(0f, encounterConstants.CrowdSoundTransition).OnComplete(() => { audioCrowdBG.Stop(); }); break; } }
/// <summary> /// Disables the sound. /// </summary> public void DisableSound(bool IsUseAnimation = true) { if (SoundPlayer != null) { SoundPlayer.DOKill(); if (IsUseAnimation) { SoundPlayer.DOFade(0, Contains.DurationFade).OnComplete(() => { SoundPlayer.mute = true; }); ; } else { SoundPlayer.mute = true; SoundPlayer.volume = 0; } } // TODO: find all sound helper. var soundFinds = GameObject.FindObjectsOfType <SoundHelper> (); for (int i = 0; i < soundFinds.Length; i++) { // TODO: update the status of sound. soundFinds [i].UpdateStatusSound(); } }
void SwitchMusic(int nextFocus) { MusicUIItem currentItem = musicUIItemList[focusIndex]; MusicUIItem nextItem = musicUIItemList[nextFocus]; float updatedGroupPosition = -nextFocus * (itemWidth + itemSpacing); musicUIGroup.transform.DOPause(); musicUIGroup.transform.DOLocalMoveX(updatedGroupPosition, swipeTransitionDuration, true).SetEase(Ease.OutQuad).OnComplete(() => { Music nextMusic = nextItem.music; if (playMusicCoroutine != null) { StopCoroutine(playMusicCoroutine); } playMusicCoroutine = StartCoroutine(LoadAsyncAndPlay(nextMusic)); bannerBackground.sprite = nextItem.albumImage.sprite; bannerBackground.DOFade(backgroundAlpha, swipeTransitionDuration).SetEase(Ease.OutQuad); }); currentItem.transform.DOScale(itemMinScale, swipeTransitionDuration).SetEase(Ease.OutQuad); nextItem.transform.DOScale(itemMaxScale, swipeTransitionDuration).SetEase(Ease.OutQuad); currentItem.textGroup.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad); nextItem.textGroup.DOFade(1, swipeTransitionDuration).SetEase(Ease.OutQuad); audio.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad); bannerBackground.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad); focusIndex = nextFocus; }
public void PlayerExitsArea() { startAudio.DOFade(0, 2f); gameAudio.Play(); gameAudio.DOFade(1, 2f); ActivateSpawners(); }
/// <summary> /// Players the music. /// </summary> /// <param name="musicIndex">Music index.</param> /// <param name="IsLoop">If set to <c>true</c> is loop.</param> /// <param name="IsReset">if set to <c>true</c> the music player will restart play the sound anyway.</c></param> public void PlayerMusic(Enums.MusicIndex musicIndex, bool IsLoop = false, bool IsReset = true) { AudioClip audioFound; MusicPlayer.DOComplete(true); musicLibrary.TryGetValue((int)musicIndex, out audioFound); // TODO: The condition to reset. if (object.ReferenceEquals(MusicPlayer.clip, null) || IsReset || !object.ReferenceEquals(audioFound, null) && audioFound.name != MusicPlayer.clip.name) { // TODO: animation fade MusicPlayer.DOFade(0, Contains.DurationFade).OnComplete(() => { if (!object.ReferenceEquals(audioFound, null)) { if (musicLibrary.TryGetValue((int)musicIndex, out audioFound)) { MusicPlayer.clip = audioFound; MusicPlayer.Play(); MusicPlayer.loop = IsLoop; } } MusicPlayer.DOFade(0.7f, Contains.DurationFade); }); } }
void _playSound(string audioclipname, bool isLoop, float SoundVolume = 1, float fadeInSec = 1, float pitch = 1) { AudioClip ac = TryGetAudioClip(audioclipname); if (audioSource.isPlaying) { Debug.Assert(fadeInAudioSource != null); fadeInAudioSource.clip = ac; fadeInAudioSource.loop = isLoop; fadeInAudioSource.pitch = pitch; fadeInAudioSource.Play(); fadeInAudioSource.DOFade(SoundVolume, fadeInSec).OnComplete(OnFadeInDone); audioSource.DOFade(0, fadeInSec); // Debug.Log("[AudioManagerBase][_playSound] : fadeIn : " + fadeInAudioSource.clip.name + " , fadeOut : " + audioSource.clip.name); } else { audioSource.clip = ac; audioSource.loop = isLoop; audioSource.pitch = pitch; audioSource.Play(); audioSource.volume = 0; audioSource.DOFade(SoundVolume, fadeInSec); // Debug.Log("[AudioManagerBase][_playSound] : fadeIn : " + audioSource.clip.name); } }
void DeactivateMainMenu() { if (Input.GetKeyDown(KeyCode.Return) && !playingGame) { playingGame = true; player1.isAlive = true; player2.enabled = true; clouds.SetActive(true); menuAudio.DOFade(0, 2); titleScreen.DOFade(0.0f, 1.5f); startAudio.Play(); startAudio.DOFade(1, 2); player1.playerAnimator.SetTrigger("PlayerWakeUp"); player1.playerAnimator.SetTrigger("PlayerRun"); Camera.main.GetComponent <CinemachineBrain>().enabled = true; foreach (GameObject i in uis) { i.SetActive(true); } } }
private IEnumerator GameOver() { hasGameEnded = true; if (onGameEndNow != null) { onGameEndNow(); } yield return(new WaitForSeconds(2)); if (onGameEnd != null) { onGameEnd(); } for (int i = 0; i < thingsToDisable.Length; i++) { thingsToDisable[i].SetActive(false); } mainCamera.cullingMask = cameraLayerMask; mainCamera.DOOrthoSize(65f, 2f); xrayCamera.DOOrthoSize(65f, 2f); ShowGameOverOverlay(); mainCamera.DOColor(new Color(0.071f, 0.041f, 0.025f), 2f); windAudioSource.DOFade(0f, 2f); musicAudioSource.DOFade(0f, 2f); musicElevatorAudioSource.Play(); musicElevatorAudioSource.DOFade(0.02f, 2f); }
/// <summary> /// 用于按钮 /// </summary> public void Dance() { if (dancing) { //动画 anim.SetBool("Dancing", false); //音乐 audioSource.DOFade(0, 2f); //状态 text.text = "停止跳舞"; dancing = false; } else { //动画 anim.SetBool("Dancing", true); //音乐 audioSource.Stop(); audioSource.DOFade(1, 2f); audioSource.Play(); //状态 text.text = "开始跳舞"; dancing = true; } }
/// <summary> /// Módulo encargado de iniciar la secuencia de GameOver /// </summary> /// <param name="characterName">Nombre del personaje</param> public void StartSequenceGameOver (string characterName) { this.gameObject.SetActive(true); endGameText.text = characterName + " is dead"; GetComponent<Image>().DOColor(gameOverColor,fadeOutTime); musicSource.DOFade(0, fadeOutTime); }
void Thrust() { if (Input.GetKey(KeyCode.Space)) { if (currentFuel > 0) { rigidBody.AddRelativeForce(Vector3.up * thrustAmount); if (!engineSound.isPlaying) { engineSound.Play(); } // TODO: figure out why this is popping every ~loop engineSound.DOFade(1, 1); currentFuel -= fuelBurnPerFrame; } else { Debug.LogFormat("Current fuel is less than 0 : {0}", currentFuel); } } else { engineSound.DOFade(0, 1f); } }
// Update is called once per frame void Update() { if (!audio.isPlaying && GameManager._instance.gameState == GameState.inGame) { audio.volume = 0; audio.loop = false; AudioClip clip = bgms[Random.Range(0, bgms.Length)]; audio.clip = clip; audio.Play(); audio.DOFade(1, 2f); } if (GameManager._instance.gameState == GameState.end && audio.volume >= 0.1f) { audio.DOFade(0, 2); } if (GameManager._instance.gameState == GameState.menu && !audio.isPlaying) { audio.volume = 0; audio.loop = true; audio.clip = menuBgm; audio.Play(); audio.DOFade(1, 2f); } }
private void FixedUpdate() { // if (_shiftPressed) return; if (GetRotationVector().magnitude > 0.4f) { if (ApplicationManager.instance._gameStarted == false) { ApplicationManager.instance.StartGame(); } if (_audioSource.volume == 0) { _audioSource.DOFade(_audioEffectMaxVolume, _audioFadeTimeStart); } transform.RotateTowardsVector(GetRotationVector(), _rotSpeed, _rotOffset); tempVec = (transform.forward * _moveSpeed * Time.fixedDeltaTime); _rb.velocity = new Vector3(tempVec.x, _rb.velocity.y, tempVec.z); if (_rb.velocity.magnitude >= _maxVelocity) { _rb.velocity = _rb.velocity * _maxVelocity; } } else if (_audioSource.volume != 0) { _audioSource.DOFade(0.0f, _audioFadeTimeEnd); } }
void FootingSFX(PlayerState state) { if (state.Equals(PlayerState.still)) { footing.DOFade(0, 0.1f); } else if (state.Equals(PlayerState.walking)) { footing.clip = walk; } else if (state.Equals(PlayerState.sprinting)) { footing.clip = sprint; } else if (state.Equals(PlayerState.crouching) & (!hrzMov.Equals(0) || !vrtMov.Equals(0))) { footing.clip = crouch; } if (!state.Equals(PlayerState.still)) { AudioManager.manager.UseSound(footing); footing.DOFade(0, 0.3f).OnComplete(() => footing.DOFade(1, 0.3f)); } else { AudioManager.manager.RemoveSound(footing); } }
void Move() { if (Input.GetAxis("Horizontal") == 0f && Input.GetAxis("Vertical") == 0f) { if (aud.volume > 0.99999f) { aud.DOFade(0f, 0.5f); } } else { /* if((0 < Input.GetAxis("Horizontal") && 0 > Input.GetAxis("Horizontal")) || (0< Input.GetAxis("Vertical") && 0 > Input.GetAxis("Vertical"))){*/ if (aud.volume < 0.001f) { aud.DOFade(1f, 0.5f); } } float x = Input.GetAxis("Horizontal") * Time.deltaTime * speed; float y = Input.GetAxis("Vertical") * Time.deltaTime * speed; transform.Translate(x, y, 0); Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); pos.x = Mathf.Clamp01(pos.x); pos.y = Mathf.Clamp01(pos.y); transform.position = Camera.main.ViewportToWorldPoint(pos); }
IEnumerator StopMenuSongCo() { songMenu.DOFade(0, 1); yield return(new WaitForSeconds(1)); songMenu.Stop(); }
private void FadeInOut() { if (m_triggered) { var v = m_realVolume * SettingsManager.realBgmVolume; if (m_tweener != null) { m_tweener.Kill(); } m_source.enabled = true; m_source.volume = 0; m_source.Play(); m_tweener = m_source.DOFade(v, fadeInDuration).SetEase(Ease.InExpo).OnUpdate(TweenUpdate).OnComplete(TweenComplete); return; } if (m_tweener != null) { m_tweener.Kill(); } m_tweener = m_source.DOFade(0, fadeOutDuration).SetEase(Ease.OutExpo).OnComplete(TweenComplete); }
private void Start() { background.canvasRenderer.SetAlpha(0); pressedEnter = false; screenLight.DOIntensity(1, 5); menuMusic.DOFade(.2f, 8); }
void OnLevelWasLoaded(int lvl) { if (lvl == 0 && Instance == this) { audioSource_music.DOFade(1, 2f); audioSource_sounds.DOFade(1, 2f); } }
public void PlayAtmos(string idHistory) { atmosAudioSource.clip = audioClips.Find(a => a.name == idHistory); atmosAudioSource.loop = true; atmosAudioSource.volume = 0; atmosAudioSource.DOFade(1, GameData.ANIMATION_TIME_DEFAULT * 4); atmosAudioSource.Play(); }
void Start() { RegisterEvnets(); AudioSource.volume = 0; AudioSource.clip = AmbientTrack; AudioSource.Play(); AudioSource.DOFade(1, 1f); }
private IEnumerator ChangeSound() { yield return(new WaitForSeconds(fadeDuration)); source.clip = music; source.Play(); source.DOFade(1, fadeDuration); }
void SwitchBGM(AudioClip to, bool randomPlay, float duration = -1f) { if (duration < 0) { duration = bgmFadeTime; } if (bgmSource == null) { bgmSource = gameObject.AddComponent <AudioSource> (); bgmSource.loop = true; bgmSource.volume = 0.5f; bgmSource.spatialBlend = 0f; bgmSource.clip = defaultBGM; bgmSource.Play(); } if (bgmSwitchableSource == null) { bgmSwitchableSource = gameObject.AddComponent <AudioSource> (); bgmSwitchableSource.loop = true; bgmSwitchableSource.volume = 0.5f; bgmSwitchableSource.spatialBlend = 0f; } if (bgmSource != null) { if (to != defaultBGM) { bgmSource.DOFade(0.2f, duration); } else { bgmSource.DOFade(0.5f, duration); } } if (bgmSwitchableSource != null) { if (to != defaultBGM) { bgmSwitchableSource.DOFade(0, duration).OnComplete(delegate { bgmSwitchableSource.clip = to; if (randomPlay) { bgmSwitchableSource.time = Random.Range(0, bgmSwitchableSource.clip.length); } bgmSwitchableSource.Play(); bgmSwitchableSource.DOFade(0.5f, duration); }); } else { bgmSwitchableSource.DOFade(0, duration).OnComplete(delegate { bgmSwitchableSource.clip = null; }); } } }