using System.Collections.Generic;
using cfg.LevelCfg;
using cfg.RedPoint;
using Gameplay;
///
/// 章节信息
///
public class ChapterInfo: IRedPointTreeNode
{
///
/// 关卡组信息字典
///
private readonly Dictionary dicLevelGroupInfoList = new();
#region 属性
///
/// 配置数据
///
public DataChapter Cfg { get; private set; }
///
/// 红点
///
public RedPointNode RedPoint { get; private set; }
///
/// 章节名
///
public string Name
{
get { return CommonUtils.GetLocalizeText(E_LocalizePrefix.ChapterName,Cfg.Id); }
}
///
/// 章节描述
///
public string Desc
{
get { return CommonUtils.GetLocalizeText(E_LocalizePrefix.ChapterDesc, Cfg.Id); }
}
///
/// 章节序号
///
public string Number
{
get { return CommonUtils.GetLocalizeText(E_LocalizePrefix.ChapterNumber, Cfg.Id); }
}
///
/// 是否锁住
///
public bool IsLock
{
get
{
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfoList.Values)
{
if (!levelGroupInfo.IsLock)
return false;
}
return true;
}
}
#endregion
public ChapterInfo(DataChapter config)
{
Cfg = config;
}
///
/// 获取关卡组数据根据难度
///
///
///
///
public bool TryGetGroupInfo(E_LevelDifficulty levelDifficulty, out LevelGroupInfo levelGroupInfo)
{
return dicLevelGroupInfoList.TryGetValue(levelDifficulty, out levelGroupInfo);
}
///
/// 添加关卡组信息
///
///
public void AddLevelGroupInfo(LevelGroupInfo info)
{
if (dicLevelGroupInfoList.ContainsKey(info.Cfg.LevelDifficulty))
{
DebugUtil.LogError($"重复添加关卡组,关卡组id:{info.Cfg.Id}");
return;
}
dicLevelGroupInfoList.Add(info.Cfg.LevelDifficulty, info);
}
///
/// 计算红点树
///
///
public void ConstructRedPointTree(int parentID)
{
RedPoint = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parentID);
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfoList.Values)
{
levelGroupInfo.ConstructRedPointTree(RedPoint);
}
}
public void ConstructRedPointTree(RedPointNode parent)
{
throw new System.NotImplementedException();
}
}