From 04b3034c07f86aad4493f3be4bd26e2094c10d0c Mon Sep 17 00:00:00 2001
From: client_Zxw <826696702@qq.com>
Date: 星期一, 20 八月 2018 21:27:24 +0800
Subject: [PATCH] [2614]神兽开发

---
 System/Strengthening/GodBeastChildNodes.cs       |   42 ++++++
 System/Strengthening/GodBeastEntry.cs            |   22 ++
 System/Strengthening/GodBeastSlidingList.cs      |  279 +++++++++++++++++++++++++++++++++++++--
 System/Strengthening/GodBeastReinforcementWin.cs |   33 ++++
 System/Strengthening/GodBeastChildNodes.cs.meta  |   12 +
 5 files changed, 361 insertions(+), 27 deletions(-)

diff --git a/System/Strengthening/GodBeastChildNodes.cs b/System/Strengthening/GodBeastChildNodes.cs
new file mode 100644
index 0000000..a3967e5
--- /dev/null
+++ b/System/Strengthening/GodBeastChildNodes.cs
@@ -0,0 +1,42 @@
+锘�//--------------------------------------------------------
+//    [Author]:           绗簩涓栫晫
+//    [  Date ]:           Monday, August 20, 2018
+//--------------------------------------------------------
+using UnityEngine;
+using System.Collections;
+using UnityEngine.UI;
+
+namespace Snxxz.UI {
+
+    public class GodBeastChildNodes:MonoBehaviour {
+        [SerializeField] ItemCell m_ItemCell;
+        [SerializeField] GameObject m_ChoosenImg;
+        [SerializeField] Text m_TextNumber;
+        [SerializeField] Button m_Button;
+
+        public Button ButtonDown
+        {
+            get { return m_Button; }
+            set { m_Button = value; }
+        }
+        public GameObject ChoosenImg
+        {
+            get { return m_ChoosenImg; }
+            set { m_ChoosenImg = value; }
+        }
+        public ItemCell ItemCell
+        {
+            get { return m_ItemCell; }
+            set { m_ItemCell = value; }
+        }
+        public Text TextNumber
+        {
+            get { return m_TextNumber; }
+            set { m_TextNumber = value; }
+        }
+    }
+
+}
+
+
+
diff --git a/System/Strengthening/GodBeastChildNodes.cs.meta b/System/Strengthening/GodBeastChildNodes.cs.meta
new file mode 100644
index 0000000..6132d0c
--- /dev/null
+++ b/System/Strengthening/GodBeastChildNodes.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 589b5dafae4252347a827e827ae08ba3
+timeCreated: 1534766620
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Strengthening/GodBeastEntry.cs b/System/Strengthening/GodBeastEntry.cs
index 4119582..14956bd 100644
--- a/System/Strengthening/GodBeastEntry.cs
+++ b/System/Strengthening/GodBeastEntry.cs
@@ -16,10 +16,17 @@
         [SerializeField] ItemCell m_itemCell;
         [SerializeField] GameObject m_Selectedbar_Image;
         [SerializeField] Text m_Item_Text;
-        //[SerializeField] Button //
+        [SerializeField] Button m_GodBeastButton;
+
+        public Button GodBeastButton
+        {
+            get { return m_GodBeastButton; }
+            set { m_GodBeastButton = value; }
+        }
+
         DogzModel Dogz_model;
         DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel<DogzModel>()); } }
-        public void GetGodBeastLocationMarker(int locationMarker)
+        public void GetGodBeastLocationMarker(int locationMarker, int currentlySelected)
         {
             int godBeastNumber = locationMarker / 10;
             int godBeastPart = locationMarker % 10;
@@ -43,12 +50,17 @@
                         {
                             m_Item_Text.text = itemConfig.ItemName;
                         }
+                        if (locationMarker == currentlySelected)
+                        {
+                            m_Selectedbar_Image.SetActive(true);
+                        }
+                        else
+                        {
+                            m_Selectedbar_Image.SetActive(false);
+                        }
                     }
-
                 }
-
             }
-
         }
     }
 
