using FairyGUI;
using UI.DressUp;
using UI.Main;
using System.Collections.Generic;
using cfg.GfgCfg;
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 < CommonDataManager.Tables.TblGuideCfg.DataList.Count ; i++)
{
if (GuideDataManager.IsGuideFinish(CommonDataManager.Tables.TblGuideCfg.DataList[i].GuideKey) <= 0)
{
isAllGuideFinish = false;
break;
}
isAllGuideFinish = true;
}
bool isGuide = GameGlobal.skipGuide == false && !isAllGuideFinish;
return isGuide;
}
///
/// 检测当前角色等级是否有引导开启,若有则返回引导id
///
///
public static string CheckHasRoleLvGuideOpen()
{
List guideCfgs = CommonDataManager.Tables.TblGuideCfg.DataList;
for (int i = 0; i < guideCfgs.Count; 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 "";
}
///
/// 是否特殊条件开启
///
///
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) && SuitUtil.GetClothingFosterHasSuitId();
}
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,bool otherChapterID = false)
{
if (!GameGlobal.PreDataInited)
{
return false;
}
GuideCfg cfg = CommonDataManager.Tables.TblGuideCfg.GetOrDefault(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
|| otherChapterID
|| MainStoryDataManager.currentLevelCfgId == cfg.StoryLevelId;//无选择(进入游戏时无选择)或当前所选择为配置关卡
if (isStoryLevelGuide && isPass && !isFinishCurId)
{
GuideDataManager.currentGuideId = cfg.Id;
TryCompleteGuide(guideKey);
GRoot.inst.touchable = true;
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.SendGuideFlowLog(GuideDataManager.currentGuideId * 100 + 1);
ViewManager.Show(new List