GuideDataManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. LogServerHelper.SendNodeLog(GuideDataManager.currentGuideId * 100 + 2);
  48. return await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + guideId, 1);
  49. }
  50. return false;
  51. }
  52. // public static bool CheckGuideIsCompletedAtThisLogin(int guideId)
  53. // {
  54. // if (_guideDicAtThisLogin.ContainsKey(guideId))
  55. // {
  56. // return _guideDicAtThisLogin[guideId];
  57. // }
  58. // return false;
  59. // }
  60. public static int _currentGuideIdIndex;
  61. public static int currentGuideIdIndex
  62. {
  63. get
  64. {
  65. return _currentGuideIdIndex;
  66. }
  67. set
  68. {
  69. _currentGuideIdIndex = value;
  70. }
  71. }
  72. public static void SetGuideIndex(int guideId, int index)
  73. {
  74. if (!_guideDicIndex.ContainsKey(guideId))
  75. {
  76. _guideDicIndex.Add(guideId, new Dictionary<int, int>());
  77. }
  78. if (_guideDicIndex[guideId].ContainsKey(index)) return;
  79. _guideDicIndex[guideId][index] = 0;
  80. }
  81. public static int IsGuideFinish(string guideKey)
  82. {
  83. if (GameGlobal.skipGuide) return 1;
  84. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  85. return StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.id);
  86. }
  87. public static bool TryCompleteGuideIndex(int guideId, int index, bool checkInde = true)
  88. {
  89. if (GameGlobal.skipGuide)
  90. {
  91. return false;
  92. }
  93. if (!checkInde && guideId == currentGuideId || checkInde && guideId == currentGuideId && index == currentGuideIdIndex && !IsGuideIndexFinish(guideId, index))
  94. {
  95. _guideDicIndex[guideId][index] = 1;
  96. return true;
  97. }
  98. return false;
  99. }
  100. public static void SetGuideIndexState(int guideId, int index, int state)
  101. {
  102. if (guideId == currentGuideId && index == currentGuideIdIndex && _guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index))
  103. {
  104. _guideDicIndex[guideId][index] = state;
  105. }
  106. }
  107. public static bool CheckAllIndexFinish(int guideId, int count)
  108. {
  109. for (int i = 1; i <= count; i++)
  110. {
  111. if (!IsGuideIndexFinish(guideId, i)) return false;
  112. }
  113. return true;
  114. }
  115. public static bool IsGuideIndexFinish(int guideId, int index)
  116. {
  117. if (index == 0) return true;
  118. if (_guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index) && _guideDicIndex[guideId][index] == 1)
  119. {
  120. return true;
  121. }
  122. return false;
  123. }
  124. }
  125. }