123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System.Collections.Generic;
- using System.Linq;
- 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 bool TryCompleteGuide(int guideId)
- {
- if (GameGlobal.skipGuide)
- {
- return false;
- }
- if (currentGuideId == guideId)
- {
- GuideData guideData = null;
- if (_dataDic.ContainsKey(guideId))
- {
- guideData = _dataDic[guideId];
- }
- else
- {
- guideData = new GuideData();
- guideData.guideId = guideId;
- guideData.count = 0;
- _dataDic.Add(guideId, guideData);
- }
- guideData.count++;
- currentGuideId = 0;
- GameProxy.ReqUpdateRoleGuide(guideData);
- _guideDicAtThisLogin[guideId] = true;
- return true;
- }
- return false;
- }
- public static int GetGuideCount(int guideId)
- {
- if (GuideController.useNewGuide) return 1;
- if (_dataDic.ContainsKey(guideId))
- {
- GuideData guideData = _dataDic[guideId];
- return guideData.count;
- }
- return 0;
- }
- 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 (!GuideController.useNewGuide) return 1;
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- if (_dataDic.ContainsKey(cfg.id))
- {
- GuideData guideData = _dataDic[cfg.id];
- return guideData.count;
- }
- return 0;
- }
- public static int GetGuideCountCopy(int guideId)
- {
- if (!GuideController.useNewGuide) return 1;
- if (_dataDic.ContainsKey(guideId))
- {
- GuideData guideData = _dataDic[guideId];
- return guideData.count;
- }
- return 0;
- }
- 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;
- }
- }
- }
|