Explorar o código

增加剧情场景切换过渡、对话框延时进入

leiyasi hai 1 ano
pai
achega
6b0d0e722f

+ 24 - 0
GameClient/Assets/Game/HotUpdate/Data/StoryDialogDataManager.cs

@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class StoryDialogDataManager : SingletonBase<StoryDialogDataManager>
+    {
+        public void Clear()
+        {
+            _waitPicFade = false;
+            _waitBgChange = false;
+        }
+
+        private bool _waitPicFade = false;
+        private bool _waitBgChange = false;
+
+
+        // Dialog wait pic's animation finished 
+        public bool waitPicFade { get { return _waitPicFade; } set { _waitPicFade = value; } }
+        public bool waitBgChange { get { return _waitBgChange; } set { _waitBgChange = value; } }
+    }
+}
+

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Data/StoryDialogDataManager.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d77a5fb2a91aa87499ecf6cb29e413c5
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 7
GameClient/Assets/Game/HotUpdate/DressUp/SceneController.cs

@@ -64,6 +64,7 @@ namespace GFGGame
                 }
                 else
                 {
+                    StoryDialogDataManager.Instance.waitBgChange = true;
                     SetSpriteRendererAlpha(bgSpr, 1f);
                     bgNextSpr.sprite = sp;
                     FairyGUI.Timers.inst.StartCoroutine(LastBgFadeOut());
@@ -92,6 +93,7 @@ namespace GFGGame
                             }
                             yield return new WaitForEndOfFrame();
                         }
+                        StoryDialogDataManager.Instance.waitBgChange = false;
                     }
                 }
 
@@ -109,6 +111,15 @@ namespace GFGGame
             }
             else
             {
+                StoryDialogDataManager.Instance.waitPicFade = true;
+
+                var resPath = ResPathUtil.GetNpcPicSPath(value);
+                Sprite sp = GFGAsset.Load<Sprite>(resPath);
+                DressUpUtil.AddAssetReleaser(tf.gameObject, resPath);
+                spr.sprite = sp;
+                SetSpriteRendererAlpha(spr, 0f);
+                FairyGUI.Timers.inst.StartCoroutine(UpdateDialogPicAlpha());
+
                 IEnumerator UpdateDialogPicAlpha()
                 {
                     while (true)
@@ -131,13 +142,6 @@ namespace GFGGame
                         yield return new WaitForEndOfFrame();
                     }
                 }
-
-                var resPath = ResPathUtil.GetNpcPicSPath(value);
-                Sprite sp = GFGAsset.Load<Sprite>(resPath);
-                DressUpUtil.AddAssetReleaser(tf.gameObject, resPath);
-                spr.sprite = sp;
-                SetSpriteRendererAlpha(spr, 0f);
-                FairyGUI.Timers.inst.StartCoroutine(UpdateDialogPicAlpha());
             }
         }
 

+ 32 - 25
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryDialogView.cs

@@ -34,7 +34,6 @@ namespace GFGGame
         private int _wordIndex = 0;
         private bool _isShowLetters;
         private bool _canClickBtnNext;
-        private bool _waitPic;
         private string _currentWords;
         private string _storyStartID;
         private string lastTextFieldType;   // 上一段文本框的类型
@@ -170,6 +169,7 @@ namespace GFGGame
             MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
             _onCompleteStoryDialogCall = null;
             _onCompleteStoryDialogCallParam = null;
+            StoryDialogDataManager.Instance.Clear();
         }
 
         private void OnClickBtnBack()
@@ -185,7 +185,7 @@ namespace GFGGame
             {
                 return;
             }
