GuideDataManager.cs 3.5 KB

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