GuideDataManager.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using ET;
  4. namespace GFGGame
  5. {
  6. public class GuideDataManager
  7. {
  8. // //public static int currentGuideId;
  9. // private static Dictionary<int, GuideData> _dataDic = new Dictionary<int, GuideData>();
  10. // //本次登录引导的id缓存
  11. // private static Dictionary<int, bool> _guideDicAtThisLogin = new Dictionary<int, bool>();
  12. private static Dictionary<int, Dictionary<int, int>> _guideDicIndex = new Dictionary<int, Dictionary<int, int>>();
  13. public static int _currentGuideId;
  14. public static int currentGuideId
  15. {
  16. get
  17. {
  18. return _currentGuideId;
  19. }
  20. set
  21. {
  22. _currentGuideId = value;
  23. }
  24. }
  25. // public static void InitServerData(List<GuideData> list)
  26. // {
  27. // currentGuideId = 0;
  28. // _dataDic.Clear();
  29. // _guideDicAtThisLogin.Clear();
  30. // if (list != null)
  31. // {
  32. // foreach (GuideData data in list)
  33. // {
  34. // _dataDic.Add(data.guideId, data);
  35. // }
  36. // }
  37. // }
  38. public static async ETTask<bool> TryCompleteGuide(int guideId)
  39. {
  40. if (GameGlobal.skipGuide)
  41. {
  42. return false;
  43. }
  44. if (currentGuideId == guideId)
  45. {
  46. return await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + guideId, 1);
  47. }
  48. return false;
  49. }
  50. // public static bool CheckGuideIsCompletedAtThisLogin(int guideId)
  51. // {
  52. // if (_guideDicAtThisLogin.ContainsKey(guideId))
  53. // {
  54. // return _guideDicAtThisLogin[guideId];
  55. // }
  56. // return false;
  57. // }
  58. public static int _currentGuideIdIndex;
  59. public static int currentGuideIdIndex
  60. {
  61. get
  62. {
  63. return _currentGuideIdIndex;
  64. }
  65. set
  66. {
  67. _currentGuideIdIndex = value;
  68. }
  69. }
  70. public static void SetGuideIndex(int guideId, int index)
  71. {
  72. if (!_guideDicIndex.ContainsKey(guideId))
  73. {
  74. _guideDicIndex.Add(guideId, new Dictionary<int, int>());
  75. }
  76. if (_guideDicIndex[guideId].ContainsKey(index)) return;
  77. _guideDicIndex[guideId][index] = 0;
  78. }
  79. public static int GetGuideCountCopy(string guideKey)
  80. {
  81. if (GameGlobal.skipGuide) return 1;
  82. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  83. return StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.id);
  84. }
  85. public static bool TryCompleteGuideIndex(int guideId, int index, bool checkInde = true)
  86. {
  87. if (GameGlobal.skipGuide)
  88. {
  89. return false;
  90. }
  91. if (!checkInde && guideId == currentGuideId || checkInde && guideId == currentGuideId && index == currentGuideIdIndex && !IsGuideIndexFinish(guideId, index))
  92. {
  93. _guideDicIndex[guideId][index] = 1;
  94. return true;
  95. }
  96. return false;
  97. }
  98. public static void SetGuideIndexState(int guideId, int index, int state)
  99. {
  100. if (guideId == currentGuideId && index == currentGuideIdIndex && _guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index))
  101. {
  102. _guideDicIndex[guideId][index] = state;
  103. }
  104. }
  105. public static bool CheckAllIndexFinish(int guideId, int count)
  106. {
  107. for (int i = 1; i <= count; i++)
  108. {
  109. if (!IsGuideIndexFinish(guideId, i)) return false;
  110. }
  111. return true;
  112. }
  113. public static bool IsGuideIndexFinish(int guideId, int index)
  114. {
  115. if (index == 0) return true;
  116. if (_guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index) && _guideDicIndex[guideId][index] == 1)
  117. {
  118. return true;
  119. }
  120. return false;
  121. }
  122. }
  123. }