NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/LevelGroupInfo.cs

194 lines
4.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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