From 4c3f9dc75ca9ab8785c622a555a7454986f43ed4 Mon Sep 17 00:00:00 2001
From: Client_PangDeRong <593317293@qq.com>
Date: 星期二, 21 八月 2018 17:39:24 +0800
Subject: [PATCH] [1885]神兽开发

---
 System/Dogz/DogzActiveWin.cs           |   42 +++++-
 System/Dogz/DogzPackWin.cs             |   23 +++
 System/Dogz/DogzWin.cs                 |    2 
 System/Dogz/SelectDogzItemWin.cs.meta  |   12 ++
 System/KnapSack/Logic/ItemTipsModel.cs |    2 
 System/Dogz/SelectCell.cs.meta         |   12 ++
 System/Dogz/DogzModel.cs               |  132 +++++++++++++++++++++
 System/Dogz/SelectCell.cs              |   30 +++++
 System/KnapSack/Logic/EquipTip.cs      |   36 ++++-
 System/Dogz/SelectDogzItemWin.cs       |   53 ++++++++
 10 files changed, 319 insertions(+), 25 deletions(-)

diff --git a/System/Dogz/DogzActiveWin.cs b/System/Dogz/DogzActiveWin.cs
index 6007c59..262415b 100644
--- a/System/Dogz/DogzActiveWin.cs
+++ b/System/Dogz/DogzActiveWin.cs
@@ -60,7 +60,6 @@
 
         protected override void OnPreOpen()
         {
-            SelectDecide();
             GenerateDogz();
             UpdateSelectDogzEvent();
             UpdateDogzAssistCnt();
@@ -86,12 +85,6 @@
         {
         }
         #endregion
-
-        void SelectDecide()
-        {
-            var configs = ConfigManager.Instance.GetAllValues<DogzConfig>();
-            model.presentSelectDogz = configs[0].ID;
-        }
 
         void GenerateDogz()
         {
@@ -155,6 +148,7 @@
         {
             if (dogzId != model.presentSelectDogz) return;
             UpdateDogzEquip();
+            UpdateDogzProperty();
         }
 
         private void UpdateDogzEquip()
@@ -177,6 +171,11 @@
         private void UpdateDogzProperty()
         {
             var _dogzCfg = ConfigManager.Instance.GetTemplate<DogzConfig>(model.presentSelectDogz);
+            bool isAddAttr = model.GetDogzEquips(model.presentSelectDogz) != null && model.GetDogzEquips(model.presentSelectDogz).Count == 5 ? true : false;
+            if(isAddAttr)
+            {
+                model.GetDogzEquipAddAttr(model.presentSelectDogz);
+            }
             for (int i = 0; i < m_PropertyTypes.Count; i++)
             {
                 m_PropertyTypes[i].gameObject.SetActive(i < _dogzCfg.BaseAttrTypes.Length);
@@ -185,8 +184,31 @@
                 {
                     var _propertyCfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(_dogzCfg.BaseAttrTypes[i]);
                     m_PropertyTypes[i].text = _propertyCfg.Name;
-                    m_PropertyValues[i].text = StringUtility.Contact(UIHelper.ReplacePercentage(_dogzCfg.BaseAttrValues[i], _propertyCfg.ISPercentage)
-                        , _propertyCfg.ISPercentage == 1 ? "%" : string.Empty);
+                    int attrValue = _dogzCfg.BaseAttrValues[i];
+
+                    if (isAddAttr && model.m_DogzEquipAttrDict[_propertyCfg.ID] > 0)
+                    {
+                        m_PropertyValues[i].text = StringUtility.Contact(UIHelper.ReplacePercentage(_dogzCfg.BaseAttrValues[i], _propertyCfg.ISPercentage)
+                      , _propertyCfg.ISPercentage == 1 ? "%" : string.Empty,"+",UIHelper.ReplacePercentage(model.m_DogzEquipAttrDict[_propertyCfg.ID], _propertyCfg.ISPercentage)
+                      , _propertyCfg.ISPercentage == 1 ? "%" : string.Empty);
+                    }
+                    else
+                    {
+                        m_PropertyValues[i].text = StringUtility.Contact(UIHelper.ReplacePercentage(_dogzCfg.BaseAttrValues[i], _propertyCfg.ISPercentage)
+                      , _propertyCfg.ISPercentage == 1 ? "%" : string.Empty);
+                    }
+                  
+                }
+
+                if(model.TryGetAssistDogzState(model.presentSelectDogz))
+                {
+                    m_PropertyTypes[i].material = MaterialUtility.GetUIDefaultGraphicMaterial();
+                    m_PropertyValues[i].material = MaterialUtility.GetUIDefaultGraphicMaterial();
+                }
+                else
+                {
+                    m_PropertyTypes[i].material = MaterialUtility.GetDefaultSpriteGrayMaterial();
+                    m_PropertyValues[i].material = MaterialUtility.GetDefaultSpriteGrayMaterial();
                 }
             }
         }
@@ -212,7 +234,7 @@
         }
         private void TakeOffEquip()
         {
-            model.SendPutOffEquip(0);
+            model.CheckPutOff(0);
         }
         private void OpenEquipPack()
         {
diff --git a/System/Dogz/DogzModel.cs b/System/Dogz/DogzModel.cs
index 5f0fc72..0b9995c 100644
--- a/System/Dogz/DogzModel.cs
+++ b/System/Dogz/DogzModel.cs
@@ -21,7 +21,9 @@
             SelectDogzItemQuality = 0;
             SelectDogzItemStart = 0;
             dogzItemList = new List<ItemModel>();
+            selectEquipPlacelist = new List<ItemModel>();
             dogzAssistStateDict = new Dictionary<int, int>();
+            m_DogzEquipAttrDict = new Dictionary<int, int>();
         }
 
         public void OnAfterPlayerDataInitialize()
@@ -58,7 +60,7 @@
                 var _dict = new Dictionary<int, int>();
                 for(int j = 0; j < _dogzCfgs[i].EquipPlaceColorList.Length; j++)
                 {
-                    _dict.Add(j+1, _dogzCfgs[i].EquipPlaceColorList[j]);
+                    _dict.Add(j, _dogzCfgs[i].EquipPlaceColorList[j]);
                 }
                 m_DogzEquipLimit.Add(_dogzCfgs[i].ID, _dict);
             }
