119 lines
2.6 KiB
C#
119 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 ChapterInfo
|
|
{
|
|
private DataChapter _config;
|
|
|
|
private List<LevelGroupInfo> _levelGroupList = new();
|
|
|
|
private RedPointNode _redPointNode;
|
|
|
|
public int ID => _config.Id;
|
|
|
|
public LevelChapterType 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 RedPointNode RedPointNode => _redPointNode;
|
|
|
|
public LevelGroupInfo PlotLevelGroup
|
|
{
|
|
get
|
|
{
|
|
return _levelGroupList.FirstOrDefault((lgi) => lgi.LevelType == LevelType.Plot);
|
|
}
|
|
}
|
|
|
|
public LevelGroupInfo EasyLevelGroup
|
|
{
|
|
get
|
|
{
|
|
return _levelGroupList.FirstOrDefault((lgi) => lgi.LevelType == LevelType.Easy);
|
|
}
|
|
}
|
|
|
|
public LevelGroupInfo HardLevelGroup
|
|
{
|
|
get
|
|
{
|
|
return _levelGroupList.FirstOrDefault((lgi) => lgi.LevelType == LevelType.Hard);
|
|
}
|
|
}
|
|
|
|
public int StarCount
|
|
{
|
|
get
|
|
{
|
|
var count = 0;
|
|
foreach (var lgi in _levelGroupList)
|
|
{
|
|
count += lgi.StarCount;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|
|
|
|
public int StarMax
|
|
{
|
|
get
|
|
{
|
|
var count = 0;
|
|
foreach (var lgi in _levelGroupList)
|
|
{
|
|
count += lgi.StarMax;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
}
|
|
|
|
public bool IsLock
|
|
{
|
|
get
|
|
{
|
|
foreach (var lgi in _levelGroupList)
|
|
{
|
|
if (!lgi.IsLock)
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public ChapterInfo(DataChapter config)
|
|
{
|
|
_config = config;
|
|
}
|
|
|
|
public void AddLevelGroup(LevelGroupInfo levelGroupInfo)
|
|
{
|
|
if (!_levelGroupList.Contains(levelGroupInfo))
|
|
{
|
|
_levelGroupList.Add(levelGroupInfo);
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.LogError($"cant add levelGroup,levelGroupID:{levelGroupInfo.ID}");
|
|
}
|
|
}
|
|
|
|
public void ConstructRedPointTree(int parentID)
|
|
{
|
|
_redPointNode = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parentID);
|
|
foreach (var lgi in _levelGroupList)
|
|
{
|
|
lgi.ConstructRedPointTree(_redPointNode);
|
|
}
|
|
}
|
|
} |