Exemple #1
0
        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);
            });
        }
Exemple #2
0
 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();
    }
Exemple #5
0
 private void OnMatchStart()
 {
     state            = BGMState.MatchStart;
     currSirenIndex   = 0;
     ghostsRetreating = 0;
     audioSrc.clip    = bgmMatchStart;
     audioSrc.loop    = false;
     audioSrc.Play();
 }
Exemple #6
0
        public void SetBGMState(BGMState state)
        {
            if (state_ == state)
            {
                return;
            }

            AnimateToState(state);
            state_ = state;
        }
Exemple #7
0
 private void OnStartPowerPellet()
 {
     if (state != BGMState.PowerPellet && state != BGMState.Retreating)
     {
         state         = BGMState.PowerPellet;
         audioSrc.clip = bgmPowerPellet;
         audioSrc.loop = true;
         audioSrc.Play();
     }
 }
Exemple #8
0
        public void PlayBGM(BGMState state)
        {
            switch (state)
            {
            case BGMState.Title: bgm.clip = titleBGM; break;

            case BGMState.Main: bgm.clip = mainBGM; break;
            }

            bgm.Play();
        }
Exemple #9
0
        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);
        }
Exemple #10
0
 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();
         });
     }
 }
Exemple #11
0
 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();
     });
 }
Exemple #12
0
    // 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();
        }
    }
Exemple #13
0
 public void Update()
 {
     if (CurrentBGMState == BGMState.BGM)
     {
         return;
     }
     if (CurrentBGMState == BGMState.Jingle)
     {
         if (!JingleSource.isPlaying && AutoplayBGM)
         {
             CurrentBGMState = BGMState.BGM;
             BGMSource.Play();
         }
     }
 }
Exemple #14
0
        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;
        }
Exemple #15
0
        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);
        }
Exemple #16
0
 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();
             }
         });
     }
 }
Exemple #17
0
        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);
        }
Exemple #18
0
 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();
         }
     }
 }
Exemple #19
0
 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();
     }
 }
Exemple #20
0
 public BGMStatePause(BGMState _beforeState)
 {
     beforeState = _beforeState;
 }
Exemple #21
0
    public override void BeOverrided(BasicResult i_other)
    {
        base.BeOverrided(i_other);

        bgmState_ = (i_other as BGMResult).bgmState_;
    }
Exemple #22
0
 private void OnEndPowerPellet()
 {
     state = BGMState.Siren;
     PlaySiren();
 }
Exemple #23
0
 // 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;
 }
Exemple #24
0
 public void BGMStart()
 {
     source.PlayOneShot(intro);
     state = BGMState.Intro;
 }
Exemple #25
0
 public void BGMStop()
 {
     source.Stop();
     state = BGMState.None;
 }