GuideDataManager.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using cfg.GfgCfg;
  4. using ET;
  5. using FairyGUI;
  6. namespace GFGGame
  7. {
  8. public class GuideDataManager
  9. {
  10. private static Dictionary<int, Dictionary<int, int>> _guideDicIndex = new Dictionary<int, Dictionary<int, int>>();
  11. public static int _currentGuideId;
  12. public static void Clear()
  13. {
  14. _guideDicIndex.Clear();
  15. }
  16. public static int currentGuideId
  17. {
  18. get
  19. {
  20. return _currentGuideId;
  21. }
  22. set
  23. {
  24. if (_currentGuideId == value) return;
  25. _currentGuideId = value;
  26. }
  27. }
  28. public static async ETTask<bool> TryCompleteGuide(int guideId)
  29. {
  30. if (GameGlobal.skipGuide)
  31. {
  32. return false;
  33. }
  34. if (currentGuideId == guideId)
  35. {
  36. bool result = await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + guideId, 1);
  37. return result;
  38. }
  39. return false;
  40. }
  41. public static int _currentGuideIdIndex;
  42. public static int currentGuideIdIndex
  43. {
  44. get
  45. {
  46. return _currentGuideIdIndex;
  47. }
  48. set
  49. {
  50. _currentGuideIdIndex = value;
  51. }
  52. }
  53. public static void SetGuideIndex(int guideId, int index)
  54. {
  55. if (!_guideDicIndex.ContainsKey(guideId))
  56. {
  57. _guideDicIndex.Add(guideId, new Dictionary<int, int>());
  58. }
  59. if (_guideDicIndex[guideId].ContainsKey(index)) return;
  60. _guideDicIndex[guideId][index] = 0;
  61. }
  62. public static int IsGuideFinish(string guideKey)
  63. {
  64. GuideCfg cfg = CommonDataManager.Tables.TblGuideCfg.GetOrDefault(guideKey);
  65. if (GameGlobal.skipGuide || cfg == null) return 1;
  66. return StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.Id);
  67. }
  68. public static bool TryCompleteGuideIndex(int guideId, int index, bool checkInde = true)
  69. {
  70. if (GameGlobal.skipGuide)
  71. {
  72. return false;
  73. }
  74. if (!checkInde && guideId == currentGuideId || checkInde && guideId == currentGuideId && index == currentGuideIdIndex && !IsGuideIndexFinish(guideId, index))
  75. {
  76. _guideDicIndex[guideId][index] = 1;
  77. return true;
  78. }
  79. return false;
  80. }
  81. public static void SetGuideIndexState(int guideId, int index, int state)
  82. {
  83. if (guideId == currentGuideId && index == currentGuideIdIndex && _guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index))
  84. {
  85. _guideDicIndex[guideId][index] = state;
  86. }
  87. }
  88. public static bool CheckAllIndexFinish(int guideId, int count)
  89. {
  90. for (int i = 1; i <= count; i++)
  91. {
  92. if (!IsGuideIndexFinish(guideId, i)) return false;
  93. }
  94. return true;
  95. }
  96. public static bool IsGuideIndexFinish(int guideId, int index)
  97. {
  98. if (index == 0) return true;
  99. if (_guideDicIndex.ContainsKey(guideId) && _guideDicIndex[guideId].ContainsKey(index) && _guideDicIndex[guideId][index] == 1)
  100. {
  101. return true;
  102. }
  103. return false;
  104. }
  105. }
  106. }