@@ -138,7 +140,7 @@
 
         public int GetAssistItemCnt()
         {
-            return AddAssistItemCnt[0];
+            return AddAssistItemCnt[addAssistCnt];
         }
 
         public int presentSelectDogz { get; set; } //褰撳墠閫変腑鐨勭鍏絠d
@@ -189,7 +191,7 @@
             int assistCnt = 0;
             foreach(var key in dogzAssistStateDict.Keys)
             {
-                if(key == 1)
+                if(dogzAssistStateDict[key] == 1)
                 {
                     assistCnt += 1;
                 }
@@ -297,6 +299,53 @@
             return _list;
         }
 
+        /// <summary>
+        /// 鑾峰緱鍔╂垬灞炴�у姞鎴�
+        /// </summary>
+        public Dictionary<int,int> m_DogzEquipAttrDict { get; private set; }
+        public Dictionary<int,int> GetDogzEquipAddAttr(int dogzId)
+        {
+            m_DogzEquipAttrDict.Clear();
+            DogzConfig dogzConfig = ConfigManager.Instance.GetTemplate<DogzConfig>(dogzId);
+            int[] baseAttrIds = dogzConfig.BaseAttrTypes;
+            for(int i = 0; i < baseAttrIds.Length; i++)
+            {
+                int attrValue = 0;
+                List<ItemModel> itemModels = GetDogzEquips(dogzId);
+                if(itemModels != null)
+                {
+                    for(int j = 0; j < itemModels.Count; j++)
+                    {
+                        ItemConfig itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(itemModels[j].itemId);
+
+                        if(itemConfig.Effect1 == baseAttrIds[i])
+                        {
+                            attrValue += itemConfig.EffectValueA1;
+                        }
+                        if (itemConfig.Effect2 == baseAttrIds[i])
+                        {
+                            attrValue += itemConfig.EffectValueA2;
+                        }
+                        if (itemConfig.Effect3 == baseAttrIds[i])
+                        {
+                            attrValue += itemConfig.EffectValueA3;
+                        }
+                        if (itemConfig.Effect4 == baseAttrIds[i])
+                        {
+                            attrValue += itemConfig.EffectValueA4;
+                        }
+                        if (itemConfig.Effect5 == baseAttrIds[i])
+                        {
+                            attrValue += itemConfig.EffectValueA5;
+                        }
+                    }
+                }
+
+                m_DogzEquipAttrDict.Add(baseAttrIds[i], attrValue);
+            }
+            return m_DogzEquipAttrDict;
+        }
+
         public int GetDogzEquipPlaceByIndex(int index)
         {
             return (index % 5) + 101;
@@ -335,6 +384,26 @@
             return false;
         }
 
