using FairyGUI; using UI.DressUp; using UI.Main; using System.Collections.Generic; using UnityEngine; using UI.ClothingSynthetic; namespace GFGGame { public class GuideController { public static bool IsGuide() { bool isAllGuideFinish = false; for (int i = 0; i < GuideCfgArray.Instance.dataArray.Length; i++) { if (GuideDataManager.GetGuideCountCopy(GuideCfgArray.Instance.dataArray[i].key) <= 0) { isAllGuideFinish = false; break; } isAllGuideFinish = true; } bool isGuide = GameGlobal.skipGuide == false && !isAllGuideFinish; return isGuide; } public static bool useNewGuide = true; 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) { if (!useNewGuide) return false; GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey); if ((GuideDataManager.GetGuideCountCopy(guideKey) <= 0 && (cfg.priorId <= 0 || cfg.priorId > 0 && (GuideDataManager.GetGuideCountCopy(cfg.priorId) > 0)) && (!checkIndex || checkIndex && GuideDataManager.IsGuideIndexFinish(cfg.id, index - 1) == true && GuideDataManager.IsGuideIndexFinish(cfg.id, index) == false) && (GuideDataManager.currentGuideId == 0 || GuideDataManager.currentGuideId == cfg.id && GuideDataManager.currentGuideIdIndex != index) && (StoryDataManager.CurrentChapterOrder == 0 || StoryDataManager.CheckCurrentLevelPass() == false) && StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level - 1) && !StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level)) || (cfg.chapterId == 0 && GuideDataManager.GetGuideCountCopy(guideKey) <= 0 )) { GuideDataManager.currentGuideId = cfg.id; GuideDataManager.currentGuideIdIndex = index; GuideDataManager.SetGuideIndex(cfg.id, index); if (isList) { if (target.asList.numItems > 0) { GObject item = (target.asList).GetChildAt(listIndex); if (item != null) { target = item; // target.asList.ScrollToView(listIndex); } } else { return false; } } ShowGuideByIndex(target, needUpdate, guideStr, yTxt, cfg.optionalGuide == 1, devWidth, devHeight, GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex); if (!checkIndex) { for (int i = 1; i < index; i++) { GuideDataManager.TryCompleteGuideIndex(cfg.id, i, false); } } return true; } return false; } 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) { HideGuideIndex(); if (GameGlobal.skipGuide) { return; } ViewManager.Show(ViewName.GUIDE_VIEW, new List { target, needUpdate, guideStr, yTxt, isOptionalGuide, devWidth, devHeight, guideId, index }); } public static bool TryCompleteGuideIndex(int guideId, int index) { if (!useNewGuide) return false; HideGuideIndex(); // bool result = GuideDataManager.TryCompleteGuideIndex(guideId, index); if (GuideDataManager.TryCompleteGuideIndex(guideId, index)) { return true; } return false; } public static bool TryCompleteGuide(string guideKey, int count) { if (!useNewGuide) return false; GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey); if (!GuideDataManager.CheckAllIndexFinish(cfg.id, count)) return false; bool result = GuideDataManager.TryCompleteGuide(cfg.id); if (result) { GuideDataManager.currentGuideId = 0; HideGuideIndex(); } return result; } public static void HideGuideIndex() { if (!useNewGuide) return; ViewManager.Hide(ViewName.GUIDE_VIEW); } } }