GuideDataManager.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. LogServerHelper.SendNodeLog(GuideDataManager.currentGuideId * 100 + 2);
  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. if (GameGlobal.skipGuide) return 1;
  65. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  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. }