浏览代码

添加剧情对话倍速不播放语音
添加自动播放继承
调整自动播放等待时间

leiyasi 1 年之前
父节点
当前提交
78db9daaa5

+ 11 - 2
GameClient/Assets/Game/HotUpdate/Sound/VoiceManager.cs

@@ -74,11 +74,20 @@ namespace GFGGame
             player.clip = null;
             player.clip = null;
         }
         }
 
 
-        public int GetClipLength()
+        public float GetClipLength()
         {
         {
             if (player.clip != null)
             if (player.clip != null)
             {
             {
-                return (int)Mathf.Ceil(player.clip.length);
+                return player.clip.length;
+            }
+            return 0;
+        }
+
+        public float GetClipRemainingLength()
+        {
+            if (player.clip != null)
+            {
+                return Mathf.Ceil(player.clip.length - player.time);
             }
             }
             return 0;
             return 0;
         }
         }

+ 15 - 8
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryDialogView.cs

@@ -142,7 +142,8 @@ namespace GFGGame
             }
             }
 
 
             IsTeaParty = (bool)datas[4];
             IsTeaParty = (bool)datas[4];
-            _autoPlay = IsTeaParty;
+            _autoPlay = _lastStartAutoPlay;
+            _ui.m_btnAutoPlay.selected = _autoPlay;
 
 
             if (LauncherConfig.netType == LauncherConfig.EnumNetType.TEMP && !InstanceZonesDataManager.CheckLevelPass(MainStoryDataManager.currentLevelCfgId))
             if (LauncherConfig.netType == LauncherConfig.EnumNetType.TEMP && !InstanceZonesDataManager.CheckLevelPass(MainStoryDataManager.currentLevelCfgId))
             {
             {
@@ -156,7 +157,6 @@ namespace GFGGame
 
 
             _ui.m_btnSkip.visible = skipable;
             _ui.m_btnSkip.visible = skipable;
             _ui.m_c1.selectedIndex = 0;
             _ui.m_c1.selectedIndex = 0;
-            _ui.m_btnAutoPlay.selected = false;
 
 
             if (_storyStartID == MainStoryDataManager.priorId)
             if (_storyStartID == MainStoryDataManager.priorId)
             {
             {
@@ -180,13 +180,14 @@ namespace GFGGame
             Timers.inst.StartCoroutine(CheckResLoad());
             Timers.inst.StartCoroutine(CheckResLoad());
         }
         }
 
 
+        private bool _lastStartAutoPlay = false;
         protected override void OnHide()
         protected override void OnHide()
         {
         {
             base.OnHide();
             base.OnHide();
             Timers.inst.Remove(UpdateShake);
             Timers.inst.Remove(UpdateShake);
             Timers.inst.Remove(OnScreenEffectComplete);
             Timers.inst.Remove(OnScreenEffectComplete);
-            Timers.inst.Remove(ShowNextWords);
             ScreenBlackController.Instance.HideBlack();
             ScreenBlackController.Instance.HideBlack();
+            _lastStartAutoPlay = _autoPlay;
             StopAutoPlay();
             StopAutoPlay();
             VoiceManager.Instance.StopVoice();
             VoiceManager.Instance.StopVoice();
 
 
@@ -407,7 +408,7 @@ namespace GFGGame
             _canClickBtnNext = true;
             _canClickBtnNext = true;
             if (content.IndexOf("//") >= 0)
             if (content.IndexOf("//") >= 0)
             {
             {
-                showList(content);
+                ShowList(content);
             }
             }
             else
             else
             {
             {
@@ -415,7 +416,7 @@ namespace GFGGame
             }
             }
         }
         }
 
 
-        private void showList(string content)
+        private void ShowList(string content)
         {
         {
             StopAutoPlay();
             StopAutoPlay();
             _ui.m_btnAutoPlay.enabled = false;
             _ui.m_btnAutoPlay.enabled = false;
@@ -477,8 +478,14 @@ namespace GFGGame
             string[] effectInfo = storyDialogCfg.effectInfoArr;
             string[] effectInfo = storyDialogCfg.effectInfoArr;
 
 
             VoiceManager.Instance.StopVoice();
             VoiceManager.Instance.StopVoice();
-            // 如果配置了语音,读取语音
-            VoiceManager.Instance.LoadRes(ResPathUtil.GetVoicePath(storyDialogCfg.voiceRes));
+
+            // 如果没开倍速才加载语音
+            if(_speedAutoPlay == 1 || !_autoPlay)
+            {
+                // 如果配置了语音,读取语音
+                VoiceManager.Instance.LoadRes(ResPathUtil.GetVoicePath(storyDialogCfg.voiceRes));
+            }
+
             _wordList = Regex.Split(words, "&&");
             _wordList = Regex.Split(words, "&&");
 
 
             // 有对话
             // 有对话
@@ -669,7 +676,7 @@ namespace GFGGame
             _wordIndex++;
             _wordIndex++;
             if (_autoPlay)
             if (_autoPlay)
             {
             {
-                int interval = (int)Mathf.Max(VoiceManager.Instance.GetClipLength(), GameConst.NEXT_WORDS_INTERVAL_MAX / _speedAutoPlay);
+                float interval = Mathf.Max(VoiceManager.Instance.GetClipRemainingLength(), GameConst.NEXT_WORDS_INTERVAL_MAX / _speedAutoPlay);
                 Timers.inst.Add(interval, 1, ShowNextWords);
                 Timers.inst.Add(interval, 1, ShowNextWords);
             }
             }
         }
         }