From cba0f34cacddb395271f04d29ac7263f05ab39ec Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期一, 24 十二月 2018 10:31:43 +0800
Subject: [PATCH] 5367 【前端】【1.4】聚魂功能开发(添加UI特效)

---
 System/GatheringSoul/GatherSoulResolveWin.cs    |   12 +++
 System/GatheringSoul/GatherSoulWin.cs           |   46 +++++++++++++++
 Utility/EnumHelper.cs                           |    1 
 System/GatheringSoul/GatherSoulItemBehaviour.cs |   65 ++++++++++++++++++++-
 System/GatheringSoul/GatheringSoulModel.cs      |   16 +++++
 System/GatheringSoul/GatherSoulHoleBehaviour.cs |    8 ++
 System/GatheringSoul/GatherSoulLevelUpWin.cs    |    8 ++
 7 files changed, 151 insertions(+), 5 deletions(-)

diff --git a/System/GatheringSoul/GatherSoulHoleBehaviour.cs b/System/GatheringSoul/GatherSoulHoleBehaviour.cs
index 767162c..4aa23be 100644
--- a/System/GatheringSoul/GatherSoulHoleBehaviour.cs
+++ b/System/GatheringSoul/GatherSoulHoleBehaviour.cs
@@ -31,6 +31,8 @@
             get { return ModelCenter.Instance.GetModel<GatherSoulComposeModel>(); }
         }
 
+        bool existItem = false;
+
         private void Awake()
         {
             m_Func.onClick.AddListener(OnFunc);
@@ -56,6 +58,7 @@
             m_ContainreItem.gameObject.SetActive(equiped);
             m_ContainerLock.gameObject.SetActive(!unlockHole);
             m_ContainerEquipSign.gameObject.SetActive(!equiped && unlockHole);
+            existItem = equiped;
             if (equiped)
             {
                 var config = Config.Instance.Get<ItemConfig>(item.id);
@@ -175,7 +178,12 @@
         {
             if (this.hole == hole)
             {
+                bool exist = existItem;
                 DisplayBase();
+                if (!exist && existItem && model.serverInited)
+                {
+                    EffectMgr.Instance.PlayUIEffect(3079, 2100, transform, false);
+                }
             }
         }
 
diff --git a/System/GatheringSoul/GatherSoulItemBehaviour.cs b/System/GatheringSoul/GatherSoulItemBehaviour.cs
index fb199d4..9a79cc4 100644
--- a/System/GatheringSoul/GatherSoulItemBehaviour.cs
+++ b/System/GatheringSoul/GatherSoulItemBehaviour.cs
@@ -18,6 +18,7 @@
         [SerializeField] Text m_Count;
         [SerializeField] Button m_Func;
         [SerializeField] RectTransform m_Select;
+        [SerializeField] UIEffect m_Effect;
 
         VirtualPackModel model
         {
@@ -36,12 +37,31 @@
 
         VirtualItem displayItem;
 
+        bool requireResolveEffect = false;
+
+        public static event Action<Transform> alreadyResolveEvent;
+
         private void Awake()
         {
             if (m_Func != null)
             {
                 m_Func.onClick.AddListener(OnFunc);
             }
+        }
+
+        private void OnEnable()
+        {
+            soulModel.prepareResolveEvent += PrepareResolveEvent;
+            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitializeEvent;
+            DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += MakeItemAnswerEvent;
+        }
+
+        private void OnDisable()
+        {
+            soulModel.prepareResolveEvent -= PrepareResolveEvent;
+            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerDataInitializeEvent;
+            DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= MakeItemAnswerEvent;
+            requireResolveEffect = false;
         }
 
         /// <summary>
@@ -130,9 +150,48 @@
         {
             if (m_Select != null)
             {
-                m_Select.gameObject.SetActive(displayItem.packType == PackType.rptGatherSoul
-                    && soulModel.replaceRedpoint.state == RedPointState.Simple
-                    && soulModel.replaceRedpointIndex == displayItem.index);
+                var requireSelect = displayItem.packType == PackType.rptGatherSoul
+                    && soulModel.topBestSoulIndexs.Contains(displayItem.index);
+                m_Select.gameObject.SetActive(requireSelect);
+                if (requireSelect)
+                {
+                    if (m_Effect.target != null)
+                    {
+                        var animator = m_Effect.target.GetAnimator();
+                        if (animator != null)
+                        {
+                            animator.Play(0, 0, GatherSoulWin.sync_topsoul_normalized);
+                        }
+                    }
+                }
+            }
+        }
+
+        private void PrepareResolveEvent(PackType packType, int index)
+        {
+            if (displayItem.packType == packType && displayItem.index == index)
+            {
+                requireResolveEffect = true;
+            }
+        }
+
+        private void BeforePlayerDataInitializeEvent()
+        {
+            requireResolveEffect = false;
+        }
+
+        private void MakeItemAnswerEvent(H0721_tagMakeItemAnswer package)
+        {
+            if (package.MakeType == (int)MakeType.Def_mitGatherSoulDecompose)
+            {
+                if (requireResolveEffect)
+                {
+                    if (alreadyResolveEvent != null)
+                    {
+                        alreadyResolveEvent(transform);
+                    }
+                    requireResolveEffect = false;
+                }
             }
         }
 
diff --git a/System/GatheringSoul/GatherSoulLevelUpWin.cs b/System/GatheringSoul/GatherSoulLevelUpWin.cs
index 44fca0d..4fd4947 100644
--- a/System/GatheringSoul/GatherSoulLevelUpWin.cs
+++ b/System/GatheringSoul/GatherSoulLevelUpWin.cs
@@ -28,6 +28,8 @@
 
         public static int selectHole = 0;
 
+        int level = 0;
+
         GatheringSoulModel model
         {
             get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
@@ -82,6 +84,7 @@
                 m_ItemName.color = UIHelper.GetUIColor(itemConfig.ItemColor);
                 m_Level.text = Language.Get("Z1024", item.level);
                 m_Icon.SetSprite(itemConfig.IconKey);
+                level = item.level;
             }
         }
 
@@ -144,7 +147,12 @@
                     CloseImmediately();
                     return;
                 }
+                var record = level;
                 Display();
+                if (level > record && model.serverInited)
+                {
+                    EffectMgr.Instance.PlayUIEffect(3078, 3100, m_Icon.transform, false);
+                }
             }
         }
 
