示例#1
0
 public void PauseAudio()
 {
     if (!RobotConnector.IsConnected)
     {
         return;
     }
     if (_audioSource != null)
     {
         _audioSource.Pause();
     }
 }
示例#2
0
        /// <summary>Pauses the timer</summary>
        public void Pause()
        {
            if (!Validate("MinigamesUITimer"))
            {
                return;
            }

            if (alarmSfxSource != null)
            {
                alarmSfxSource.Pause();
            }
            timerTween.Pause();
        }
示例#3
0
文件: TxKitEars.cs 项目: mrayy/TxKit
 public void PauseAudio()
 {
     if (!RobotConnector.IsConnected)
     {
         return;
     }
     //if (_audioSource != null)
     //	_audioSource.SetAudioVolume (0);
     if (_audioSource != null)
     {
         _audioSource.Pause();
     }
     //if(RobotConnector.Connector!=null)
     //	RobotConnector.Connector.SendData("PauseAudio","",false,true);
 }
示例#4
0
        private void CheckSongPause()
        {
            bool isMenuOpen = UI.PauseMenu.I.IsMenuOpen;

            if (loopingSource != null && loopingSource.IsPlaying && isMenuOpen)
            {
                float currentTime = loopingSource.Position;
                lastSongTime = currentTime;
                loopingSource.Pause();
                songPaused = true;
                Debug.Log("SONG PAUSING");
            }
            else if (loopingSource != null && !loopingSource.IsPlaying && !isMenuOpen && songPaused)
            {
                loopingSource.Stop();
                loopingSource.Play();
                loopingSource.Position = lastSongTime;
                songPaused             = false;
                Debug.Log("SONG RESUMING");
            }
        }
示例#5
0
        void Update()
        {
            for (int i = 0; i < bars.Count; ++i)
            {
                var bar = bars[i];

                int completedPairId = (completedBars / 2) * 2;

                bool show = (i >= completedPairId) && (i < completedPairId + 2);

                bar.Show(show);
            }

            bool isMenuOpen = UI.PauseMenu.I.IsMenuOpen;

            songInsideAWord = false;
            if (playingSong)
            {
                if (songSource != null && songSource.IsPlaying)
                {
                    float currentTime = songSource.Position;
                    lastSongTime = currentTime;

                    if (isMenuOpen)
                    {
                        songSource.Pause();
                        return;
                    }

                    var songWords = currentBarSong.lines;

                    var songStart = songWords[0].start;
                    if (currentTime > songStart - 2)
                    {
                        if (!songStarted && activeBar == null)
                        {
                            SetActiveBar(bars[0]);
                        }

                        songStarted = true;
                    }

                    if (songStarted)
                    {
                        for (int i = 0; i < songWords.Count; ++i)
                        {
                            var currentSongWord = songWords[i];
                            var currentBarWord  = currentBarWords[i];

                            var timeStart = currentSongWord.start;
                            var timeEnd   = currentSongWord.end;

                            // Move to currentBarWord
                            while (activeBar != null && activeBar.Id < currentBarWord.barId)
                            {
                                SwitchToNextBar();
                            }

                            if (currentTime < timeStart)
                            {
                                if (activeBar != null && activeBar.Id == currentBarWord.barId)
                                {
                                    activeBar.currentTarget = 0;
                                }
                                break;
                            }
                            else if (currentTime > timeEnd)
                            {
                                barsCompleted = (i == songWords.Count - 1);

                                if (activeBar != null && activeBar.Id == currentBarWord.barId)
                                {
                                    if (i == 3 || i == 7) // only at specific rows   // TODO: find a better way to stop the music halfway
                                    {
                                        ((ReadingGameGame)(ReadingGameGame.I)).hiddenText.gameObject.SetActive(false);
                                        bars[0].transform.parent.gameObject.SetActive(false);
                                        //KeeperManager.I.PlayDialogue(LocalizationDataId.Song_alphabet_SingWithMe, false, keeperMode:KeeperMode.SubtitlesOnly);
                                    }
                                }
                            }
                            else
                            {
                                // Show bar
                                if (!bars[0].transform.parent.gameObject.activeInHierarchy)
                                {
                                    ((ReadingGameGame)(ReadingGameGame.I)).hiddenText.gameObject.SetActive(true);
                                    bars[0].transform.parent.gameObject.SetActive(true);
                                    KeeperManager.I.CloseSubtitles();
                                }

                                float tInWord = (currentTime - timeStart) / (timeEnd - timeStart);

                                float t = Mathf.Lerp(currentBarWord.start, currentBarWord.end, tInWord);
                                if (activeBar != null)
                                {
                                    activeBar.currentTarget = t;
                                }
                                songInsideAWord = true;

                                break;
                            }
                        }
                    }

                    if (barsCompleted)
                    {
                        SetActiveBar(null);
                    }
                }
                else if (barsCompleted)
                {
                    songStarted = false;
                    playingSong = false;
                    songSource  = null;

                    if (onSongCompleted != null)
                    {
                        onSongCompleted();
                    }
                }
                else
                {
                    if (songSource != null && !songSource.IsPlaying && !isMenuOpen)
                    {
                        songSource.Stop();
                        songSource.Play();
                        songSource.Position = lastSongTime;
                    }
                }
            }
        }
