2023-10-24 14:58:21 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using cfg.LevelCfg;
|
2023-11-02 20:02:10 +08:00
|
|
|
|
using cfg.RedPoint;
|
2024-01-19 14:00:42 +08:00
|
|
|
|
using Gameplay.Level;
|
2023-10-30 18:33:18 +08:00
|
|
|
|
using Gameplay.Net;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡组信息
|
|
|
|
|
|
/// </summary>
|
2024-09-05 13:41:39 +08:00
|
|
|
|
public class LevelGroupInfo : IRedPointTreeNode
|
2023-10-24 14:58:21 +08:00
|
|
|
|
{
|
2024-09-04 16:40:19 +08:00
|
|
|
|
#region 属性
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡信息列表
|
|
|
|
|
|
/// </summary>
|
2024-09-03 19:22:47 +08:00
|
|
|
|
public List<LevelInfo> ListLevelInfo { get; private set; } = new();
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// <summary>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// 关卡组配置
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// </summary>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
public DataLevelGroup Cfg { get; private set; }
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// <summary>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// 章节信息
|
2024-09-02 14:08:35 +08:00
|
|
|
|
/// </summary>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
public ChapterInfo ChapterInfo
|
|
|
|
|
|
{
|
2024-09-05 13:52:02 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LevelManager.Instance.TryGetChapterInfoByID(Cfg.ChapterID, out ChapterInfo chapterInfo))
|
|
|
|
|
|
return chapterInfo;
|
|
|
|
|
|
|
|
|
|
|
|
return chapterInfo;
|
|
|
|
|
|
}
|
2024-09-02 18:51:47 +08:00
|
|
|
|
}
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
public RedPointNode RedPoint { get; private set; }
|
2023-11-02 20:02:10 +08:00
|
|
|
|
|
2023-10-30 18:33:18 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前已经领取的奖励的最大index,从1开始
|
|
|
|
|
|
/// </summary>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
public int OwnRewardMaxIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Actor.Instance.Level.GetChapterRewardIndex(Cfg.Id); }
|
|
|
|
|
|
}
|
2023-10-30 18:33:18 +08:00
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 星星数量
|
|
|
|
|
|
/// </summary>
|
2023-10-26 20:20:11 +08:00
|
|
|
|
public int StarCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
int count = 0;
|
2024-09-03 19:22:47 +08:00
|
|
|
|
foreach (LevelInfo levelInfo in ListLevelInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-09-05 14:17:27 +08:00
|
|
|
|
count += levelInfo.Score;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 最大星星数量
|
|
|
|
|
|
/// </summary>
|
2024-09-04 16:40:19 +08:00
|
|
|
|
public int StarMax
|
|
|
|
|
|
{
|
2024-09-05 13:41:39 +08:00
|
|
|
|
get { return ListLevelInfo.Count * (int)NLDPB.GlobalDefine.MaxLevelStar; }
|
2024-09-04 16:40:19 +08:00
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否锁住
|
|
|
|
|
|
/// </summary>
|
2023-10-26 20:20:11 +08:00
|
|
|
|
public bool IsLock
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
foreach (LevelInfo levelInfo in ListLevelInfo)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2023-11-01 13:33:20 +08:00
|
|
|
|
if (!levelInfo.IsLock)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-04 16:40:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否有可以领取的奖励
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool IsHasGetReward
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
int curIndex = 1;
|
|
|
|
|
|
for (int i = 0; i < Cfg.StarList.Length; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (StarCount < Cfg.StarList[i])
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
curIndex = i + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return curIndex > OwnRewardMaxIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-04 17:23:16 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取下一个目标星级
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int NextTargerStar
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
int target = StarCount;
|
|
|
|
|
|
for (int i = Cfg.StarList.Length - 1; i >= 0; --i)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Cfg.StarList[i] > StarCount)
|
|
|
|
|
|
target = Cfg.StarList[i];
|
|
|
|
|
|
else
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return target;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-04 16:40:19 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
public LevelGroupInfo(DataLevelGroup config)
|
2023-10-24 14:58:21 +08:00
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
Cfg = config;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加关卡
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="levelInfo"></param>
|
2023-10-24 14:58:21 +08:00
|
|
|
|
public void AddLevel(LevelInfo levelInfo)
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
if (ListLevelInfo.Contains(levelInfo))
|
2023-10-24 14:58:21 +08:00
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
DebugUtil.LogError($"添加重复的关卡,关卡ID:{levelInfo.Cfg.Id}");
|
|
|
|
|
|
return;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
}
|
2024-09-02 18:51:47 +08:00
|
|
|
|
|
2024-09-03 19:22:47 +08:00
|
|
|
|
ListLevelInfo.Add(levelInfo);
|
2023-10-24 14:58:21 +08:00
|
|
|
|
}
|
2023-10-26 20:20:11 +08:00
|
|
|
|
|
2023-10-30 18:33:18 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否可以获得某个章节奖励,index从1开始
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-09-02 18:51:47 +08:00
|
|
|
|
public bool IsGetReward(int index)
|
2023-10-30 18:33:18 +08:00
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
return index > 0 &&
|
|
|
|
|
|
index <= Cfg.StarList.Length &&
|
|
|
|
|
|
StarCount >= Cfg.StarList[index - 1] &&
|
2024-09-04 16:40:19 +08:00
|
|
|
|
OwnRewardMaxIndex < index;
|
2023-10-30 18:33:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-02 18:51:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 计算红点树
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parent"></param>
|
2023-11-02 20:02:10 +08:00
|
|
|
|
public void ConstructRedPointTree(RedPointNode parent)
|
|
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
RedPoint = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parent);
|
2024-09-03 19:22:47 +08:00
|
|
|
|
foreach (LevelInfo levelInfo in ListLevelInfo)
|
2023-11-02 20:02:10 +08:00
|
|
|
|
{
|
2024-09-02 18:51:47 +08:00
|
|
|
|
levelInfo.ConstructRedPointTree(RedPoint);
|
2023-11-02 20:02:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-18 16:02:45 +08:00
|
|
|
|
|
2024-06-27 18:55:53 +08:00
|
|
|
|
public void ConstructRedPointTree(int parentID)
|
|
|
|
|
|
{
|
2024-09-03 19:22:47 +08:00
|
|
|
|
|
2024-06-27 18:55:53 +08:00
|
|
|
|
}
|
2023-10-24 14:58:21 +08:00
|
|
|
|
}
|