From 4d49bb46fe70db2e883c71ce8c9209734667c7be Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期四, 16 八月 2018 21:20:13 +0800
Subject: [PATCH] 法宝魂修改

---
 System/HappyXB/HappyXBModel.cs |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/System/HappyXB/HappyXBModel.cs b/System/HappyXB/HappyXBModel.cs
index 3066b1a..10e6429 100644
--- a/System/HappyXB/HappyXBModel.cs
+++ b/System/HappyXB/HappyXBModel.cs
@@ -76,6 +76,8 @@
             XBWarehouseRedPoint();
             m_storeModel.RefreshTCBPlayerDataEvent -= RefreshStoreScore;
             m_storeModel.RefreshTCBPlayerDataEvent += RefreshStoreScore;
+            playerPack.RefreshItemCountAct -= RefreshXBTool;
+            playerPack.RefreshItemCountAct += RefreshXBTool;
         }
 
         public override void UnInit()
@@ -149,10 +151,16 @@
                     funcSet.xbPrices[i] = int.Parse(jsonData[i].ToString());
                 }
                 jsonData = JsonMapper.ToObject(xbSet.Numerical3);
-                funcSet.costTools = new int[jsonData.Count];
+                funcSet.costToolIds = new int[jsonData.Count];
+                funcSet.costToolNums = new int[jsonData.Count];
                 for (int i = 0; i < jsonData.Count; i++)
                 {
-                    funcSet.costTools[i] = int.Parse(jsonData[i].ToString());
+                    if(jsonData.IsArray)
+                    {
+                        funcSet.costToolIds[i] = int.Parse(jsonData[i][0].ToString());
+                        funcSet.costToolNums[i] = int.Parse(jsonData[i][1].ToString());
+                    }
+                  
                 }
                 jsonData = JsonMapper.ToObject(xbSet.Numerical4);
                 funcSet.xbFreeCDs = new int[jsonData.Count];
@@ -546,6 +554,45 @@
             }
             return false;
         }
+        
+        public bool CheckIsXBTool(int itemId,int type)
+        {
+            XBFuncSet funcSet = GetXBFuncSet(type);
+            if (funcSet == null) return false;
+
+            if(funcSet.costToolIds.Contains(itemId))
+            {
+                return true;
+            }
+            return false;
+        }
+        public bool IsHaveOneXBTool(int type)
+        {
+            XBFuncSet funcSet = GetXBFuncSet(type);
+            if (funcSet == null) return false;
+
+            int toolCnt = playerPack.GetItemCountByID(PackType.rptItem, funcSet.costToolIds[0]);
+            if(toolCnt >= funcSet.costToolNums[0])
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        public bool IsHaveManyXBTool(int type, out int toolCnt)
+        {
+            toolCnt = 0;
+            XBFuncSet funcSet = GetXBFuncSet(type);
+            if (funcSet == null) return false;
+
+            toolCnt = playerPack.GetItemCountByID(PackType.rptItem, funcSet.costToolIds[1]);
+            if (toolCnt > 0)
+            {
+                return true;
+            }
+            return false;
+        }
 
         public void RecordFreeXBTime()
         {
@@ -666,11 +713,18 @@
             }
         }
 
+        private void RefreshXBTool(PackType type, int index, int id)
+        {
+            if (type != PackType.rptItem) return;
+            if (!CheckIsXBTool(id, 1) && !CheckIsXBTool(id, 2)) return;
+            BestAndRuneXBRedPoint();
+        }
+
         public void BestAndRuneXBRedPoint()
         {
             if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.HappyFindTreasure)) return;
 
-            if (IsHaveFreeXB(1))
+            if (IsHaveFreeXB(1) || IsHaveOneXBTool(1))
             {
                 bestXBRed.state = RedPointState.Simple;
             }
@@ -679,7 +733,7 @@
                 bestXBRed.state = RedPointState.None;
             }
 
-            if (IsHaveFreeXB(2))
+            if (IsHaveFreeXB(2) || IsHaveOneXBTool(2))
             {
                 runeXBRed.state = RedPointState.Simple;
             }
@@ -745,7 +799,8 @@
         public int xbType;// 1 鏋佸搧瀵诲疂 2 绗﹀嵃瀵诲疂 
         public int[] xbNums;
         public int[] xbPrices;
-        public int[] costTools;
+        public int[]costToolIds;
+        public int[] costToolNums;
         public int[] xbFreeCDs;
         public int[] xbScores;
     }

--
Gitblit v1.8.0