+        public void CheckPutOff(int equipPlace)
+        {
+            if (TryGetAssistDogzState(presentSelectDogz))
+            {
+                ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),"褰撳墠绁炲吔鍔╂垬涓紝鍗镐笅瑁呭鏃犳硶淇濇寔鍔╂垬鐘舵�侊紝纭畾缁х画锛�",
+                    (bool isOk)=>
+                    {
+                        if(isOk)
+                        {
+                            SendPutOffEquip(equipPlace);
+                        }
+                        return;
+                    });
+            }
+            else
+            {
+                SendPutOffEquip(equipPlace);
+            }
+        }
+
         public void SendPutOnEquip(int index)
         {
             CA5C0_tagCMDogzEquipItem dogzPutOn = new CA5C0_tagCMDogzEquipItem();
@@ -343,7 +412,7 @@
             GameNetSystem.Instance.SendInfo(dogzPutOn);
         }
 
-        public void SendPutOffEquip(int equipPlace)
+        private void SendPutOffEquip(int equipPlace)
         {
             CA5C1_tagCMDogzUnEquipItem dogzPutOff = new CA5C1_tagCMDogzUnEquipItem();
             dogzPutOff.DogzID = (byte)presentSelectDogz;
@@ -419,6 +488,43 @@
 
             return false;
         }
+
+        public List<ItemModel> selectEquipPlacelist { get; private set; }
+        public List<ItemModel> GetDogzItemListByIndex(int index)
+        {
+            SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptDogzItem);
+            selectEquipPlacelist.Clear();
+            if (singlePack == null) return selectEquipPlacelist;
+
+            var _itemColor = GetDogzEquipLimitByIndex(presentSelectDogz, index);
+            var _equipPlace = GetDogzEquipPlaceByIndex(index);
+            Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
+            foreach (var value in pairs.Values)
+            {
+                if(value.chinItemModel.EquipPlace == _equipPlace
+                    && value.chinItemModel.ItemColor >= _itemColor)
+                {
+                    selectEquipPlacelist.Add(value);
+                }
+            }
+            selectEquipPlacelist.Sort(CompareByDogzItem);
+            return selectEquipPlacelist;
+        }
+
+        private int CompareByDogzItem(ItemModel start,ItemModel end)
+        {
+            int x = start.chinItemModel.ItemColor;
+            int y = end.chinItemModel.ItemColor;
+            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
+            x = start.chinItemModel.StarLevel;
+            y = end.chinItemModel.StarLevel;
+            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
+            x = start.equipScore;
+            y = end.equipScore;
+            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
+
+            return 0;
+        }
         #endregion
 
         #region 瑁呭璇︾粏淇℃伅
@@ -441,6 +547,24 @@
             return 0;
         }
         #endregion
+
+        #region 榛樿閫夋嫨閫昏緫澶勭悊
+        public void SetDefaultSelectDogz()
+        {
+            var configs = ConfigManager.Instance.GetAllValues<DogzConfig>();
+            presentSelectDogz = configs[0].ID;
+            foreach (var key in dogzAssistStateDict.Keys)
+            {
+                if(dogzAssistStateDict[key] == 1)
+                {
+                    if(presentSelectDogz < key)
+                    {
+                        presentSelectDogz = key;
+                    }
+                }
+            }
+        }
+        #endregion
     }
 }
 
diff --git a/System/Dogz/DogzPackWin.cs b/System/Dogz/DogzPackWin.cs
index af1316d..3d00cc6 100644
--- a/System/Dogz/DogzPackWin.cs
+++ b/System/Dogz/DogzPackWin.cs
@@ -8,6 +8,7 @@
 using System.Collections.Generic;
 using TableConfig;
 using UnityEngine;
+using UnityEngine.Events;
 using UnityEngine.UI;
 
 namespace Snxxz.UI {
@@ -103,6 +104,7 @@
             for (int i = 0; i < m_DogzEquips.Count; i++)
             {
                 ItemModel _data;
+                int index = i;
                 bool _equiped = dogzModel.TryGetDogzEquip(dogzModel.presentSelectDogz, i, out _data);
                 m_DogzUnEquipBtns[i].gameObject.SetActive(!_equiped);
                 m_DogzEquips[i].gameObject.SetActive(_equiped);
@@ -116,10 +118,31 @@
                     m_DogzUnEquipContents[i].text = StringUtility.Contact(DogzModel.GetItemColorName(_itemColor),
                         DogzModel.GetDogzPartNameByIndex(i));
                     m_DogzUnEquipContents[i].color = UIHelper.GetUIColor(_itemColor);
+                    m_DogzUnEquipBtns[i].RemoveAllListeners();
+                    m_DogzUnEquipBtns[i].AddListener(() => { ClickEquipIndex(index); });
                 }
             }
         }
 
