From 7c96e6bada0ea8bbff233395b879960686f0f4b4 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期三, 15 八月 2018 13:53:30 +0800
Subject: [PATCH] 2562【前端】宗门试练兑换界面优化

---
 System/Dungeon/TrialExchangeTitleCell.cs      |   19 ++++
 System/Dungeon/TrialExchangeWin.cs            |   35 +++++++-
 System/Dungeon/TrialExchangeCell.cs           |   73 ++++-------------
 System/Dungeon/TrialExchangeCell.cs.meta      |    4 
 System/Dungeon/TrialExchangeBehaviour.cs      |   74 ++++++++++++++++++
 System/Dungeon/TrialExchangeBehaviour.cs.meta |   12 +++
 System/Dungeon/TrialExchangeTitleCell.cs.meta |   12 +++
 7 files changed, 165 insertions(+), 64 deletions(-)

diff --git a/System/Dungeon/TrialExchangeBehaviour.cs b/System/Dungeon/TrialExchangeBehaviour.cs
new file mode 100644
index 0000000..f374abb
--- /dev/null
+++ b/System/Dungeon/TrialExchangeBehaviour.cs
@@ -0,0 +1,74 @@
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using TableConfig;
+using System;
+
+namespace Snxxz.UI
+{
+    public class TrialExchangeBehaviour : MonoBehaviour
+    {
+        [SerializeField] ItemCell m_Item;
+        [SerializeField] Text m_Description;
+        [SerializeField] ItemBehaviour m_Token;
+        [SerializeField] Button m_Exchange;
+        [SerializeField] Image m_Redpoint;
+        TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
+        DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
+
+        int trialExchangeId = 0;
+        private void Awake()
+        {
+            m_Exchange.AddListener(Exchange);
+        }
+
+        private void Exchange()
+        {
+            if (trialExchangeId != 0)
+            {
+                int error = 0;
+                if (!model.TrialSendExchange(trialExchangeId, out error))
+                {
+                    if (error == 1)
+                    {
+                        var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(trialExchangeId);
+                        if (config != null)
+                        {
+                            ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
+                        }
+                    }
+                    model.ProcessTrialError(error);
+                }
+            }
+        }
+
+        public void Display(int id)
+        {
+            trialExchangeId = id;
+            var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(id);
+            if (config == null)
+            {
+                trialExchangeId = 0;
+                return;
+            }
+            m_Item.cellBtn.RemoveAllListeners();
+            m_Item.gameObject.SetActive(true);
+            ItemCellModel cellModel = new ItemCellModel(config.exchangeItemID, true, (ulong)config.exchangeItemCount, config.exchangeItemIsBind);
+            m_Item.Init(cellModel);
+            m_Item.cellBtn.AddListener(() =>
+            {
+                ItemAttrData itemAttrData = new ItemAttrData(config.exchangeItemID, true, (ulong)config.exchangeItemCount, -1, config.exchangeItemIsBind);
+                ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
+            });
+            m_Description.text = config.description;
+            m_Token.SetItem(config.tokenId, config.tokenCount);
+            var count = model.GetTrialTokenCount(config.tokenId);
+            m_Token.count.color = UIHelper.GetUIColor(count >= config.tokenCount ? TextColType.Green : TextColType.Red, true);
+
+            m_Redpoint.gameObject.SetActive(count >= config.tokenCount
+                && dailyQuestModel.trialExchangeRedpoint.state == RedPointState.Simple);
+        }
+    }
+}
+
diff --git a/System/Dungeon/TrialExchangeBehaviour.cs.meta b/System/Dungeon/TrialExchangeBehaviour.cs.meta
new file mode 100644
index 0000000..f9fb53b
--- /dev/null
+++ b/System/Dungeon/TrialExchangeBehaviour.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9ebb65b796d3424439f2dff414553268
+timeCreated: 1533181655
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Dungeon/TrialExchangeCell.cs b/System/Dungeon/TrialExchangeCell.cs
index 5776fe5..2d7b86e 100644
--- a/System/Dungeon/TrialExchangeCell.cs
+++ b/System/Dungeon/TrialExchangeCell.cs
@@ -1,72 +1,35 @@
 锘縰sing System.Collections;
 using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
 using TableConfig;
-using System;
-
+using UnityEngine;
 namespace Snxxz.UI
 {
     public class TrialExchangeCell : CellView
     {
-        [SerializeField] ItemCell m_Item;
-        [SerializeField] Text m_Description;
-        [SerializeField] ItemBehaviour m_Token;
-        [SerializeField] Button m_Exchange;
-        [SerializeField] Image m_Redpoint;
+        [SerializeField] TrialExchangeBehaviour[] m_TrialExchanges;
+
         TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
-        DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
 
-        int trialExchangeId = 0;
-        private void Awake()
+        public void Display(int _class, int _line)
         {
-            m_Exchange.AddListener(Exchange);
-        }
-
-        private void Exchange()
-        {
-            if (trialExchangeId != 0)
+            List<TrialExchangeConfig> list;
+            if (!model.TryGetTrialExchanges(_class, out list))
             {
-                int error = 0;
-                if (!model.TrialSendExchange(trialExchangeId, out error))
-                {
-                    if (error == 1)
-                    {
-                        var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(trialExchangeId);
-                        if (config != null)
-                        {
-                            ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
-                        }
-                    }
-                    model.ProcessTrialError(error);
-                }
-            }
-        }
-
-        public void Display(int id)
-        {
-            trialExchangeId = id;
-            var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(id);
-            if (config == null)
-            {
-                trialExchangeId = 0;
                 return;
             }
-            m_Item.cellBtn.RemoveAllListeners();
-            m_Item.gameObject.SetActive(true);
-            ItemCellModel cellModel = new ItemCellModel(config.exchangeItemID, true, (ulong)config.exchangeItemCount, config.exchangeItemIsBind);
-            m_Item.Init(cellModel);
-            m_Item.cellBtn.AddListener(() =>
+            for (int i = 0; i < m_TrialExchanges.Length; i++)
             {
-                ItemAttrData itemAttrData = new ItemAttrData(config.exchangeItemID, true, (ulong)config.exchangeItemCount, -1, config.exchangeItemIsBind);
-                ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
-            });
-            m_Description.text = config.description;
-            m_Token.SetItem(config.tokenId, config.tokenCount);
-
-            var count = model.GetTrialTokenCount(config.tokenId);
-            m_Redpoint.gameObject.SetActive(count >= config.tokenCount
-                && dailyQuestModel.trialExchangeRedpoint.state == RedPointState.Simple);
+                var index = _line * 4 + i;
+                if (index < list.Count)
+                {
+                    m_TrialExchanges[i].gameObject.SetActive(true);
+                    m_TrialExchanges[i].Display(list[index].id);
+                }
+                else
+                {
+                    m_TrialExchanges[i].gameObject.SetActive(false);
+                }
+            }
         }
     }
 }