示例#6
0
        void Update()
        {
            for (int i = 0; i < bars.Count; ++i)
            {
                var bar = bars[i];

                int completedPairId = (completedBars / 2) * 2;

                bool show = (i >= completedPairId) && (i < completedPairId + 2);

                bar.Show(show);
            }

            bool isMenuOpen = UI.PauseMenu.I.IsMenuOpen;

            songInsideAWord = false;
            if (playingSong)
            {
                if (songSource != null && songSource.IsPlaying)
                {
                    float currentTime = songSource.Position;
                    lastSongTime = currentTime;

                    if (isMenuOpen)
                    {
                        songSource.Pause();
                        return;
                    }

                    var songWords = currentBarSong.lines;

                    var songStart = songWords[0].start;
                    if (currentTime > songStart - 2)
                    {
                        if (!songStarted && activeBar == null)
                        {
                            SetActiveBar(bars[0]);
                        }

                        songStarted = true;
                    }

                    if (songStarted)
                    {
                        for (int i = 0; i < songWords.Count; ++i)
                        {
                            var currentSongWord = songWords[i];
                            var currentBarWord  = currentBarWords[i];

                            var timeStart = currentSongWord.start;
                            var timeEnd   = currentSongWord.end;

                            // Move to currentBarWord
                            while (activeBar != null && activeBar.Id < currentBarWord.barId)
                            {
                                SwitchToNextBar();
                            }

                            if (currentTime < timeStart)
                            {
                                if (activeBar != null && activeBar.Id == currentBarWord.barId)
                                {
                                    activeBar.currentTarget = 0;
                                }

                                break;
                            }
                            else if (currentTime > timeEnd)
                            {
                                barsCompleted = (i == songWords.Count - 1);
                            }
                            else
                            {
                                float tInWord = (currentTime - timeStart) / (timeEnd - timeStart);

                                float t = Mathf.Lerp(currentBarWord.start, currentBarWord.end, tInWord);
                                activeBar.currentTarget = t;
                                songInsideAWord         = true;

                                break;
                            }
                        }
                    }

                    if (barsCompleted)
                    {
                        SetActiveBar(null);
                    }
                }
                else if (barsCompleted)
                {
                    songStarted = false;
                    playingSong = false;
                    songSource  = null;

                    if (onSongCompleted != null)
                    {
                        onSongCompleted();
                    }
                }
                else
                {
                    if (songSource != null && !songSource.IsPlaying && !isMenuOpen)
                    {
                        songSource.Stop();
                        songSource.Play();
                        songSource.Position = lastSongTime;
                    }
                }
            }
        }