GuideDataManager.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. if (_currentGuideId == value) return;
  23. _currentGuideId = value;
  24. }
  25. }
  26. // public static void InitServerData(List<GuideData> list)
  27. // {
  28. // currentGuideId = 0;
  29. // _dataDic.Clear();
  30. // _guideDicAtThisLogin.Clear();
  31. // if (list != null)
  32. // {
  33. // foreach (GuideData data in list)
  34. // {
  35. // _dataDic.Add(data.guideId, data);
  36. // }
  37. // }
  38. // }
  39. public static async ETTask<bool> TryCompleteGuide(int guideId)
  40. {
  41. if (GameGlobal.skipGuide)
  42. {
  43. return false;
  44. }
  45. if (currentGuideId == guideId)
  46. {
  47. return await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + guideId, 1);
  48. }
  49. return false;
  50. }
  51. // public static bool CheckGuideIsCompletedAtThisLogin(int guideId)
  52. // {
  53. // if (_guideDicAtThisLogin.ContainsKey(guideId))
  54. // {
  55. // return _guideDicAtThisLogin[guideId];
  56. // }
  57. // return false;
  58. // }
  59. public static int _currentGuideIdIndex;
  60. public static int currentGuideIdIndex
  61. {
  62. get
  63. {
  64. return _currentGuideIdIndex;
  65. }
  66. set
  67. {
  68. _currentGuideIdIndex = value;
  69. }
  70. }
  71. public static void SetGuideIndex(int guideId, int index)
  72. {
  73. if (!_guideDicIndex.ContainsKey(guideId))
  74. {
  75. _guideDicIndex.Add(guideId, new Dictionary<int, int>());
  76. }
  77. if (_guideDicIndex[guideId].ContainsKey(index)) return;
  78. _guideDicIndex[guideId][index] = 0;
  79. }
  80. public static int IsGuideFinish(string guideKey)
  81. {
  82. if (GameGlobal.skipGuide) return 1;
  83. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  84. return StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.id);
  85. }
  86. public static bool TryCompleteGuideIndex(int guideId, int index, bool checkInde = true)
  87. {
  88. if (GameGlobal.skipGuide)
  89. {
  90. return false;
  91. }
  92. if (!checkInde && guideId == currentGuideId || checkInde && guideId == currentGuideId && index == currentGuideIdIndex && !IsGuideIndexFinish(guideId, index))
  93. {
  94. _guideDicIndex[guideId][index] = 1;
  95. return true;
  96. }
  97. return false;
  98. }
  99. public static void SetGuideIndexState(int guideId, int index, int state)
  100. {
  101. if (guideId == currentGuideId && index == currentGuideIdIndex && _guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index))
  102. {
  103. _guideDicIndex[guideId][index] = state;
  104. }
  105. }
  106. public static bool CheckAllIndexFinish(int guideId, int count)
  107. {
  108. for (int i = 1; i <= count; i++)
  109. {
  110. if (!IsGuideIndexFinish(guideId, i)) return false;
  111. }
  112. return true;
  113. }
  114. public static bool IsGuideIndexFinish(int guideId, int index)
  115. {
  116. if (index == 0) return true;
  117. if (_guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index) && _guideDicIndex[guideId][index] == 1)
  118. {
  119. return true;
  120. }
  121. return false;
  122. }
  123. }
  124. }