From 1a13e98582ce38176d33c64e1437bd6b658195fb Mon Sep 17 00:00:00 2001
From: client_Zxw <826696702@qq.com>
Date: 星期五, 17 八月 2018 10:09:39 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

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

diff --git a/System/HappyXB/HappyXBModel.cs b/System/HappyXB/HappyXBModel.cs
index 3066b1a..fe373e3 100644
--- a/System/HappyXB/HappyXBModel.cs
+++ b/System/HappyXB/HappyXBModel.cs
@@ -26,6 +26,7 @@
 
         public static string HAPPYXBITEMKEY;
         public List<ArrayList> XBNotifyParms = new List<ArrayList>();
+        public bool isXBCoolTime { get; set; }
 
         public override void Init()
         {
@@ -63,6 +64,7 @@
 
         public void OnBeforePlayerDataInitialize()
         {
+            isXBCoolTime = false;
             XBNotifyParms.Clear();
             xbTypeInfoDict.Clear();
         }
@@ -76,6 +78,8 @@
             XBWarehouseRedPoint();
             m_storeModel.RefreshTCBPlayerDataEvent -= RefreshStoreScore;
             m_storeModel.RefreshTCBPlayerDataEvent += RefreshStoreScore;
+            playerPack.RefreshItemCountAct -= RefreshXBTool;
+            playerPack.RefreshItemCountAct += RefreshXBTool;
         }
 
         public override void UnInit()
@@ -149,10 +153,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];
@@ -318,6 +328,7 @@
                 }
             }
             SetXBResultRecord();
+            isXBCoolTime = false;
             if (RefreshXBResultAct != null)
             {
                 RefreshXBResultAct();
@@ -468,6 +479,7 @@
         /// <param name="index"></param>
         public void SendXBQuest(int type,int index,int costType)
         {
+            isXBCoolTime = true;
             CA568_tagCMRequestTreasure treasure = new CA568_tagCMRequestTreasure();
             treasure.TreasureType = (byte)type;
             treasure.TreasureIndex = (byte)index;
@@ -543,6 +555,45 @@
                 {
                     return true;
                 }
+            }
+            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;
         }
@@ -666,11 +717,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 +737,7 @@
                 bestXBRed.state = RedPointState.None;
             }
 
-            if (IsHaveFreeXB(2))
+            if (IsHaveFreeXB(2) || IsHaveOneXBTool(2))
             {
                 runeXBRed.state = RedPointState.Simple;
             }
@@ -745,7 +803,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