diff --git a/System/Strengthening/GodBeastReinforcementWin.cs b/System/Strengthening/GodBeastReinforcementWin.cs
index 9750523..d500c10 100644
--- a/System/Strengthening/GodBeastReinforcementWin.cs
+++ b/System/Strengthening/GodBeastReinforcementWin.cs
@@ -20,6 +20,7 @@
         public int GodBeastQuality;//绁炲吔鍝佽川
         public int GodBeastStar;//绁炲吔鏄熺骇
         public int LocationMarker;//浣嶇疆鏍囪
+        public int EquipScore;//瑁呭璇勫垎
     }
     public class GodBeastReinforcementWin : Window
     {
@@ -30,6 +31,7 @@
         DogzModel Dogz_model;
         DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel<DogzModel>()); } }
         private List<GodBeastClass> GodBeastList = new List<GodBeastClass>();
+        private int CurrentlySelected = 0;
         #region Built-in
         protected override void BindController()
         {
@@ -47,6 +49,7 @@
             OnCreateGridLineCell(m_ScrollerController);
             if (GodBeastList.Count > 0)
             {
+                CurrentlySelected = GodBeastList[0].LocationMarker;
                 m_ScrollerController.JumpIndex(0);
             }     
             m_GodBeastSlidingList.Init();
@@ -57,8 +60,7 @@
         }
 
         protected override void OnPreClose()
-        {
-            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+        {        
             m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
         }
 
@@ -85,9 +87,18 @@
                         godBeastClass.GodBeastPart = itemModel[i].EquipPlace;
                         godBeastClass.GodBeastQuality = itemModel[i].chinItemModel.ItemColor;
                         godBeastClass.GodBeastStar = itemModel[i].chinItemModel.StarLevel;
+                        godBeastClass.EquipScore = itemModel[i].equipScore;
                         var IudetDogzEquipPlus = itemModel[i].GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus);// 绁炲吔瑁呭寮哄寲淇℃伅鍒楄〃 [寮哄寲绛夌骇, 寮哄寲鐔熺粌搴
-                        godBeastClass.GodBeastLv = IudetDogzEquipPlus[0];
-                        godBeastClass.GodBeasProficiency = IudetDogzEquipPlus[1];
+                        if (IudetDogzEquipPlus == null)
+                        {
+                            godBeastClass.GodBeastLv = 0;
+                            godBeastClass.GodBeasProficiency = 0;
+                        }
+                        else
+                        {
+                            godBeastClass.GodBeastLv = IudetDogzEquipPlus[0];
+                            godBeastClass.GodBeasProficiency = IudetDogzEquipPlus[1];
+                        }                                  
                         godBeastClass.LocationMarker= key*10+ itemModel[i].EquipPlace;
                         GodBeastList.Add(godBeastClass);
                     }
@@ -117,6 +128,10 @@
             {
                 return -x.GodBeasProficiency.CompareTo(y.GodBeasProficiency);
             }
+            if (x.EquipScore.CompareTo(y.EquipScore) != 0)//瑁呭璇勫垎
+            {
+                return -x.EquipScore.CompareTo(y.EquipScore);
+            }
             return 1;
         }
         void OnCreateGridLineCell(ScrollerController gridCtrl)
@@ -142,6 +157,16 @@
         {
             GodBeastEntry godBeastEntry = cell.GetComponent<GodBeastEntry>();
             int locationMarker = cell.index;
+            godBeastEntry.GetGodBeastLocationMarker(locationMarker, CurrentlySelected);
+            godBeastEntry.GodBeastButton.RemoveAllListeners();
+            godBeastEntry.GodBeastButton.AddListener(()=> 
+            {
+                if (locationMarker != CurrentlySelected)
+                {
+                    CurrentlySelected = locationMarker;
+                    m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                }             
+            });
         }
     }
 