+        private void ClickEquipIndex(int index)
+        {
+            dogzModel.GetDogzItemListByIndex(index);
+            if(dogzModel.selectEquipPlacelist.Count > 0)
+            {
+                WindowCenter.Instance.Open<SelectDogzItemWin>();
+            }
+            else
+            {
+                ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),"鑳屽寘涓病鏈夎閮ㄤ綅鍙┛鎴寸殑瑁呭",(bool isOk)=>
+                {
+                    if(isOk)
+                    {
+
+                    }
+                    return;
+                });
+            }
+        }
 
         private void RefreshDogzSelectEvent(int type)
         {
diff --git a/System/Dogz/DogzWin.cs b/System/Dogz/DogzWin.cs
index e5c2ff7..7a6c76f 100644
--- a/System/Dogz/DogzWin.cs
+++ b/System/Dogz/DogzWin.cs
@@ -21,6 +21,7 @@
         [SerializeField] FunctionButton functionButtonStrengthen;
         [SerializeField] FunctionButtonGroup funcBtnGroup;
 
+        DogzModel dogzModel { get { return ModelCenter.Instance.GetModel<DogzModel>(); } }
         protected override void BindController()
         {
         }
@@ -54,6 +55,7 @@
 
         protected override void OnPreOpen()
         {
+            dogzModel.SetDefaultSelectDogz();
         }
 
         protected override void OnActived()
diff --git a/System/Dogz/SelectCell.cs b/System/Dogz/SelectCell.cs
new file mode 100644
index 0000000..9eca5ca
--- /dev/null
+++ b/System/Dogz/SelectCell.cs
@@ -0,0 +1,30 @@
+锘縰sing EnhancedUI.EnhancedScroller;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Snxxz.UI
+{
+    public class SelectCell : ScrollerUI
+    {
+        [SerializeField] Text nameTex;
+        [SerializeField] CommonItemBaisc itemBaisc;
+        [SerializeField] Button selectBtn;
+        DogzModel dogzModel { get { return ModelCenter.Instance.GetModel<DogzModel>(); } }
+
+        public override void Refresh(CellView cell)
+        {
+            if (cell.index >= dogzModel.selectEquipPlacelist.Count) return;
+
+            ItemModel model = dogzModel.selectEquipPlacelist[cell.index];
+            nameTex.text = model.chinItemModel.ItemName;
+            nameTex.color = UIHelper.GetUIColor(model.chinItemModel.ItemColor);
+            itemBaisc.Init(model);
+            selectBtn.RemoveAllListeners();
+            selectBtn.AddListener(()=>
+            {
+                dogzModel.SendPutOnEquip(model.itemInfo.ItemPlace);
+                WindowCenter.Instance.CloseImmediately<SelectDogzItemWin>();
+            });
+        }
+    }
+}
diff --git a/System/Dogz/SelectCell.cs.meta b/System/Dogz/SelectCell.cs.meta
new file mode 100644
index 0000000..698be10
--- /dev/null
+++ b/System/Dogz/SelectCell.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: fdd7aaa6f855054448570bc63608ceb8
+timeCreated: 1534834007
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Dogz/SelectDogzItemWin.cs b/System/Dogz/SelectDogzItemWin.cs
new file mode 100644
index 0000000..1607a64
--- /dev/null
+++ b/System/Dogz/SelectDogzItemWin.cs
@@ -0,0 +1,53 @@
+锘縰sing System;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Snxxz.UI
+{
+    public class SelectDogzItemWin : Window
+    {
+        [SerializeField] ScrollerController ctrl;
+        [SerializeField] Button closeBtn;
+        DogzModel dogzModel { get { return ModelCenter.Instance.GetModel<DogzModel>(); } }
+
+        protected override void BindController()
+        {
+           
+        }
+
+        protected override void AddListeners()
+        {
+            closeBtn.AddListener(CloseClick);
+        }
+
+        protected override void OnPreOpen()
+        {
+            CreateSelectItem();
+        }
+
+        protected override void OnAfterOpen()
+        {
+         
+        }
+
+        protected override void OnPreClose()
+        {
+           
+        }
+
+        protected override void OnAfterClose()
+        {
+
+        }
+
+        private void CreateSelectItem()
+        {
+            ctrl.Refresh();
+            for(int i = 0; i < dogzModel.selectEquipPlacelist.Count; i++)
+            {
+                ctrl.AddCell(ScrollerDataType.Header,i);
+            }
+            ctrl.Restart();
+        }
+    }
+}
diff --git a/System/Dogz/SelectDogzItemWin.cs.meta b/System/Dogz/SelectDogzItemWin.cs.meta
new file mode 100644
index 0000000..2368a6f
--- /dev/null
+++ b/System/Dogz/SelectDogzItemWin.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 82cf9b82cfbdeed478bac6785c72367e
+timeCreated: 1534833403
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/KnapSack/Logic/EquipTip.cs b/System/KnapSack/Logic/EquipTip.cs
index 08866c9..6ad0dc4 100644
--- a/System/KnapSack/Logic/EquipTip.cs
+++ b/System/KnapSack/Logic/EquipTip.cs
@@ -105,6 +105,7 @@
         EquipSource equipSourceDes;
         [SerializeField]
         Text equipSourceText;
+        [SerializeField] Text dogzEquipDesText;
         #endregion
 
         [SerializeField]
@@ -562,7 +563,9 @@
 
         private void SetGemAttrUI()
         {   
-            if (itemAttrData.itemConfig.LV < itemTipsModel.gemOpenLvs[0])
+            if (itemAttrData.itemConfig.LV < itemTipsModel.gemOpenLvs[0]
+                || itemAttrData.packType == PackType.rptDogzEquip
+                || itemAttrData.packType == PackType.rptDogzItem)
             {
                 gemAttr.SetActive(false);
                 return;
@@ -822,21 +825,34 @@
 
         private void SetBottomUI()
         {
-            if (itemAttrData.itemConfig.Description == "" || string.IsNullOrEmpty(itemAttrData.itemConfig.Description))
+            if(itemAttrData.packType != PackType.rptDogzItem && itemAttrData.packType != PackType.rptDogzEquip)
             {
-                equipSourceNormal.gameObject.SetActive(true);
-                equipSourceDes.gameObject.SetActive(false);
-                equipSourceText.gameObject.SetActive(false);
-                SetBottomText(equipSourceNormal);
+                dogzEquipDesText.gameObject.SetActive(false);
+                if (itemAttrData.itemConfig.Description == "" || string.IsNullOrEmpty(itemAttrData.itemConfig.Description))
+                {
+                    equipSourceNormal.gameObject.SetActive(true);
+                    equipSourceDes.gameObject.SetActive(false);
+                    equipSourceText.gameObject.SetActive(false);
+                    SetBottomText(equipSourceNormal);
+                }
+                else
+                {
+                    equipSourceNormal.gameObject.SetActive(false);
+                    equipSourceDes.gameObject.SetActive(true);
+                    equipSourceText.gameObject.SetActive(true);
+                    SetBottomText(equipSourceDes);
+                    equipSourceText.text = itemAttrData.itemConfig.Description;
+                }
             }
             else
             {
                 equipSourceNormal.gameObject.SetActive(false);
-                equipSourceDes.gameObject.SetActive(true);
-                equipSourceText.gameObject.SetActive(true);
-                SetBottomText(equipSourceDes);
-                equipSourceText.text = itemAttrData.itemConfig.Description;
+                equipSourceDes.gameObject.SetActive(false);
+                equipSourceText.gameObject.SetActive(false);
+                dogzEquipDesText.gameObject.SetActive(true);
+                dogzEquipDesText.text = itemAttrData.itemConfig.Description;
             }
+           
         }
 
         private void SetBottomText(EquipSource source)
diff --git a/System/KnapSack/Logic/ItemTipsModel.cs b/System/KnapSack/Logic/ItemTipsModel.cs
index 20a4fc0..b819c8b 100644
--- a/System/KnapSack/Logic/ItemTipsModel.cs
+++ b/System/KnapSack/Logic/ItemTipsModel.cs
@@ -708,7 +708,7 @@
             if (attrData == null) return;
 
             attrData.SetTipsFuncBtn(ItemWinBtnType.putOff, (ItemWinBtnType, ItemAttrData) => {
-               dogzModel.SendPutOffEquip(dogzModel.GetDogzEquipPlaceByIndex(attrData.index));
+               dogzModel.CheckPutOff(dogzModel.GetDogzEquipPlaceByIndex(attrData.index));
             });
 
             attrData.SetTipsFuncBtn(ItemWinBtnType.strength, (ItemWinBtnType, ItemAttrData) => {

--
Gitblit v1.8.0