123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System.Collections.Generic;
- using System.Linq;
- using ET;
- namespace GFGGame
- {
- public class GuideDataManager
- {
- // //public static int currentGuideId;
- // private static Dictionary<int, GuideData> _dataDic = new Dictionary<int, GuideData>();
- // //本次登录引导的id缓存
- // private static Dictionary<int, bool> _guideDicAtThisLogin = new Dictionary<int, bool>();
- private static Dictionary<int, Dictionary<int, int>> _guideDicIndex = new Dictionary<int, Dictionary<int, int>>();
- public static int _currentGuideId;
- public static int currentGuideId
- {
- get
- {
- return _currentGuideId;
- }
- set
- {
- _currentGuideId = value;
- }
- }
- // public static void InitServerData(List<GuideData> list)
- // {
- // currentGuideId = 0;
- // _dataDic.Clear();
- // _guideDicAtThisLogin.Clear();
- // if (list != null)
- // {
- // foreach (GuideData data in list)
- // {
- // _dataDic.Add(data.guideId, data);
- // }
- // }
- // }
- public static async ETTask<bool> TryCompleteGuide(int guideId)
- {
- if (GameGlobal.skipGuide)
- {
- return false;
- }
- if (currentGuideId == guideId)
- {
- return await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + guideId, 1);
- }
- return false;
- }
- // public static bool CheckGuideIsCompletedAtThisLogin(int guideId)
- // {
- // if (_guideDicAtThisLogin.ContainsKey(guideId))
- // {
- // return _guideDicAtThisLogin[guideId];
- // }
- // return false;
- // }
- public static int _currentGuideIdIndex;
- public static int currentGuideIdIndex
- {
- get
- {
- return _currentGuideIdIndex;
- }
- set
- {
- _currentGuideIdIndex = value;
- }
- }
- public static void SetGuideIndex(int guideId, int index)
- {
- if (!_guideDicIndex.ContainsKey(guideId))
- {
- _guideDicIndex.Add(guideId, new Dictionary<int, int>());
- }
- if (_guideDicIndex[guideId].ContainsKey(index)) return;
- _guideDicIndex[guideId][index] = 0;
- }
- public static int GetGuideCountCopy(string guideKey)
- {
- if (GameGlobal.skipGuide) return 1;
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- return StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.id);
- }
- public static bool TryCompleteGuideIndex(int guideId, int index, bool checkInde = true)
- {
- if (GameGlobal.skipGuide)
- {
- return false;
- }
- if (!checkInde && guideId == currentGuideId || checkInde && guideId == currentGuideId && index == currentGuideIdIndex && !IsGuideIndexFinish(guideId, index))
- {
- _guideDicIndex[guideId][index] = 1;
- return true;
- }
- return false;
- }
- public static void SetGuideIndexState(int guideId, int index, int state)
- {
- if (guideId == currentGuideId && index == currentGuideIdIndex && _guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index))
- {
- _guideDicIndex[guideId][index] = state;
- }
- }
- public static bool CheckAllIndexFinish(int guideId, int count)
- {
- for (int i = 1; i <= count; i++)
- {
- if (!IsGuideIndexFinish(guideId, i)) return false;
- }
- return true;
- }
- public static bool IsGuideIndexFinish(int guideId, int index)
- {
- if (index == 0) return true;
- if (_guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index) && _guideDicIndex[guideId][index] == 1)
- {
- return true;
- }
- return false;
- }
- }
- }
|