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
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2024-06-27 18:55:53 +08:00
|
|
|
|
public class LevelGroupInfo : IEnumerable<LevelInfo>, IRedPointTreeNode
|
2023-10-24 14:58:21 +08:00
|
|
|
|
{
|
2024-01-05 18:26:18 +08:00
|
|
|
|
private DataLevelGroup _config;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
private List<LevelInfo> _levelList = new();
|
|
|
|
|
|
|
2023-11-02 20:02:10 +08:00
|
|
|
|
private RedPointNode _redPointNode;
|
|
|
|
|
|
|
2023-10-24 14:58:21 +08:00
|
|
|
|
public int ID => _config.Id;
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
public int ChapterID => _config.ChapterID;
|
2023-10-24 14:58:21 +08:00
|
|
|
|
|
2024-01-19 14:00:42 +08:00
|
|
|
|
public ChapterInfo ChapterInfo => LevelManager.Instance.GetChapterInfoByID(ChapterID);
|
2024-06-27 18:55:53 +08:00
|
|
|
|
|
2023-10-24 14:58:21 +08:00
|
|
|
|
public LevelType LevelType => _config.Type;
|
|
|
|
|
|
|
|
|
|
|
|
public int[] StarList => _config.StarList;
|
|
|
|
|
|
|
|
|
|
|
|
public int[] Rewards => _config.Rewards;
|
|
|
|
|
|
|
2023-11-02 20:02:10 +08:00
|
|
|
|
public RedPointNode RedPointNode => _redPointNode;
|
|
|
|
|
|
|
2023-10-30 18:33:18 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前已经领取的奖励的最大index,从1开始
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int OwnRewardMaxIndex => Actor.Instance.Level.GetChapterRewardIndex(ID);
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
public int StarCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var count = 0;
|
|
|
|
|
|
foreach (var levelInfo in _levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
count += levelInfo.StarCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int StarMax => _levelList.Count * 3;
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsLock
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var levelInfo in _levelList)
|
|
|
|
|
|
{
|
2023-11-01 13:33:20 +08:00
|
|
|
|
if (!levelInfo.IsLock)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-05 19:15:21 +08:00
|
|
|
|
public LevelGroupInfo(DataLevelGroup config)
|
2023-10-24 14:58:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
_config = config;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddLevel(LevelInfo levelInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_levelList.Contains(levelInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
_levelList.Add(levelInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"cant add level,level id:{levelInfo.ID}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
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>
|
|
|
|
|
|
public bool CanGetReward(int index)
|
|
|
|
|
|
{
|
2024-01-18 17:16:20 +08:00
|
|
|
|
var alreadyGetIndex = OwnRewardMaxIndex;
|
|
|
|
|
|
return index > 0 && index <= StarList.Length && StarCount >= StarList[index - 1] && alreadyGetIndex < index;
|
2023-10-30 18:33:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-11-02 20:02:10 +08:00
|
|
|
|
public void ConstructRedPointTree(RedPointNode parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
_redPointNode = RedPointManager.Instance.AddDynamicNode(NodeType.Normal, parent);
|
|
|
|
|
|
foreach (var levelInfo in _levelList)
|
|
|
|
|
|
{
|
|
|
|
|
|
levelInfo.ConstructRedPointTree(_redPointNode);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-18 16:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
public IEnumerator<LevelInfo> GetEnumerator()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _levelList.GetEnumerator();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetEnumerator();
|
|
|
|
|
|
}
|
2024-06-27 18:55:53 +08:00
|
|
|
|
|
|
|
|
|
|
public void ConstructRedPointTree(int parentID)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
|
|
}
|
2023-10-24 14:58:21 +08:00
|
|
|
|
}
|