121 lines
2.6 KiB
C#
121 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using cfg.LevelCfg;
|
|
using cfg.RedPoint;
|
|
using UnityEngine;
|
|
|
|
public class LevelGroupInfo
|
|
{
|
|
private DataLevelGroup _config;
|
|
|
|
private List<ChapterInfo> _chapterList = new();
|
|
|
|
private RedPointNode _redPointNode;
|
|
|
|
public int ID => _config.Id;
|
|
|
|
public LevelGroupType GroupType => _config.Type;
|
|
|
|
public string MaterialIcon => _config.MaterialIcon;
|
|
|
|
public string Name => StringManager.Instance.GetLocalizeTextByKey(_config.Name);
|
|
|
|
public string Desc => StringManager.Instance.GetLocalizeTextByKey(_config.Desc);
|
|
|
|
public int Index => _config.Index;
|
|
|
|
public RedPointNode RedPointNode => _redPointNode;
|
|
|
|
public ChapterInfo PlotChapter
|
|
{
|
|
get
|
|
{
|
|
return _chapterList.First((chapter) => chapter.LevelType == LevelType.Plot);
|
|
}
|
|
}
|
|
|
|
public ChapterInfo EasyChapter
|
|
{
|
|
get
|
|
{
|
|
return _chapterList.First((chapter) => chapter.LevelType == LevelType.Easy);
|
|
}
|
|
}
|
|
|
|
public ChapterInfo HardChapter
|
|
{
|
|
get
|
|
{
|
|
return _chapterList.First((chapter) => chapter.LevelType == LevelType.Hard);
|
|
}
|
|
}
|
|
|
|
public int StarCount
|
|
{
|
|
get
|
|
{
|
|
var count = 0;
|
|
foreach (var chapterInfo in _chapterList)
|
|
{
|
|
count += chapterInfo.StarCount;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|
|
|
|
public int StarMax
|
|
{
|
|
get
|
|
{
|
|
var count = 0;
|
|
foreach (var chapterInfo in _chapterList)
|
|
{
|
|
count += chapterInfo.StarMax;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|
|
|
|
public bool IsLock
|
|
{
|
|
get
|
|
{
|
|
foreach (var chapterInfo in _chapterList)
|
|
{
|
|
if (!chapterInfo.IsLock)
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public LevelGroupInfo(DataLevelGroup config)
|
|
{
|
|
_config = config;
|
|
}
|
|
|
|
public void AddChapter(ChapterInfo chapterInfo)
|
|
{
|
|
if (!_chapterList.Contains(chapterInfo))
|
|
{
|
|
_chapterList.Add(chapterInfo);
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.LogError($"cant add chapter,chapterID:{chapterInfo.ID}");
|
|
}
|
|
}
|
|
|
|
public void ConstructRedPointTree(int parentID)
|
|
{
|
|
_redPointNode = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parentID);
|
|
foreach (var chapterInfo in _chapterList)
|
|
{
|
|
chapterInfo.ConstructRedPointTree(_redPointNode);
|
|
}
|
|
}
|
|
} |