-            // StopAutoPlay();
+            StopAutoPlay();
             if (_onScreenEffectComplete != null)
             {
                 Timers.inst.Remove(OnScreenEffectComplete);
@@ -199,6 +199,7 @@ namespace GFGGame
 
         private void OnClickBtnLookBack()
         {
+            StopAutoPlay();
             if (_ui.m_btnSkip.enabled)
             {
                 ViewManager.Show<StoryLookBackView>(_storyStartID);
@@ -269,7 +270,7 @@ namespace GFGGame
             {
                 StoryDialogCfg storyDialogCfg = (StoryDialogCfg)_stepListToRead[0];
                 _stepListToRead.RemoveAt(0);
-                InitStepContent(storyDialogCfg);
+                Timers.inst.StartCoroutine(InitStepContent(storyDialogCfg));
             }
             else
             {
@@ -324,11 +325,13 @@ namespace GFGGame
             }
         }
 
-        private void InitStepContent(StoryDialogCfg storyDialogCfg)
+        private IEnumerator InitStepContent(StoryDialogCfg storyDialogCfg)
         {
-            _canClickBtnNext = true;
-            _waitPic = false;
+            _canClickBtnNext = false;
+            StoryDialogDataManager.Instance.waitPicFade = false;
+            HideAllDialogUI();
 
+            // Init resource
             _currentStepCfg = storyDialogCfg;
             UpdateMusic(storyDialogCfg.musicRes);
             UpdateBg(storyDialogCfg.bgRes);
@@ -337,6 +340,18 @@ namespace GFGGame
             PlayShake(storyDialogCfg.shakeInfoArr);
             string content = storyDialogCfg.content;
             content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);
+
+            bool delay = StoryDialogDataManager.Instance.waitBgChange;
+            while (StoryDialogDataManager.Instance.waitBgChange)
+            {
+                yield return new WaitForEndOfFrame();
+            }
+            if (delay)
+            {
+                yield return new WaitForSeconds(0.4f);
+            }
+
+            _canClickBtnNext = true;
             if (content.IndexOf("//") >= 0)
             {
                 showList(content);
@@ -352,9 +367,6 @@ namespace GFGGame
             StopAutoPlay();
             _ui.m_btnAutoPlay.enabled = false;
             _wordTextField = null;
-            _ui.m_dialogText.target.visible = false;
-            _ui.m_dialogName.target.visible = false;
-            _ui.m_dialogHead.target.visible = false;
             _ui.m_list.visible = true;
             _ui.m_list.RemoveChildrenToPool();
             string[] list = Regex.Split(content, "//");
@@ -371,6 +383,14 @@ namespace GFGGame
 
         }
 
+        private void HideAllDialogUI()
+        {
+            _ui.m_dialogText.target.visible = false;
+            _ui.m_dialogName.target.visible = false;
+            _ui.m_dialogHead.target.visible = false;
+            _ui.m_list.visible = false;
+        }
+
         private void ShowDialog(StoryDialogCfg storyDialogCfg)
         {
             if (storyDialogCfg.showChangeName == 1 && StorageDataManager.Instance.GetStorageValue(ConstStorageId.CHANGE_NAME) == 0)
@@ -402,8 +422,6 @@ namespace GFGGame
             if (!string.IsNullOrEmpty(headAniRes) || storyDialogCfg.suitId > 0)
             {
                 //显示对话框半身像
-                _ui.m_dialogText.target.visible = false;
-                _ui.m_dialogName.target.visible = false;
                 _ui.m_dialogHead.target.visible = true;
                 _ui.m_dialogHead.m_txtName.text = roleName;
                 _ui.m_dialogHead.m_comphead.m_head.visible = false;
@@ -449,8 +467,6 @@ namespace GFGGame
             }
             else if (!string.IsNullOrEmpty(headRes))
             {
-                _ui.m_dialogText.target.visible = false;
-                _ui.m_dialogName.target.visible = false;
                 _ui.m_dialogHead.target.visible = true;
                 _ui.m_dialogHead.m_txtName.text = roleName;
                 _ui.m_dialogHead.m_comphead.m_head.visible = true;
@@ -463,9 +479,7 @@ namespace GFGGame
             }
             else if (!string.IsNullOrEmpty(roleName))
             {
-                _ui.m_dialogText.target.visible = false;
                 _ui.m_dialogName.target.visible = true;
-                _ui.m_dialogHead.target.visible = false;
                 _ui.m_dialogName.m_txtName.text = roleName;
                 _wordTextField = _ui.m_dialogName.m_txtContent;
                 _arrow = _ui.m_dialogName.m_iconNext;
@@ -475,18 +489,11 @@ namespace GFGGame
                     lastTextFieldType = "name";
                     _ui.m_t0.Play();
 
-                    // Wait pic's animation finished 
-                    if(storyDialogCfg.picRes.Length > 0 && !storyDialogCfg.picRes.Equals("0"))
-                    {
-                        _waitPic = true;
-                    }
                 }
             }
             else
             {
                 _ui.m_dialogText.target.visible = true;
-                _ui.m_dialogName.target.visible = false;
-                _ui.m_dialogHead.target.visible = false;
                 _wordTextField = _ui.m_dialogText.m_txtContent;
                 _arrow = _ui.m_dialogText.m_iconNext;
                 lastTextFieldType = "text";
@@ -567,11 +574,11 @@ namespace GFGGame
             _wordTextField.text = "";
             ArrayList letters = StoryUtil.GetLettersList(_currentWords);
 
-            if (_waitPic)
+            if (StoryDialogDataManager.Instance.waitPicFade)
             {
-                _waitPic = false;
+                StoryDialogDataManager.Instance.waitPicFade = false;
                 _canClickBtnNext = false;
-                yield return new WaitForSeconds(0.5f);
+                yield return new WaitForSeconds(0.4f);
                 _canClickBtnNext = true;
             }