GuideDataManager.cs 3.5 KB

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