using System.Collections.Generic; using cfg.LevelCfg; using cfg.RedPoint; using Gameplay.Level; using Gameplay.Net; /// /// 关卡组信息 /// public class LevelGroupInfo : IRedPointTreeNode { #region 属性 /// /// 关卡信息列表 /// public List ListLevelInfo { get; private set; } = new(); /// /// 关卡组配置 /// public DataLevelGroup Cfg { get; private set; } /// /// 章节信息 /// public ChapterInfo ChapterInfo { get { if (LevelManager.Instance.TryGetChapterInfoByID(Cfg.ChapterID, out ChapterInfo chapterInfo)) return chapterInfo; return chapterInfo; } } public RedPointNode RedPoint { get; private set; } /// /// 当前已经领取的奖励的最大index,从1开始 /// public int OwnRewardMaxIndex { get { return Actor.Instance.Level.GetChapterRewardIndex(Cfg.Id); } } /// /// 星星数量或分数 /// public int Score { get { int count = 0; foreach (LevelInfo levelInfo in ListLevelInfo) { count += levelInfo.Score; } return count; } } /// /// 最大星星数量或最大评分 /// public int ScoreMax { get { int total = 0; foreach (LevelInfo levelInfo in ListLevelInfo) { total += levelInfo.ScoreMax; } return total; } } /// /// 关卡组评级 /// public E_WarRating WarRating { get { return LevelUtils.GetWarLevelRatingByLevelGroupInfo(this); } } /// /// 是否锁住 /// public bool IsLock { get { foreach (LevelInfo levelInfo in ListLevelInfo) { if (!levelInfo.IsLock) return false; } return true; } } /// /// 是否有可以领取的奖励 /// /// public bool IsHasGetRewards { get { int curIndex = 0; for (int i = 0; i < Cfg.StarList.Length; ++i) { if (Score < Cfg.StarList[i]) break; curIndex = i + 1; } return curIndex > OwnRewardMaxIndex; } } /// /// 获取下一个目标星级索引 /// public int NextTargerStarIndex { get { int index = Cfg.StarList.Length - 1; for (int i = Cfg.StarList.Length - 1; i >= 0; --i) { if (Cfg.StarList[i] > Score) index = i; else break; } return index; } } #endregion public LevelGroupInfo(DataLevelGroup config) { Cfg = config; } /// /// 添加关卡 /// /// public void AddLevel(LevelInfo levelInfo) { if (ListLevelInfo.Contains(levelInfo)) { DebugUtil.LogError($"添加重复的关卡,关卡ID:{levelInfo.Cfg.Id}"); return; } ListLevelInfo.Add(levelInfo); } /// /// 是否已经领取过,index从1开始 /// /// /// public bool IsGetReward(int index) { return index <= OwnRewardMaxIndex; } /// /// 计算红点树 /// /// public void ConstructRedPointTree(RedPointNode parent) { RedPoint = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parent); foreach (LevelInfo levelInfo in ListLevelInfo) { levelInfo.ConstructRedPointTree(RedPoint); } } public void ConstructRedPointTree(int parentID) { } }