diff --git a/System/Dungeon/TrialExchangeCell.cs.meta b/System/Dungeon/TrialExchangeCell.cs.meta
index 63de5ee..c962446 100644
--- a/System/Dungeon/TrialExchangeCell.cs.meta
+++ b/System/Dungeon/TrialExchangeCell.cs.meta
@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 9ebb65b796d3424439f2dff414553268
-timeCreated: 1533181655
+guid: 5c0805e8cad6c2e44bbd30aaaff7008f
+timeCreated: 1534302392
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2
diff --git a/System/Dungeon/TrialExchangeTitleCell.cs b/System/Dungeon/TrialExchangeTitleCell.cs
new file mode 100644
index 0000000..11baabd
--- /dev/null
+++ b/System/Dungeon/TrialExchangeTitleCell.cs
@@ -0,0 +1,19 @@
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Snxxz.UI
+{
+    public class TrialExchangeTitleCell : CellView
+    {
+        [SerializeField] Image m_BackGround;
+        [SerializeField] Text m_Title;
+
+        public void Display(int _class)
+        {
+            m_Title.text = Language.Get("TrialExchangeTitle", _class);
+        }
+    }
+}
+
diff --git a/System/Dungeon/TrialExchangeTitleCell.cs.meta b/System/Dungeon/TrialExchangeTitleCell.cs.meta
new file mode 100644
index 0000000..d07f918
--- /dev/null
+++ b/System/Dungeon/TrialExchangeTitleCell.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 62d21c0bcc1b7ad4e8528d2bfb9f7b91
+timeCreated: 1534303452
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Dungeon/TrialExchangeWin.cs b/System/Dungeon/TrialExchangeWin.cs
index bde81f7..92f6a4a 100644
--- a/System/Dungeon/TrialExchangeWin.cs
+++ b/System/Dungeon/TrialExchangeWin.cs
@@ -98,8 +98,19 @@
         #endregion
         private void OnRefreshCell(ScrollerDataType type, CellView cell)
         {
-            TrialExchangeCell trialExchangeCell = cell as TrialExchangeCell;
-            trialExchangeCell.Display(cell.index);
+            switch (type)
+            {
+                case ScrollerDataType.Header:
+                    var _class = cell.index / 100;
+                    var _line = cell.index % 100;
+                    TrialExchangeCell trialExchangeCell = cell as TrialExchangeCell;
+                    trialExchangeCell.Display(_class, _line);
+                    break;
+                case ScrollerDataType.Normal:
+                    TrialExchangeTitleCell trialExchangeTitleCell = cell as TrialExchangeTitleCell;
+                    trialExchangeTitleCell.Display(cell.index);
+                    break;
+            }
         }
 
         private void SelectClassUp()
@@ -124,10 +135,19 @@
             m_Controller.Refresh();
             if (model.selectEquipClass == 1)
             {
-                var configs = ConfigManager.Instance.GetAllValues<TrialExchangeConfig>();
-                for (int i = 0; i < configs.Count; i++)
+                var trialClasses = model.GetTotalClass();
+                for (int i = 0; i < trialClasses.Count; i++)
                 {
-                    m_Controller.AddCell(ScrollerDataType.Header, configs[i].id);
+                    List<TrialExchangeConfig> list;
+                    if (model.TryGetTrialExchanges(trialClasses[i], out list))
+                    {
+                        m_Controller.AddCell(ScrollerDataType.Normal, trialClasses[i]);
+                        var line = Mathf.CeilToInt((float)list.Count / 4);
+                        for (int k = 0; k < line; k++)
+                        {
+                            m_Controller.AddCell(ScrollerDataType.Header, trialClasses[i] * 100 + k);
+                        }
+                    }
                 }
             }
             else
@@ -135,9 +155,10 @@
                 List<TrialExchangeConfig> list;
                 if (model.TryGetTrialExchanges(model.selectEquipClass, out list))
                 {
-                    for (int i = 0; i < list.Count; i++)
+                    var line = Mathf.CeilToInt((float)list.Count / 4);
+                    for (int i = 0; i < line; i++)
                     {
-                        m_Controller.AddCell(ScrollerDataType.Header, list[i].id);
+                        m_Controller.AddCell(ScrollerDataType.Header, model.selectEquipClass * 100 + i);
                     }
                 }
             }

--
Gitblit v1.8.0