| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using System; | 
| using LitJson; | 
|   | 
|   | 
| public class DungeonManager : GameSystemManager<DungeonManager> | 
| { | 
|     private Dictionary<int, FBInfo> fbInfoDict = new Dictionary<int, FBInfo>(); | 
|     public event Action<int> UpdateFBInfoListEvent;//int mapID | 
|     public event Action<int, bool, bool, bool> UpdateFBInfoChangeEvent; | 
|     public event Action<int> UpdateFBInfoListEventByADAddCnt;//int mapID  广告增加次数有更新 | 
|     public event Action<int> UpdateFBInfoListEventNotByADAddCnt;//int mapID  不是广告增加次数导致的更新 | 
|     Dictionary<int, DungeonRecord> dungeonRecords = new Dictionary<int, DungeonRecord>(); | 
|     public event Action updateDungeonBuyCnt; | 
|   | 
|     public override void Init() | 
|     { | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent; | 
|     } | 
|   | 
|     public override void Release() | 
|     { | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent; | 
|     } | 
|   | 
|     public void OnBeforePlayerDataInitializeEvent() | 
|     { | 
|         fbInfoDict.Clear(); | 
|     } | 
|   | 
|     public bool TryGetFBInfoByMapID(int mapID, out FBInfo info) | 
|     { | 
|         return fbInfoDict.TryGetValue(mapID, out info); | 
|     } | 
|   | 
|     public void UpdateFBInfoList(HA320_tagSCFBInfoList vNetData) | 
|     { | 
|         if (vNetData == null || vNetData.FBDataList.IsNullOrEmpty()) | 
|             return; | 
|         bool isADAddCntChange = false; | 
|         bool isBuyAddCntChange = false; | 
|         bool isItemAddCntChange = false; | 
|   | 
|         foreach (var item in vNetData.FBDataList) | 
|         { | 
|             if (!fbInfoDict.ContainsKey((int)item.MapID)) | 
|                 fbInfoDict[(int)item.MapID] = new FBInfo(); | 
|             int mapID = (int)item.MapID; | 
|             fbInfoDict[mapID].MapID = item.MapID; | 
|             fbInfoDict[mapID].EnterCnt = item.EnterCnt; | 
|   | 
|             isADAddCntChange = fbInfoDict[mapID].ADAddCnt != item.ADAddCnt; | 
|             fbInfoDict[mapID].ADAddCnt = item.ADAddCnt; | 
|   | 
|             isBuyAddCntChange = fbInfoDict[mapID].BuyAddCnt != item.BuyAddCnt; | 
|             fbInfoDict[mapID].BuyAddCnt = item.BuyAddCnt; | 
|   | 
|             isItemAddCntChange = fbInfoDict[mapID].ItemAddCnt != item.ItemAddCnt; | 
|             fbInfoDict[mapID].ItemAddCnt = item.ItemAddCnt; | 
|   | 
|             fbInfoDict[mapID].PassLineID = item.PassLineID; | 
|             fbInfoDict[mapID].PassGradeCnt = item.PassGradeCnt; | 
|             fbInfoDict[mapID].PassGrade = item.PassGrade; | 
|   | 
|             UpdateFBInfoListEvent?.Invoke(mapID); | 
|             UpdateFBInfoChangeEvent?.Invoke(mapID, isADAddCntChange, isBuyAddCntChange, isItemAddCntChange); | 
|         } | 
|     } | 
|   | 
|     public void UpdateRecords(HA3BD_tagMCBuyEnterInfo.tagMCBuyInfo[] vNetDatas) | 
|     { | 
|         for (int i = 0; i < vNetDatas.Length; i++) | 
|         { | 
|             var info = vNetDatas[i]; | 
|             var dungeonId = (int)info.FBID; | 
|             if (dungeonRecords.ContainsKey(dungeonId)) | 
|             { | 
|                 dungeonRecords[dungeonId].UpdateRecord(info); | 
|             } | 
|             else | 
|             { | 
|                 dungeonRecords[dungeonId] = new DungeonRecord(info); | 
|             } | 
|         } | 
|         if (updateDungeonBuyCnt != null) | 
|         { | 
|             updateDungeonBuyCnt(); | 
|         } | 
|     } | 
|   | 
|   | 
|   | 
| } | 
|   | 
| public class FBInfo | 
| { | 
|     public uint MapID; | 
|     public ushort EnterCnt;        //今日累计进入次数 | 
|     public byte ADAddCnt;        //广告增加次数 | 
|     public byte BuyAddCnt;        //购买增加次数 | 
|     public ushort ItemAddCnt;        //物品增加次数 | 
|     public uint PassLineID;        //已过关到的lineID | 
|     public byte PassGradeCnt;        //星级值对应个数, 每个key存9个lineID | 
|     public uint[] PassGrade;        //副本线路对应星级值列表 | 
| } |