123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- 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;
- }
- /// <summary>
- /// 检测当前角色等级是否有引导开启,若有则返回引导id
- /// </summary>
- /// <returns></returns>
- public static string CheckHasRoleLvGuideOpen()
- {
- GuideCfg[] guideCfgs = GuideCfgArray.Instance.dataArray;
- for (int i = 0; i < guideCfgs.Length; i++)
- {
- if (guideCfgs[i].roleLv <= 0) continue;
- bool isFinishCurId = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_GUIDE + guideCfgs[i].id) > 0;
- if (!isFinishCurId && guideCfgs[i].roleLv <= RoleDataManager.lvl)
- {
- return guideCfgs[i].viewName;
- }
- }
- return "";
- }
- /// <summary>
- /// 是否特殊条件开启
- /// </summary>
- /// <returns></returns>
- private static bool CheckSpecialGuideOpen(GuideCfg cfg)
- {
- if (cfg.special <= 0) return false;
- if (cfg.guideKey == ConstGuideId.SUIT_LIST_VIEW)
- {
- return FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ClothingListView).Name, false);
- }
- return false;
- }
- private static GList targetList = null;
- public static bool TryGuide(GComponent target, string guideKey, int index, string guideStr = null, int listIndex = -1, bool checkPriorIndex = true, float yTxt = 0, bool justHint = false, bool noTips = false)
- {
- if (!GameGlobal.PreDataInited)
- {
- return false;
- }
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- if (cfg == null || GuideDataManager.currentGuideId != 0 && GuideDataManager.currentGuideId != cfg.id) return false;
- bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
- // if (guideKey == ConstGuideId.ARENA_OPEN)
- // {
- // return false;//临时屏蔽
- // }
- if (guideKey == ConstGuideId.ARENA_OPEN && (isPass || ArenaDataManager.Instance.IsArenaClearing))
- {
- return false;//竞技场结算中或已通关指定开启关卡,不引导
- }
- GRoot.inst.touchable = false;
- 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已完成
- // ET.Log.Debug("storyLevelId:" + cfg.storyLevelId + " time:" + TimeHelper.ClientNowSeconds());
- bool isCfgChapterOpen = MainStoryDataManager.CheckLevelUnlock(cfg.storyLevelId, false);//引导配置关卡已开启
- bool isCfgChapter = MainStoryDataManager.currentLevelCfgId == 0 || MainStoryDataManager.currentLevelCfgId == cfg.storyLevelId;//无选择(进入游戏时无选择)或当前所选择为配置关卡
- if (isStoryLevelGuide && isPass && !isFinishCurId)
- {
- GuideDataManager.currentGuideId = cfg.id;
- TryCompleteGuide(guideKey);
- return false;
- }
- bool isRoleLvGuide = cfg.roleLv > 0;
- bool iscurRoleLv = RoleDataManager.lvl >= cfg.roleLv;
- bool isSpecial = cfg.special > 0; //特殊条件开启的引导
- bool specialOpen = CheckSpecialGuideOpen(cfg);
- bool noneType = !isStoryLevelGuide && !isFinishCurId && isFinishPriorId && !isFinishCurIndex && isFinishPriorIndex && !isRoleLvGuide && !isSpecial;
- bool storyType = isStoryLevelGuide && !isFinishCurId && isFinishPriorId && !isFinishCurIndex && isFinishPriorIndex && isCfgChapterOpen && isCfgChapter;
- bool roleLvType = isRoleLvGuide && !isFinishCurId && isFinishPriorId && !isFinishCurIndex && isFinishPriorIndex && iscurRoleLv;
- bool specialType = isSpecial && !isFinishCurId && isFinishPriorId && !isFinishCurIndex && isFinishPriorIndex && specialOpen;
- if (storyType || roleLvType || specialType || noneType)
- {
- GuideDataManager.currentGuideId = cfg.id;
- GuideDataManager.currentGuideIdIndex = index;
- GuideDataManager.SetGuideIndex(cfg.id, index);
- if (listIndex >= 0)
- {
- if (target.asList.numItems > 0)
- {
- GComponent item = (target.asList).GetChildAt(listIndex).asCom;
- if (item != null)
- {
- targetList = target as GList;
- targetList.ScrollToView(listIndex);
- if (targetList.scrollPane != null)
- {
- targetList.scrollPane.touchEffect = false;//引导中禁止拖动
- }
- target = item;
- // target.asList.ScrollToView(listIndex);
- }
- }
- else
- {
- GRoot.inst.touchable = true;
- return false;
- }
- }
- ShowGuideByIndex(target, guideKey, guideStr, GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex, yTxt, justHint, noTips);
- if (!checkPriorIndex)
- {
- for (int i = 1; i < index; i++)
- {
- GuideDataManager.TryCompleteGuideIndex(cfg.id, i, false);
- }
- }
- return true;
- }
- GRoot.inst.touchable = true;
- MainDataManager.Instance.CanSwipe = true;
- return false;
- }
- private static void ShowGuideByIndex(GObject target, string guideKey, string guideStr = null, int guideId = 0, int index = 0, float yTxt = 0, bool justHint = false, bool noTips = false)
- {
- HideGuide();
- if (GameGlobal.skipGuide)
- {
- return;
- }
- LogServerHelper.SendNodeLog(GuideDataManager.currentGuideId * 100 + 1);
- ViewManager.Show<GuideView>(new List<object> { target, guideKey, guideStr, guideId, index, yTxt, justHint, noTips });
- }
- public static bool TryCompleteGuideIndex(string guideKey, int index)
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- if (cfg == null) return false;
- HideGuide();
- if (GuideDataManager.TryCompleteGuideIndex(cfg.id, index))
- {
- if (targetList != null && targetList.scrollPane != null)
- {
- targetList.scrollPane.touchEffect = true;
- targetList = null;
- }
- MainDataManager.Instance.CanSwipe = true;
- EventAgent.DispatchEvent(ConstMessage.FINSH_GUIDE_INDEX);
- return true;
- }
- return false;
- }
- public static async void TryCompleteGuide(string guideKey, int count)
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- if (cfg == null) return;
- if (!GuideDataManager.CheckAllIndexFinish(cfg.id, count)) return;
- TryCompleteGuide(guideKey);
- }
- private static async void TryCompleteGuide(string guideKey)
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(guideKey);
- bool result = await GuideDataManager.TryCompleteGuide(cfg.id);
- if (result)
- {
- if (targetList != null && targetList.scrollPane != null)
- {
- targetList.scrollPane.touchEffect = true;
- targetList = null;
- }
- MainDataManager.Instance.CanSwipe = true;
-
- LogServerHelper.SendNodeLog(GuideDataManager.currentGuideId * 100 + 2);
- GuideDataManager.currentGuideId = 0;
-
- HideGuide();
- }
- }
- public static void HideGuide()
- {
- ViewManager.Hide<GuideView>();
- }
- }
- }
|