diff --git a/System/GatheringSoul/GatherSoulResolveWin.cs b/System/GatheringSoul/GatherSoulResolveWin.cs
index c32d79c..2535a03 100644
--- a/System/GatheringSoul/GatherSoulResolveWin.cs
+++ b/System/GatheringSoul/GatherSoulResolveWin.cs
@@ -65,12 +65,12 @@
             selectQuality = GetDefaultQuality();
             m_QualitySort.SetDefault();
             m_Quality.text = Language.Get(StringUtility.Contact("GatherSoulResolve_", selectQuality));
-            m_Quality.color = UIHelper.GetUIColor(selectQuality);
             Display();
             PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
             model.gatherSoulPackRefresh += GatherSoulPackRefresh;
             m_QualitySort.onSelectSortEvent += OnSelectSort;
             model.oneKeyResolveRefresh += OneKeyResolveRefresh;
+            DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += MakeItemAnswerEvent;
             m_ScrollerControl.JumpIndex(0);
         }
 
@@ -86,6 +86,7 @@
             model.gatherSoulPackRefresh -= GatherSoulPackRefresh;
             m_QualitySort.onSelectSortEvent -= OnSelectSort;
             model.oneKeyResolveRefresh -= OneKeyResolveRefresh;
+            DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= MakeItemAnswerEvent;
         }
 
         protected override void OnAfterClose()
@@ -129,13 +130,20 @@
             resolveCell.Display(cell.index);
         }
 
+        private void MakeItemAnswerEvent(H0721_tagMakeItemAnswer package)
+        {
+            if (package.MakeType == (int)MakeType.Def_mitGatherSoulDecompose)
+            {
+                EffectMgr.Instance.PlayUIEffect(3080, 3100, transform, false);
+            }
+        }
+
         private void OnSelectSort(SortType type, int sort)
         {
             if (type == SortType.EquipQuality)
             {
                 selectQuality = sort;
                 Display();
-                m_Quality.color = UIHelper.GetUIColor(selectQuality);
             }
         }
 
diff --git a/System/GatheringSoul/GatherSoulWin.cs b/System/GatheringSoul/GatherSoulWin.cs
index 8b5641a..ab0ded9 100644
--- a/System/GatheringSoul/GatherSoulWin.cs
+++ b/System/GatheringSoul/GatherSoulWin.cs
@@ -44,6 +44,10 @@
         {
             get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); }
         }
+
+        public static float sync_topsoul_normalized = 0f;
+        static float topsoul_duration = 1.067f;
+        static float sync_timer = 0f;
         #region Built-in
         protected override void BindController()
         {
@@ -79,6 +83,7 @@
             Display();
             PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
             model.gatherSoulPackRefresh += GatherSoulPackRefresh;
+            GatherSoulItemBehaviour.alreadyResolveEvent += AlreadyResolveEvent;
         }
 
         protected override void OnAfterOpen()
@@ -93,10 +98,24 @@
             }
             PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
             model.gatherSoulPackRefresh -= GatherSoulPackRefresh;
