GuideController.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using FairyGUI;
  2. using UI.DressUp;
  3. using UI.Main;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UI.ClothingSynthetic;
  7. namespace GFGGame
  8. {
  9. public class GuideController
  10. {
  11. public static bool IsGuide()
  12. {
  13. bool isAllGuideFinish = false;
  14. for (int i = 0; i < GuideCfgArray.Instance.dataArray.Length; i++)
  15. {
  16. if (GuideDataManager.GetGuideCountCopy(GuideCfgArray.Instance.dataArray[i].key) <= 0)
  17. {
  18. isAllGuideFinish = false;
  19. break;
  20. }
  21. isAllGuideFinish = true;
  22. }
  23. bool isGuide = GameGlobal.skipGuide == false && !isAllGuideFinish;
  24. return isGuide;
  25. }
  26. public static bool useNewGuide = true;
  27. public static bool TryGuide(GObject target, string guideKey, int index, string guideStr = null, bool isList = false, int listIndex = 0, bool checkIndex = true, bool needUpdate = false, int yTxt = 0, float devWidth = 0, float devHeight = 0)
  28. {
  29. if (!useNewGuide) return false;
  30. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  31. if ((GuideDataManager.GetGuideCountCopy(guideKey) <= 0
  32. && (cfg.priorId <= 0 || cfg.priorId > 0 && (GuideDataManager.GetGuideCountCopy(cfg.priorId) > 0))
  33. && (!checkIndex || checkIndex && GuideDataManager.IsGuideIndexFinish(cfg.id, index - 1) == true && GuideDataManager.IsGuideIndexFinish(cfg.id, index) == false)
  34. && (GuideDataManager.currentGuideId == 0 || GuideDataManager.currentGuideId == cfg.id && GuideDataManager.currentGuideIdIndex != index)
  35. && (StoryDataManager.currentChapter == 0 || StoryDataManager.CheckCurrentLevelPass() == false)
  36. && StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level - 1)
  37. && !StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level))
  38. ||
  39. (cfg.chapterId == 0
  40. && GuideDataManager.GetGuideCountCopy(guideKey) <= 0
  41. ))
  42. {
  43. GuideDataManager.currentGuideId = cfg.id;
  44. GuideDataManager.currentGuideIdIndex = index;
  45. GuideDataManager.SetGuideIndex(cfg.id, index);
  46. if (isList)
  47. {
  48. if (target.asList.numItems > 0)
  49. {
  50. GObject item = (target.asList).GetChildAt(listIndex);
  51. if (item != null)
  52. {
  53. target = item;
  54. // target.asList.ScrollToView(listIndex);
  55. }
  56. }
  57. else
  58. {
  59. return false;
  60. }
  61. }
  62. ShowGuideByIndex(target, needUpdate, guideStr, yTxt, cfg.optionalGuide == 1, devWidth, devHeight, GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex);
  63. if (!checkIndex)
  64. {
  65. for (int i = 1; i < index; i++)
  66. {
  67. GuideDataManager.TryCompleteGuideIndex(cfg.id, i, false);
  68. }
  69. }
  70. return true;
  71. }
  72. return false;
  73. }
  74. private static void ShowGuideByIndex(GObject target, bool needUpdate = false, string guideStr = null, int yTxt = 0, bool isOptionalGuide = false, float devWidth = 0, float devHeight = 0, int guideId = 0, int index = 0)
  75. {
  76. HideGuideIndex();
  77. if (GameGlobal.skipGuide)
  78. {
  79. return;
  80. }
  81. ViewManager.Show(ViewName.GUIDE_VIEW, new List<object> { target, needUpdate, guideStr, yTxt, isOptionalGuide, devWidth, devHeight, guideId, index });
  82. }
  83. public static bool TryCompleteGuideIndex(int guideId, int index)
  84. {
  85. if (!useNewGuide) return false;
  86. HideGuideIndex();
  87. // bool result = GuideDataManager.TryCompleteGuideIndex(guideId, index);
  88. if (GuideDataManager.TryCompleteGuideIndex(guideId, index))
  89. {
  90. return true;
  91. }
  92. return false;
  93. }
  94. public static bool TryCompleteGuide(string guideKey, int count)
  95. {
  96. if (!useNewGuide) return false;
  97. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
  98. if (!GuideDataManager.CheckAllIndexFinish(cfg.id, count)) return false;
  99. bool result = GuideDataManager.TryCompleteGuide(cfg.id);
  100. if (result)
  101. {
  102. GuideDataManager.currentGuideId = 0;
  103. HideGuideIndex();
  104. }
  105. return result;
  106. }
  107. public static void HideGuideIndex()
  108. {
  109. if (!useNewGuide) return;
  110. ViewManager.Hide(ViewName.GUIDE_VIEW);
  111. }
  112. }
  113. }