123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using FairyGUI;
- using UI.DressUp;
- using UI.Main;
- using System.Collections.Generic;
- using UnityEngine;
- using UI.ClothingSynthetic;
- using ET;
- namespace GFGGame
- {
- public class GuideController
- {
- public static bool IsGuide()
- {
- if (!GameGlobal.isEnterGame) return false;//未进入游戏
- bool isAllGuideFinish = false;
- for (int i = 0; i < GuideCfgArray.Instance.dataArray.Length; i++)
- {
- if (GuideDataManager.IsGuideFinish(GuideCfgArray.Instance.dataArray[i].key) <= 0)
- {
- isAllGuideFinish = false;
- break;
- }
- isAllGuideFinish = true;
- }
- bool isGuide = GameGlobal.skipGuide == false && !isAllGuideFinish;
- return isGuide;
- }
- public static bool TryGuide(GObject target, string guideKey, int index, string guideStr = null, int listIndex = -1, bool checkPriorIndex = true, int yTxt = 0, float devWidth = 0, float devHeight = 0, bool showAni = true)
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- bool isStoryLevelGuide = cfg.storyLevelId > 0;
- bool isFinishCurId = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.id) > 0;//当前引导未完成
- bool isFinishPriorId = cfg.priorId <= 0 || StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + cfg.priorId) > 0;//前置引导已完成
- bool isFinishCurIndex = GuideDataManager.IsGuideIndexFinish(cfg.id, index) == true;//当前index未完成
- bool isFinishPriorIndex = !checkPriorIndex || checkPriorIndex && GuideDataManager.IsGuideIndexFinish(cfg.id, index - 1) == true;//前置index已完成
- bool isCfgChapterOpen = MainStoryDataManager.CheckLevelUnlock(cfg.storyLevelId);//引导配置关卡已开启
- bool isCfgChapter = MainStoryDataManager.currentLevelCfgId == 0 || MainStoryDataManager.currentLevelCfgId == cfg.storyLevelId;//无选择(进入游戏时无选择)或当前所选择为配置关卡
- if (isStoryLevelGuide && !isFinishCurId && isFinishPriorId && !isFinishCurIndex && isFinishPriorIndex && isCfgChapterOpen && isCfgChapter || !isStoryLevelGuide && !isFinishCurId)
- {
- GuideDataManager.currentGuideId = cfg.id;
- GuideDataManager.currentGuideIdIndex = index;
- GuideDataManager.SetGuideIndex(cfg.id, index);
- if (listIndex >= 0)
- {
- 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, guideStr, yTxt, cfg.optionalGuide == 1, devWidth, devHeight, GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex, showAni);
- if (!checkPriorIndex)
- {
- for (int i = 1; i < index; i++)
- {
- GuideDataManager.TryCompleteGuideIndex(cfg.id, i, false);
- }
- }
- return true;
- }
- return false;
- }
- private static void ShowGuideByIndex(GObject target, string guideStr = null, int yTxt = 0, bool isOptionalGuide = false, float devWidth = 0, float devHeight = 0, int guideId = 0, int index = 0, bool showAni = true)
- {
- HideGuide();
- if (GameGlobal.skipGuide)
- {
- return;
- }
- ViewManager.Show(ViewName.GUIDE_VIEW, new List<object> { target, guideStr, yTxt, isOptionalGuide, devWidth, devHeight, guideId, index, showAni });
- }
- public static bool TryCompleteGuideIndex(int guideId, int index)
- {
- HideGuide();
- if (GuideDataManager.TryCompleteGuideIndex(guideId, index))
- {
- return true;
- }
- return false;
- }
- public static async void TryCompleteGuide(string guideKey, int count)
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- bool result = false;
- if (!GuideDataManager.CheckAllIndexFinish(cfg.id, count)) return;
- result = await GuideDataManager.TryCompleteGuide(cfg.id);
- if (result)
- {
- GuideDataManager.currentGuideId = 0;
- HideGuide();
- }
- }
- public static void HideGuide()
- {
- ViewManager.Hide(ViewName.GUIDE_VIEW);
- }
- }
- }
|