diff --git a/System/Strengthening/GodBeastSlidingList.cs b/System/Strengthening/GodBeastSlidingList.cs
index 54de49c..626336b 100644
--- a/System/Strengthening/GodBeastSlidingList.cs
+++ b/System/Strengthening/GodBeastSlidingList.cs
@@ -5,10 +5,26 @@
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
-//绁炲吔寮哄寲鍙充晶鏉愭枡鍚告敹鍒楄〃
-namespace Snxxz.UI {
+using System.Collections.Generic;
+using System;
+//绁炲吔寮哄寲鍙充晶鏉愭枡鍚告敹鍒楄〃
+namespace Snxxz.UI
+{
+    public class GodBeastBagClass
+    {
+        public int ItemId;//ID
+        public int Index;//涓嬫爣
+        public int IsEquipment;//鏄惁瑁呭0姘存櫠锛�1瑁呭
+        public int Color;//鍝佽川棰滆壊
+        public int Star;//鏄熺骇
+        public int LV;//绛夌骇
+        public int Proficiency;//鐔熺粌搴�
+        public int EquipScore;//瑁呭璇勫垎
+        public int Part;//瑁呭浣�
+    }
 
-    public class GodBeastSlidingList:MonoBehaviour {
+    public class GodBeastSlidingList : MonoBehaviour
+    {
         [SerializeField] ScrollerController m_ScrollerController;
 
         [SerializeField] Text m_Label;
@@ -23,27 +39,103 @@
         [SerializeField] Toggle m_ToggleAll;
         public int LINE = 10;
 
+        public static event Action<Dictionary<int, int>> AbsorbEvent;
+        private List<GodBeastBagClass> GodBeastBagList = new List<GodBeastBagClass>();
+        private List<int> DeleteIndexList = new List<int>();
+        private Dictionary<int, int> AbsorptionDic = new Dictionary<int, int>();
         private int Quality = 10;
+        PlayerPackModel _playerPack;
+        PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } }
         private void Start()
         {
             m_Arrow.AddListener(OnClickArrow);
-            m_ButtonAll.AddListener(()=>{ OnClickSwith(10); });
-            m_ButtonCrystal.AddListener(() => { OnClickSwith(1);});
-            m_ButtonBlue.AddListener(() => { OnClickSwith(2); });
-            m_ButtonPurple.AddListener(() => { OnClickSwith(3); });
-            m_ButtonOrange.AddListener(() => { OnClickSwith(4); });
+            m_ButtonAll.AddListener(() =>
+            {
+                OnClickSwith(10);
+                if (m_ToggleAll.isOn)
+                {
+                    m_ToggleAll.isOn = false;
+                }
+                GetGodBeastBag();
+                FilterQuality();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                if (AbsorbEvent != null)
+                {
+                    AbsorbEvent(AbsorptionDic);
+                }
+            });
+            m_ButtonCrystal.AddListener(() =>
+            {
+                OnClickSwith(0);
+                if (m_ToggleAll.isOn)
+                {
+                    m_ToggleAll.isOn = false;
+                }
+                GetGodBeastBag();
+                FilterQuality();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                if (AbsorbEvent != null)
+                {
+                    AbsorbEvent(AbsorptionDic);
+                }
+            });
+            m_ButtonBlue.AddListener(() =>
+            {
+                OnClickSwith(2);
+                if (m_ToggleAll.isOn)
+                {
+                    m_ToggleAll.isOn = false;
+                }
+                GetGodBeastBag();
+                FilterQuality();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                if (AbsorbEvent != null)
+                {
+                    AbsorbEvent(AbsorptionDic);
+                }
+            });
+            m_ButtonPurple.AddListener(() =>
+            {
+                OnClickSwith(3);
+                if (m_ToggleAll.isOn)
+                {
+                    m_ToggleAll.isOn = false;
+                }
+                GetGodBeastBag();
+                FilterQuality();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                if (AbsorbEvent != null)
+                {
+                    AbsorbEvent(AbsorptionDic);
+                }
+            });
+            m_ButtonOrange.AddListener(() =>
+            {
+                OnClickSwith(4);
+                if (m_ToggleAll.isOn)
+                {
+                    m_ToggleAll.isOn = false;
+                }
+                GetGodBeastBag();
+                FilterQuality();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                if (AbsorbEvent != null)
+                {
+                    AbsorbEvent(AbsorptionDic);
+                }
+            });
             m_ToggleAll.onValueChanged.AddListener(OnClickToggle);
         }
         private void OnEnable()
         {
-            
+
         }
         private void OnDisable()
         {
-            
+
         }
 
-        public void  Init()
+        public void Init()
         {
             Quality = 10;
             ContentSelect(Quality);
@@ -55,6 +147,8 @@
             {
                 m_ToggleAll.isOn = false;
             }
+            GetGodBeastBag();//鑾峰彇绁炲吔鑳屽寘鏁版嵁鎺掑簭
+            FilterQuality();//鍒嗙被绛涢��
             m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
             OnCreateGridLineCell(m_ScrollerController);
 
@@ -65,6 +159,114 @@
             m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
         }
 
+        private void GetGodBeastBag()//鑾峰彇绁炲吔鑳屽寘鏁版嵁鎺掑簭
+        {
+            GodBeastBagList.Clear();
+            if (playerPack.GetSinglePackModel(PackType.rptDogzItem) == null)
+            {
+                return;
+            }
+            Dictionary<int, ItemModel> BackpackDic = playerPack.GetSinglePackModel(PackType.rptDogzItem).GetPackModelIndexDict();
+            foreach (var key in BackpackDic.Keys)
+            {
+                var itemModel = BackpackDic[key];
+                GodBeastBagClass godBeastBagClass = new GodBeastBagClass();
+                godBeastBagClass.ItemId = itemModel.itemId;
+                godBeastBagClass.Index = key;
+                if (itemModel.chinItemModel.Type != 70)
+                {
+                    godBeastBagClass.IsEquipment = 1;
+                }
+                else
+                {
+                    godBeastBagClass.IsEquipment = 0;
+                }
+                godBeastBagClass.Color = itemModel.chinItemModel.ItemColor;
+                godBeastBagClass.Star = itemModel.chinItemModel.StarLevel;
+                godBeastBagClass.EquipScore = itemModel.equipScore;
+                godBeastBagClass.Part = itemModel.EquipPlace;
+                var IudetDogzEquipPlus = itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus);// 绁炲吔瑁呭寮哄寲淇℃伅鍒楄〃 [寮哄寲绛夌骇, 寮哄寲鐔熺粌搴
+                if (IudetDogzEquipPlus == null)
+                {
+                    godBeastBagClass.LV = 0;
+                    godBeastBagClass.Proficiency = 0;
+                   
+                }
+                else
+                {
+                    godBeastBagClass.LV = IudetDogzEquipPlus[0];
+                    godBeastBagClass.Proficiency = IudetDogzEquipPlus[1];
+                }
+               
+                GodBeastBagList.Add(godBeastBagClass);
+            }
+            GodBeastBagList.Sort(Compare);
+        }
+        int Compare(GodBeastBagClass x, GodBeastBagClass y)
+        {
+            if (x.IsEquipment.CompareTo(y.IsEquipment) != 0)//鏄惁寮哄寲姘存櫠
+            {
+                return x.IsEquipment.CompareTo(y.IsEquipment);
+            }
+            if (x.Proficiency.CompareTo(y.Proficiency) != 0)//寮哄寲鐔熺粌搴�
+            {
+                return -x.Proficiency.CompareTo(y.Proficiency);
+            }
+            if (x.Color.CompareTo(y.Color) != 0)//鍝佽川
+            {
+                return -x.Color.CompareTo(y.Color);
+            }
+            if (x.Star.CompareTo(y.Star) != 0)//鏄熺骇
+            {
+                return -x.Star.CompareTo(y.Star);
+            }
+            if (x.Part.CompareTo(y.Part) != 0)//瑁呭浣�
+            {
+                return x.Part.CompareTo(y.Part);
+            }
+            if (x.EquipScore.CompareTo(y.EquipScore) != 0)//瑁呭璇勫垎
+            {
+                return x.EquipScore.CompareTo(y.EquipScore);
+            }
+            return 1;
+        }
+
+        private void FilterQuality()//鍒嗙被绛涢��
+        {
+            DeleteIndexList.Clear();
+            AbsorptionDic.Clear();
+            for (int i = 0; i < GodBeastBagList.Count; i++)
+            {
+                if (Quality > 0)//鍙湁姘存櫠
+                {
+                    if (GodBeastBagList[i].IsEquipment != 0)
+                    {
+                        int type = i;
+                        DeleteIndexList.Add(type);
+                    }
+                }
+                else
+                {
+                    if (Quality < 10 && (GodBeastBagList[i].IsEquipment == 1 || GodBeastBagList[i].Color > Quality))//杩囨护鎺夊彧鍓╂墍閫夊搧璐ㄨ澶�
+                    {
+                        int type = i;
+                        DeleteIndexList.Add(type);
+                    }
+                }
+            }
+            for (int j = 0; j < DeleteIndexList.Count; j++)
+            {
+                GodBeastBagList.RemoveAt(DeleteIndexList[j]);
+            }
+            if (m_ToggleAll.isOn)
+            {
+                for (int k = 0; k < GodBeastBagList.Count; k++)
+                {
+                    AbsorptionDic.Add(GodBeastBagList[k].Index, 1);
+                }
+            }
+        }
+
         private void OnClickArrow()
         {
             m_ScrollViewFirst.SetActive(!m_ScrollViewFirst.activeSelf);
@@ -72,7 +274,24 @@
 
         private void OnClickToggle(bool IsBool)
         {
+            if (IsBool)
+            {
 
+            }
+            else
+            {
+                if (AbsorptionDic.Count != 0)
+                {
+                    AbsorptionDic.Clear();
+                }
+            }
+            GetGodBeastBag();
+            FilterQuality();
+            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+            if (AbsorbEvent != null)
+            {
+                AbsorbEvent(AbsorptionDic);
+            }
         }
         private void OnClickSwith(int Type)
         {
@@ -87,7 +306,7 @@
         {
             switch (Type)
             {
-                case 1:
+                case 0:
                     m_Label.text = "寮哄寲姘存櫠";
                     break;
                 case 2:
@@ -123,14 +342,38 @@
             int childCode = 0;
             for (childCode = 0; childCode < cell.transform.childCount; childCode++)
             {
-                ChildNodes _ChildNodes = cell.transform.GetChild(childCode).GetComponent<ChildNodes>();
-                _ChildNodes._ItemIcon.SetActive(false);
-                _ChildNodes._Elect.SetActive(false);
+                GodBeastChildNodes GodBeastChildNodes = cell.transform.GetChild(childCode).GetComponent<GodBeastChildNodes>();
+                GodBeastChildNodes.ItemCell.gameObject.SetActive(false);
+                GodBeastChildNodes.ChoosenImg.SetActive(false);
+                GodBeastChildNodes.TextNumber.gameObject.SetActive(false);
                 int cellCount = (cell.transform.childCount) * gridlineIndex + (childCode + 1);
-                if (cellCount - 1 < 1)
+                GodBeastChildNodes.ButtonDown.RemoveAllListeners();
+                if (cellCount - 1 < GodBeastBagList.Count)
                 {
-
-
+                    int index = cellCount - 1;
+                    GodBeastChildNodes.ItemCell.gameObject.SetActive(true);
+                    GodBeastBagClass godBeastBagClass = GodBeastBagList[index];
+                    if (AbsorptionDic.ContainsKey(godBeastBagClass.Index))
+                    {
+                        GodBeastChildNodes.ChoosenImg.SetActive(true);
+                    }
+                    GodBeastChildNodes.ButtonDown.AddListener(() =>
+                    {
+                        if (AbsorptionDic.ContainsKey(godBeastBagClass.Index))
+                        {
+                            AbsorptionDic.Remove(godBeastBagClass.Index);
+                        }
+                        else
+                        {
+                            AbsorptionDic.Add(godBeastBagClass.Index,1);
+                        }
+                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                        if (AbsorbEvent != null)
+                        {
+                            AbsorbEvent(AbsorptionDic);
+                        }
+                    });
+                    
                 }
             }
         }

--
Gitblit v1.8.0