+            GatherSoulItemBehaviour.alreadyResolveEvent -= AlreadyResolveEvent;
         }
 
         protected override void OnAfterClose()
         {
+        }
+
+        protected override void LateUpdate()
+        {
+            sync_topsoul_normalized = Mathf.Clamp01(sync_timer / topsoul_duration);
+            if (sync_timer >= topsoul_duration)
+            {
+                sync_timer = 0f;
+            }
+            else
+            {
+                sync_timer += Time.deltaTime;
+            }
         }
         #endregion
 
@@ -153,6 +172,33 @@
             m_ScrollerControl.m_Scorller.RefreshActiveCellViews();
         }
 
+        private void AlreadyResolveEvent(Transform resolveTransform)
+        {
+            if (resolveTransform != null)
+            {
+                var effect = EffectMgr.Instance.PlayUIEffect(3076, 2200, transform, true);
+                if (effect != null)
+                {
+                    var bezierMove = effect.AddMissingComponent<BezierMove>();
+                    bezierMove.duration = 1.5f;
+                    var startPoint = resolveTransform.position;
+                    var endPoint = m_DustIcon.transform.position;
+
+                    var nl = Vector3.Normalize(endPoint - startPoint);
+                    var normal = new Vector3(-nl.y, nl.x, 0);
+                    var distance = Vector3.Distance(startPoint, endPoint);
+                    var pivot = startPoint + normal * UnityEngine.Random.Range(-distance, distance) * 0.7f + nl * distance * 0.4f;
+                    bezierMove.Begin(startPoint, pivot, endPoint, () =>
+                    {
+                        if (effect != null)
+                        {
+                            EffectMgr.Instance.RecyleUIEffect(3076, effect.gameObject);
+                        }
+                    });
+                }
+            }
+        }
+
         private void ViewProperty()
         {
             if (WindowCenter.Instance.IsOpen<GatherSoulTotalPropertyWin>())
diff --git a/System/GatheringSoul/GatheringSoulModel.cs b/System/GatheringSoul/GatheringSoulModel.cs
index 62ace26..537c20a 100644
--- a/System/GatheringSoul/GatheringSoulModel.cs
+++ b/System/GatheringSoul/GatheringSoulModel.cs
@@ -20,6 +20,7 @@
         public Dictionary<int, List<int>> gatherSoulPropertys { get; private set; }
 
         public List<int> packIndexs { get; private set; }
+        public List<int> topBestSoulIndexs = new List<int>();
         public List<GatherSoulItem> resolveItems { get; private set; }
 
         public int holeCount
@@ -46,6 +47,11 @@
         public int coreHole { get; private set; }
 
         public int autoResolveRemainCount { get; private set; }
+
+        public bool serverInited { get; private set; }
+
+        public event Action<PackType, int> prepareResolveEvent;
+
 
         public event Action<int> gatherSoulHoleRefresh;
         public event Action gatherSoulHolesRefresh;
@@ -88,12 +94,15 @@
 
         public void OnBeforePlayerDataInitialize()
         {
+            serverInited = false;
             packIndexs.Clear();
+            topBestSoulIndexs.Clear();
             gatherSoulHoleDict.Clear();
         }
 
         public void OnPlayerLoginOk()
         {
+            serverInited = true;
             CheckAutoResolve();
             UpdateRedpoint();
         }
@@ -234,6 +243,7 @@
         public void RefreshGatherSoulPack()
         {
             packIndexs.Clear();
+            topBestSoulIndexs.Clear();
             List<int> emptyHoles;
             if (ExistEmptyHole(out emptyHoles))
             {
@@ -359,6 +369,7 @@
             {
                 packIndexs.RemoveAt(removeList[i]);
             }
+            topBestSoulIndexs.AddRange(packIndexs);
         }
 
         public bool ExistEmptyHole(out List<int> list)
@@ -784,6 +795,11 @@
             {
                 return;
             }
+            if (prepareResolveEvent != null)
+            {
+                prepareResolveEvent(item.placeType == 0 ? PackType.rptGatherSoul : PackType.rptInterimPack,
+                    item.index);
+            }
             SendResolvePack(new ushort[1] { (ushort)item.index }, false);
         }
 
diff --git a/Utility/EnumHelper.cs b/Utility/EnumHelper.cs
index dcf67a9..34c00bd 100644
--- a/Utility/EnumHelper.cs
+++ b/Utility/EnumHelper.cs
@@ -816,6 +816,7 @@
     Def_mitDogzEquipPlus = 21,// 绁炲吔瑁呭寮哄寲 
     Def_mitRuneCompound = 22,//绗﹀嵃鍚堟垚
     Def_mitGatherSoulCompound = 23,//鑱氶瓊鍚堟垚
+    Def_mitGatherSoulDecompose = 24,//鑱氶瓊鍒嗚В
 }
 /// <summary>
 /// 閲戦挶绫诲瀷(铏氭嫙鐗╁搧)

--
Gitblit v1.8.0