private void AnimateToState(BGMState state) { if (coroutine_ != null) { coroutine_.Cancel(); coroutine_ = null; } float oldVolume = backgroundMusicAudioSource_.volume; float newVolume = 0.0f; switch (state) { case BGMState.Normal: newVolume = 1.0f; break; case BGMState.Muted: newVolume = kBGMMutedVolume; break; } coroutine_ = CoroutineWrapper.DoEaseFor(kBGMStateTransitionDuration, EaseType.SineEaseInOut, (float p) => { backgroundMusicAudioSource_.volume = Mathf.Lerp(oldVolume, newVolume, p); }); }
private void OnFinishLevel() { ghostsRetreating = 0; state = BGMState.None; audioSrc.loop = false; audioSrc.Stop(); }
void Update() { sfxState = StaticStatesAndVariables.SfxState; bgmState = StaticStatesAndVariables.BgmState; switch (gameState) { case GameStates.Running: UIRunning.Show(); UIPause.Hide(); UIGameOver.Hide(); break; case GameStates.Paused: UIRunning.Hide(); UIPause.Show(); UIGameOver.Hide(); break; case GameStates.GameOver: UIRunning.Hide(); UIPause.Hide(); UIGameOver.Show(); break; } }
public void TransitionBGMState(BGMState i_bgmState) { if (i_bgmState == currentBGMState_) { return; } AudioSource audioSource = GetComponent <AudioSource>(); audioSource.Stop(); switch (i_bgmState) { case BGMState.BGM_DayStart: audioSource.clip = dayStart_; break; case BGMState.BGM_DayMiddle: audioSource.clip = dayMiddle_; break; case BGMState.BGM_DayEnd: audioSource.clip = dayEnd_; break; } currentBGMState_ = i_bgmState; audioSource.Play(); }
private void OnMatchStart() { state = BGMState.MatchStart; currSirenIndex = 0; ghostsRetreating = 0; audioSrc.clip = bgmMatchStart; audioSrc.loop = false; audioSrc.Play(); }
public void SetBGMState(BGMState state) { if (state_ == state) { return; } AnimateToState(state); state_ = state; }
private void OnStartPowerPellet() { if (state != BGMState.PowerPellet && state != BGMState.Retreating) { state = BGMState.PowerPellet; audioSrc.clip = bgmPowerPellet; audioSrc.loop = true; audioSrc.Play(); } }
public void PlayBGM(BGMState state) { switch (state) { case BGMState.Title: bgm.clip = titleBGM; break; case BGMState.Main: bgm.clip = mainBGM; break; } bgm.Play(); }
public AudioSource PlayJingle(AudioClip clip, float volume = 1.0f) { BGMSource.Stop(); PowerupSource.Stop(); JingleSource.clip = clip; JingleSource.volume = volume; JingleSource.Play(); CurrentBGMState = BGMState.Jingle; return(JingleSource); }
private void OnDeath() { state = BGMState.None; audioSrc.Stop(); if (!Game.IsGameOver) { this.Delay(Game.DEATH_STUTTER_TIME + Game.ROUND_START_TIME + Game.RESPAWN_FREEZE_TIME, () => { state = BGMState.Siren; PlaySiren(); }); } }
private void OnRoundStart() { currSirenIndex = 0; ghostsRetreating = 0; if (state != BGMState.MatchStart) { state = BGMState.None; audioSrc.Stop(); } this.Delay(Game.RESPAWN_FREEZE_TIME, () => { state = BGMState.Siren; PlaySiren(); }); }
// Update is called once per frame void Update() { // イントロが終わったらメインループに if (source.isPlaying == false && state == BGMState.Intro) { state = BGMState.Loop; source.Play(); } // 曲が流れててプレイヤーが死んだらリセット if (state != BGMState.None && playerController.State == PlayerState.Dead) { BGMStop(); } }
public void Update() { if (CurrentBGMState == BGMState.BGM) { return; } if (CurrentBGMState == BGMState.Jingle) { if (!JingleSource.isPlaying && AutoplayBGM) { CurrentBGMState = BGMState.BGM; BGMSource.Play(); } } }
private void Start() { audioSrc = GetComponent <AudioSource>(); GameEvents.onMatchStart += OnMatchStart; GameEvents.onRoundStart += OnRoundStart; GameEvents.onDeath += OnDeath; GameEvents.onFinishLevel += OnFinishLevel; GameEvents.onCollect += OnCollect; GameEvents.onEatGhost += OnEatGhost; GameEvents.onStartPowerPellet += OnStartPowerPellet; GameEvents.onEndPowerPellet += OnEndPowerPellet; GameEvents.onGhostEndRetreat += OnGhostEndRetreat; state = BGMState.None; }
public AudioSource PlaySecondaryBGM(AudioClip clip, float volume = 1.0f) { BGMSource.Stop(); JingleSource.Stop(); PowerupSource.clip = clip; PowerupSource.volume = volume; PowerupSource.Play(); CurrentBGMState = BGMState.Powerup; PowerupLooper.LoopStart = 0f; PowerupLooper.LoopEnd = 999f; AutoplaySecondaryBGM = true; return(PowerupSource); }
private void OnEatGhost() { ghostsRetreating++; if (state != BGMState.Retreating) { this.Delay(Game.EAT_GHOST_STUTTER_TIME, () => { if (state != BGMState.None) { state = BGMState.Retreating; audioSrc.clip = bgmRetreating; audioSrc.loop = true; audioSrc.Play(); } }); } }
public AudioSource PlayBGM(AudioClip clip, float volume = 1.0f) { PowerupSource.Stop(); JingleSource.Stop(); BGMSource.clip = clip; BGMSource.volume = volume; BGMSource.Play(); CurrentBGMState = BGMState.BGM; BGMLooper.LoopStart = 0f; BGMLooper.LoopEnd = 999f; AutoplayBGM = true; return(BGMSource); }
private void OnGhostEndRetreat() { ghostsRetreating--; if (ghostsRetreating == 0) { if (Game.IsInPowerPelletMode) { state = BGMState.PowerPellet; audioSrc.clip = bgmPowerPellet; audioSrc.loop = true; audioSrc.Play(); } else { state = BGMState.Siren; PlaySiren(); } } }
private void M_TransitionBGM(AudioClip track) { if (bgmState == BGMState.None) { bgm_A.clip = track; bgm_A.Play(); bgmState = BGMState.A; return; } else { //toggle var isA = bgmState == BGMState.A; bgmState = (isA) ? BGMState.B : BGMState.A; var audioA = (isA) ? bgm_A : bgm_B; var audioB = (isA) ? bgm_B : bgm_A; StartCoroutine(CrossFade(audioA, audioB)); //assign the clip. audioB.clip = track; audioB.volume = 0f; //mute audio audioB.Play(); } }
public BGMStatePause(BGMState _beforeState) { beforeState = _beforeState; }
public override void BeOverrided(BasicResult i_other) { base.BeOverrided(i_other); bgmState_ = (i_other as BGMResult).bgmState_; }
private void OnEndPowerPellet() { state = BGMState.Siren; PlaySiren(); }
// Start is called before the first frame update void Start() { source = transform.GetChild(0).GetComponent <AudioSource>(); playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); state = BGMState.None; }
public void BGMStart() { source.PlayOneShot(intro); state = BGMState.Intro; }
public void BGMStop() { source.Stop(); state = BGMState.None; }