优化关卡数据相关API
parent
b7749e5504
commit
c08be4c84a
|
|
@ -13,10 +13,12 @@ public class ConditionLevelPass : ICondition
|
|||
|
||||
public bool Check(List<float> args)
|
||||
{
|
||||
var id = (int)args[0];
|
||||
int id = (int)args[0];
|
||||
|
||||
var levelInfo = LevelManager.Instance.GetLevelInfoByID(id);
|
||||
return levelInfo != null && levelInfo.IsPass;
|
||||
if (!LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
|
||||
return false;
|
||||
|
||||
return levelInfo.IsPass;
|
||||
}
|
||||
|
||||
public string[] GetArgLocalizations(List<float> args)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ public class ConditionLevelStar : ICondition
|
|||
|
||||
public bool Check(List<float> args)
|
||||
{
|
||||
var id = (int)args[0];
|
||||
var star = (int)args[1];
|
||||
int id = (int)args[0];
|
||||
int star = (int)args[1];
|
||||
|
||||
var levelInfo = LevelManager.Instance.GetLevelInfoByID(id);
|
||||
return levelInfo != null && levelInfo.StarCount >= star;
|
||||
if (!LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
|
||||
return false;
|
||||
|
||||
return levelInfo.StarCount >= star;
|
||||
}
|
||||
|
||||
public string[] GetArgLocalizations(List<float> args)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Gameplay
|
|||
return;
|
||||
}
|
||||
|
||||
LevelInfo levelInfo = LevelManager.Instance.GetLevelInfoByID(levelId); //new LevelInfo(data);
|
||||
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
||||
|
||||
await UI_LevelSelectController.Open(levelInfo);
|
||||
}
|
||||
|
|
@ -85,10 +85,10 @@ namespace Gameplay
|
|||
}
|
||||
|
||||
|
||||
LevelInfo levelInfo = LevelManager.Instance.GetLevelInfoByID(levelId); //new LevelInfo(data);
|
||||
LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo);
|
||||
|
||||
await UI_LevelSelectController.Open(levelInfo);
|
||||
UI_LevelDetailController.Open(levelInfo);
|
||||
await UI_LevelDetailController.Open(levelInfo);
|
||||
}
|
||||
|
||||
public static async void JumpToShopDetail(int shopID)
|
||||
|
|
|
|||
|
|
@ -39,40 +39,6 @@ public class ChapterInfo: IRedPointTreeNode
|
|||
get { return StringManager.Instance.GetLocalizeTextByKey(Cfg.Desc); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 星星数量
|
||||
/// </summary>
|
||||
public int StarCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfoList.Values)
|
||||
{
|
||||
count += levelGroupInfo.StarCount;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最大星星数量
|
||||
/// </summary>
|
||||
public int StarMax
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfoList.Values)
|
||||
{
|
||||
count += levelGroupInfo.StarMax;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否锁住
|
||||
/// </summary>
|
||||
|
|
@ -89,23 +55,6 @@ public class ChapterInfo: IRedPointTreeNode
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所有关卡信息
|
||||
/// </summary>
|
||||
public IEnumerable<LevelInfo> AllLevelInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfoList.Values)
|
||||
{
|
||||
foreach (LevelInfo levelInfo in levelGroupInfo)
|
||||
{
|
||||
yield return levelInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public ChapterInfo(DataChapter config)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Gameplay.Level
|
|||
|
||||
private void LoadConfigLevel()
|
||||
{
|
||||
_currLevelInfo = LevelManager.Instance.GetLevelInfoByID(_id);
|
||||
LevelManager.Instance.TryGetLevelInfoByID(_id, out _currLevelInfo);
|
||||
}
|
||||
|
||||
private async UniTask LoadScene()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Gameplay.Net;
|
|||
/// <summary>
|
||||
/// 关卡组信息
|
||||
/// </summary>
|
||||
public class LevelGroupInfo : IEnumerable<LevelInfo>, IRedPointTreeNode
|
||||
public class LevelGroupInfo : IRedPointTreeNode
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>
|
||||
|
|
@ -61,7 +61,7 @@ public class LevelGroupInfo : IEnumerable<LevelInfo>, IRedPointTreeNode
|
|||
/// </summary>
|
||||
public int StarMax
|
||||
{
|
||||
get { return ListLevelInfo.Count * 3; }
|
||||
get { return ListLevelInfo.Count * (int)NLDPB.GlobalDefine.MaxLevelStar; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -169,16 +169,6 @@ public class LevelGroupInfo : IEnumerable<LevelInfo>, IRedPointTreeNode
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerator<LevelInfo> GetEnumerator()
|
||||
{
|
||||
return ListLevelInfo.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void ConstructRedPointTree(int parentID)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ public class LevelInfo : IRedPointTreeNode
|
|||
/// <summary>
|
||||
/// 章节索引
|
||||
/// </summary>
|
||||
private int _chapterIndex = -1;
|
||||
private int chapterIndex = -1;
|
||||
/// <summary>
|
||||
/// 关卡索引
|
||||
/// </summary>
|
||||
private int _levelIndex = -1;
|
||||
private int levelIndex = -1;
|
||||
/// <summary>
|
||||
/// 解锁条件id
|
||||
/// </summary>
|
||||
|
|
@ -73,7 +73,7 @@ public class LevelInfo : IRedPointTreeNode
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_chapterIndex == -1)
|
||||
if (-1 == chapterIndex)
|
||||
{
|
||||
if (Cfg.Id < 100000)
|
||||
{
|
||||
|
|
@ -81,11 +81,11 @@ public class LevelInfo : IRedPointTreeNode
|
|||
return 0;
|
||||
}
|
||||
|
||||
var resultStr = Cfg.Id.ToString().Substring(1, 2);
|
||||
_chapterIndex = int.Parse(resultStr);
|
||||
string resultStr = Cfg.Id.ToString().Substring(1, 2);
|
||||
chapterIndex = int.Parse(resultStr);
|
||||
}
|
||||
|
||||
return _chapterIndex;
|
||||
return chapterIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ public class LevelInfo : IRedPointTreeNode
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_levelIndex == -1)
|
||||
if (-1 == levelIndex)
|
||||
{
|
||||
if (Cfg.Id < 100000)
|
||||
{
|
||||
|
|
@ -104,11 +104,11 @@ public class LevelInfo : IRedPointTreeNode
|
|||
return 0;
|
||||
}
|
||||
|
||||
var resultStr = Cfg.Id.ToString().Substring(3, 3);
|
||||
_levelIndex = int.Parse(resultStr);
|
||||
string resultStr = Cfg.Id.ToString().Substring(3, 3);
|
||||
levelIndex = int.Parse(resultStr);
|
||||
}
|
||||
|
||||
return _levelIndex;
|
||||
return levelIndex;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -130,7 +130,6 @@ public class LevelInfo : IRedPointTreeNode
|
|||
get { return GroupInfo?.ChapterInfo; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 环境类型
|
||||
/// </summary>
|
||||
|
|
@ -194,7 +193,7 @@ public class LevelInfo : IRedPointTreeNode
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Server Data
|
||||
#region 服务器数据
|
||||
/// <summary>
|
||||
/// 星级数量
|
||||
/// </summary>
|
||||
|
|
@ -331,7 +330,7 @@ public class LevelInfo : IRedPointTreeNode
|
|||
if (result)
|
||||
{
|
||||
IsLock = false;
|
||||
DebugUtil.Log($"[Level] level unlock,id:{Cfg.Id}");
|
||||
DebugUtil.Log($"关卡未解锁,id:{Cfg.Id}");
|
||||
EventManager.Instance.Send(EventManager.EventName.LevelUnlock, Cfg.Id);
|
||||
ConditionReactor.Instance.RemoveReaction(reactionID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,8 +128,7 @@ namespace Gameplay.Level
|
|||
|
||||
private void _EnterLevelDirectly(int levelID)
|
||||
{
|
||||
var levelInfo = Instance.GetLevelInfoByID(levelID);
|
||||
if (levelInfo == null)
|
||||
if (!Instance.TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
{
|
||||
Debug.LogError($"关卡不存在,id:{levelID}");
|
||||
return;
|
||||
|
|
@ -210,8 +209,7 @@ namespace Gameplay.Level
|
|||
return;
|
||||
}
|
||||
|
||||
var levelInfo = GetLevelInfoByID(id);
|
||||
if (levelInfo == null)
|
||||
if(!TryGetLevelInfoByID(id, out LevelInfo levelInfo))
|
||||
{
|
||||
Debug.LogError($"关卡不存在,id:{id}");
|
||||
return;
|
||||
|
|
@ -257,7 +255,9 @@ namespace Gameplay.Level
|
|||
_enterLevelFinishCallBack = enterLevelFinishCallBack;
|
||||
_levelParam = param;
|
||||
_EnterLevelDirectly(levelID);
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
if (!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
return;
|
||||
|
||||
if (!levelInfo.IsStory && GuideManager.Instance.IsGuiding)
|
||||
PlayBGM();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ namespace Gameplay.Level
|
|||
/// </summary>
|
||||
private Dictionary<E_ChapterType, List<ChapterInfo>> dicChapterType = new();
|
||||
|
||||
public List<LevelInfo> ListLevelInfo
|
||||
{
|
||||
get { return dicLevelInfo.Values.ToList(); }
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, OnAllConfigLoad);
|
||||
|
|
@ -53,151 +48,10 @@ namespace Gameplay.Level
|
|||
dicLevelGroupInfo = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置
|
||||
/// </summary>
|
||||
private void OnAllConfigLoad()
|
||||
{
|
||||
LoadAllLevelInfo();
|
||||
LoadAllLevelGroup();
|
||||
LoadAllChapter();
|
||||
ConstructRedPointTree();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有关卡信息
|
||||
/// </summary>
|
||||
private void LoadAllLevelInfo()
|
||||
{
|
||||
dicLevelInfo.Clear();
|
||||
List<DataLevel> listAllLevelConfig = TableManager.Instance.Tables.Level.DataList;
|
||||
|
||||
foreach (DataLevel config in listAllLevelConfig)
|
||||
{
|
||||
dicLevelInfo.Add(config.Id, new LevelInfo(config));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有章节
|
||||
/// </summary>
|
||||
private void LoadAllChapter()
|
||||
{
|
||||
dicChapterInfo.Clear();
|
||||
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfo.Values)
|
||||
{
|
||||
int chapterID = levelGroupInfo.Cfg.ChapterID;
|
||||
if (!dicChapterInfo.TryGetValue(chapterID, out ChapterInfo chapterInfo))
|
||||
{
|
||||
DataChapter config = TableManager.Instance.Tables.Chapter.Get(chapterID);
|
||||
if (null != config)
|
||||
{
|
||||
chapterInfo = new ChapterInfo(config);
|
||||
dicChapterInfo.Add(chapterID, chapterInfo);
|
||||
}
|
||||
else
|
||||
DebugUtil.LogError($"找不到章节配置,id:{chapterID}");
|
||||
}
|
||||
|
||||
chapterInfo?.AddLevelGroupInfo(levelGroupInfo);
|
||||
}
|
||||
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
E_ChapterType chapterType = chapterInfo.Cfg.Type;
|
||||
if (!dicChapterType.TryGetValue(chapterType, out List<ChapterInfo> list))
|
||||
{
|
||||
list = new();
|
||||
dicChapterType.Add(chapterType, list);
|
||||
}
|
||||
|
||||
list.Add(chapterInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有关卡组信息
|
||||
/// </summary>
|
||||
private void LoadAllLevelGroup()
|
||||
{
|
||||
dicLevelGroupInfo.Clear();
|
||||
foreach (LevelInfo levelInfo in dicLevelInfo.Values)
|
||||
{
|
||||
int levelGroupID = levelInfo.Cfg.LevelGroupID;
|
||||
if (!dicLevelGroupInfo.TryGetValue(levelGroupID, out LevelGroupInfo levelGroupInfo))
|
||||
{
|
||||
DataLevelGroup config = TableManager.Instance.Tables.LevelGroupConfig.Get(levelGroupID);
|
||||
if (null != config)
|
||||
{
|
||||
levelGroupInfo = new LevelGroupInfo(config);
|
||||
dicLevelGroupInfo.Add(levelGroupID, levelGroupInfo);
|
||||
}
|
||||
else
|
||||
DebugUtil.LogError($"找不到关卡组配置, id: {levelGroupID}");
|
||||
}
|
||||
|
||||
levelGroupInfo?.AddLevel(levelInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConstructRedPointTree()
|
||||
{
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
int index = (int)chapterInfo.Cfg.Type;
|
||||
if (index < 0 || index > _levelGroupTypeRedPointIDArray.Length)
|
||||
{
|
||||
DebugUtil.LogError($"index is out of range!index:{index}");
|
||||
continue;
|
||||
}
|
||||
|
||||
int redPointParentID = _levelGroupTypeRedPointIDArray[index];
|
||||
chapterInfo.ConstructRedPointTree(redPointParentID);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeRedPointTree()
|
||||
{
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
if (null != chapterInfo.RedPoint)
|
||||
RedPointManager.Instance.RemoveDynamicNode(chapterInfo.RedPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新的关卡服务器数据
|
||||
/// </summary>
|
||||
/// <param name="levelID"></param>
|
||||
private void OnNewLevelServerData(int levelID)
|
||||
{
|
||||
LevelInfo levelInfo = GetLevelInfoByID(levelID);
|
||||
levelInfo?.RefreshServerData(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存战斗关卡
|
||||
/// </summary>
|
||||
/// <param name="levelInfo"></param>
|
||||
private void SaveFightLevel(LevelInfo levelInfo)
|
||||
{
|
||||
if(null == levelInfo)
|
||||
return;
|
||||
|
||||
LevelGroupInfo levelGroupInfo = levelInfo.GroupInfo;
|
||||
if(null == levelGroupInfo)
|
||||
return;
|
||||
|
||||
ChapterInfo chapterInfo = levelGroupInfo.ChapterInfo;
|
||||
if(null == chapterInfo)
|
||||
return;
|
||||
|
||||
PlayerPrefs.SetInt(GetChapterTypeSaveKey(chapterInfo.Cfg.Type), levelInfo.Cfg.Id);
|
||||
}
|
||||
|
||||
private string GetChapterTypeSaveKey(E_ChapterType chapterType) => LAST_FIGHT_LEVEL_PREFIX + chapterType;
|
||||
|
||||
#region API
|
||||
/// <summary>
|
||||
/// 刷新所有关卡信息
|
||||
/// </summary>
|
||||
public void RefreshAllLevelInfo()
|
||||
{
|
||||
foreach (LevelInfo levelInfo in dicLevelInfo.Values)
|
||||
|
|
@ -206,14 +60,20 @@ namespace Gameplay.Level
|
|||
}
|
||||
}
|
||||
|
||||
public LevelInfo GetLevelInfoByID(int id)
|
||||
/// <summary>
|
||||
/// 通关关卡id获取关卡信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryGetLevelInfoByID(int id, out LevelInfo levelInfo)
|
||||
{
|
||||
if (!dicLevelInfo.TryGetValue(id, out var levelInfo))
|
||||
if (!dicLevelInfo.TryGetValue(id, out levelInfo))
|
||||
{
|
||||
DebugUtil.LogError($"找不到levelInfo,id:{id}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return levelInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
public LevelGroupInfo GetLevelGroupInfoByID(int id)
|
||||
|
|
@ -264,28 +124,6 @@ namespace Gameplay.Level
|
|||
return dicLevelGroupInfo.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某种关卡类型的最新进度
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public LevelInfo GetLatestLevelInfo(E_ChapterType type)
|
||||
{
|
||||
if (dicChapterType.TryGetValue(type, out var list))
|
||||
{
|
||||
ChapterInfo latestChapterInfo = list.Where(chapterInfo => !chapterInfo.IsLock).ToList()[^1];
|
||||
if (null == latestChapterInfo)
|
||||
return null;
|
||||
|
||||
List<LevelInfo> allUnlockLevels = latestChapterInfo.AllLevelInfo.Where(level => !level.IsLock).ToList();
|
||||
allUnlockLevels.Sort((a, b) => a.Cfg.Id.CompareTo(b.Cfg.Id));
|
||||
|
||||
return allUnlockLevels[^1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//获取某种关卡类型上一次战斗的关卡
|
||||
public LevelInfo GetLastFightLevelInfo(E_ChapterType type)
|
||||
{
|
||||
|
|
@ -296,7 +134,8 @@ namespace Gameplay.Level
|
|||
}
|
||||
|
||||
var levelID = PlayerPrefs.GetInt(key);
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
TryGetLevelInfoByID(levelID, out LevelInfo levelInfo);
|
||||
|
||||
return levelInfo;
|
||||
}
|
||||
|
||||
|
|
@ -312,12 +151,16 @@ namespace Gameplay.Level
|
|||
DebugUtil.LogError("error level ID! ");
|
||||
return E_ChapterType.Main;
|
||||
}
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
|
||||
if (!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
return E_ChapterType.Count;
|
||||
|
||||
int levelGroupID = levelInfo.Cfg.LevelGroupID;
|
||||
DataLevelGroup config = TableManager.Instance.Tables.LevelGroupConfig.Get(levelGroupID);
|
||||
|
||||
DataChapter chapterCfg = TableManager.Instance.Tables.Chapter.Get(config.ChapterID);
|
||||
var chapterInfo = new ChapterInfo(chapterCfg);
|
||||
|
||||
return chapterInfo.Cfg.Type;
|
||||
}
|
||||
|
||||
|
|
@ -328,34 +171,34 @@ namespace Gameplay.Level
|
|||
/// <returns></returns>
|
||||
public bool CheckLevelUnlock(int levelID)
|
||||
{
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
if(levelInfo == null)
|
||||
if(!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
{
|
||||
DebugUtil.LogError($"cant find levelInfo,id:{levelID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return !levelInfo.IsLock;
|
||||
}
|
||||
|
||||
public string LevelIDToNum(int levelID)
|
||||
{
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
if(levelInfo == null)
|
||||
if(!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
{
|
||||
DebugUtil.LogError($"cant find levelInfo,id:{levelID}");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return levelInfo.ChapterIndex + "-" + levelInfo.LevelIndex;
|
||||
}
|
||||
|
||||
public string LevelIDToName(int levelID)
|
||||
{
|
||||
var levelInfo = GetLevelInfoByID(levelID);
|
||||
if (levelInfo == null)
|
||||
if(!TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
{
|
||||
DebugUtil.LogError($"cant find levelInfo,id:{levelID}");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return levelInfo.Name;
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +221,152 @@ namespace Gameplay.Level
|
|||
}
|
||||
return info.Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 私有方法
|
||||
/// <summary>
|
||||
/// 加载配置
|
||||
/// </summary>
|
||||
private void OnAllConfigLoad()
|
||||
{
|
||||
LoadAllLevelInfo();
|
||||
LoadAllLevelGroup();
|
||||
LoadAllChapter();
|
||||
ConstructRedPointTree();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有关卡信息
|
||||
/// </summary>
|
||||
private void LoadAllLevelInfo()
|
||||
{
|
||||
dicLevelInfo.Clear();
|
||||
List<DataLevel> listAllLevelConfig = TableManager.Instance.Tables.Level.DataList;
|
||||
|
||||
foreach (DataLevel config in listAllLevelConfig)
|
||||
{
|
||||
dicLevelInfo.Add(config.Id, new LevelInfo(config));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有关卡组信息
|
||||
/// </summary>
|
||||
private void LoadAllLevelGroup()
|
||||
{
|
||||
dicLevelGroupInfo.Clear();
|
||||
foreach (LevelInfo levelInfo in dicLevelInfo.Values)
|
||||
{
|
||||
int levelGroupID = levelInfo.Cfg.LevelGroupID;
|
||||
if (!dicLevelGroupInfo.TryGetValue(levelGroupID, out LevelGroupInfo levelGroupInfo))
|
||||
{
|
||||
DataLevelGroup config = TableManager.Instance.Tables.LevelGroupConfig.Get(levelGroupID);
|
||||
if (null != config)
|
||||
{
|
||||
levelGroupInfo = new LevelGroupInfo(config);
|
||||
dicLevelGroupInfo.Add(levelGroupID, levelGroupInfo);
|
||||
}
|
||||
else
|
||||
DebugUtil.LogError($"找不到关卡组配置, id: {levelGroupID}");
|
||||
}
|
||||
|
||||
levelGroupInfo?.AddLevel(levelInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有章节
|
||||
/// </summary>
|
||||
private void LoadAllChapter()
|
||||
{
|
||||
dicChapterInfo.Clear();
|
||||
foreach (LevelGroupInfo levelGroupInfo in dicLevelGroupInfo.Values)
|
||||
{
|
||||
int chapterID = levelGroupInfo.Cfg.ChapterID;
|
||||
if (!dicChapterInfo.TryGetValue(chapterID, out ChapterInfo chapterInfo))
|
||||
{
|
||||
DataChapter config = TableManager.Instance.Tables.Chapter.Get(chapterID);
|
||||
if (null != config)
|
||||
{
|
||||
chapterInfo = new ChapterInfo(config);
|
||||
dicChapterInfo.Add(chapterID, chapterInfo);
|
||||
}
|
||||
else
|
||||
DebugUtil.LogError($"找不到章节配置,id:{chapterID}");
|
||||
}
|
||||
|
||||
chapterInfo?.AddLevelGroupInfo(levelGroupInfo);
|
||||
}
|
||||
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
E_ChapterType chapterType = chapterInfo.Cfg.Type;
|
||||
if (!dicChapterType.TryGetValue(chapterType, out List<ChapterInfo> list))
|
||||
{
|
||||
list = new();
|
||||
dicChapterType.Add(chapterType, list);
|
||||
}
|
||||
|
||||
list.Add(chapterInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConstructRedPointTree()
|
||||
{
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
int index = (int)chapterInfo.Cfg.Type;
|
||||
if (index < 0 || index > _levelGroupTypeRedPointIDArray.Length)
|
||||
{
|
||||
DebugUtil.LogError($"index is out of range!index:{index}");
|
||||
continue;
|
||||
}
|
||||
|
||||
int redPointParentID = _levelGroupTypeRedPointIDArray[index];
|
||||
chapterInfo.ConstructRedPointTree(redPointParentID);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeRedPointTree()
|
||||
{
|
||||
foreach (ChapterInfo chapterInfo in dicChapterInfo.Values)
|
||||
{
|
||||
if (null != chapterInfo.RedPoint)
|
||||
RedPointManager.Instance.RemoveDynamicNode(chapterInfo.RedPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新的关卡服务器数据
|
||||
/// </summary>
|
||||
/// <param name="levelID"></param>
|
||||
private void OnNewLevelServerData(int levelID)
|
||||
{
|
||||
if (TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
levelInfo.RefreshServerData(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存战斗关卡
|
||||
/// </summary>
|
||||
/// <param name="levelInfo"></param>
|
||||
private void SaveFightLevel(LevelInfo levelInfo)
|
||||
{
|
||||
if(null == levelInfo)
|
||||
return;
|
||||
|
||||
LevelGroupInfo levelGroupInfo = levelInfo.GroupInfo;
|
||||
if(null == levelGroupInfo)
|
||||
return;
|
||||
|
||||
ChapterInfo chapterInfo = levelGroupInfo.ChapterInfo;
|
||||
if(null == chapterInfo)
|
||||
return;
|
||||
|
||||
PlayerPrefs.SetInt(GetChapterTypeSaveKey(chapterInfo.Cfg.Type), levelInfo.Cfg.Id);
|
||||
}
|
||||
|
||||
private string GetChapterTypeSaveKey(E_ChapterType chapterType) => LAST_FIGHT_LEVEL_PREFIX + chapterType;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -19,23 +19,20 @@ namespace Gameplay.Net
|
|||
{
|
||||
public uint id; // 关卡ID
|
||||
public bool isPassed; // 关卡是否通关
|
||||
public uint []star; // 关卡获得的星
|
||||
public uint[] star; // 关卡获得的星
|
||||
|
||||
public uint StarCount {
|
||||
public uint StarCount
|
||||
{
|
||||
get
|
||||
{
|
||||
uint c = 0;
|
||||
for(int i = 0; i < star.Length; i ++)
|
||||
for (int i = 0; i < star.Length; i++)
|
||||
{
|
||||
if(star[i] > 0)
|
||||
{
|
||||
c ++;
|
||||
}
|
||||
c += star[i];
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LevelInfo()
|
||||
|
|
|
|||
|
|
@ -146,13 +146,9 @@ public partial class PVPManager : Singlenton<PVPManager>, IInitable, IUpdatable
|
|||
|
||||
private void OnAllConfigLoad()
|
||||
{
|
||||
var pvpLevelID = TableManager.Instance.Tables.GlobalConfig.PVPLevelID;
|
||||
_pvpLevelInfo = LevelManager.Instance.GetLevelInfoByID(pvpLevelID);
|
||||
if (_pvpLevelInfo == null)
|
||||
{
|
||||
int pvpLevelID = TableManager.Instance.Tables.GlobalConfig.PVPLevelID;
|
||||
if (!LevelManager.Instance.TryGetLevelInfoByID(pvpLevelID, out _pvpLevelInfo))
|
||||
DebugUtil.LogError($"找不到关卡配置,id:{pvpLevelID}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float dt)
|
||||
|
|
|
|||
|
|
@ -148,42 +148,39 @@ public class UIFightClockController : UIWindow{
|
|||
_RefreshOnFightTxt();
|
||||
}
|
||||
|
||||
#region LevelInfo
|
||||
#region LevelInfo
|
||||
|
||||
private async void _RefreshLevelInfo()
|
||||
{
|
||||
var curLevelInfo = LevelManager.Instance.GetLevelInfoByID(LevelManager.Instance.CurrentLevel.ID);
|
||||
if (curLevelInfo != null)
|
||||
{
|
||||
|
||||
var dayNightConfig = CommonUtils.GetDayNightConfig(curLevelInfo.Cfg.LevelTime);
|
||||
var weatherConfig = CommonUtils.GetWeatherConfig(curLevelInfo.Cfg.LevelWeather);
|
||||
var environmentConfig = CommonUtils.GetEnvironmentConfig(curLevelInfo.Environment);
|
||||
if (!LevelManager.Instance.TryGetLevelInfoByID(LevelManager.Instance.CurrentLevel.ID, out LevelInfo curLevelInfo))
|
||||
return;
|
||||
|
||||
var imgDay = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_DayOrNight");
|
||||
var txtDay = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_DayOrNight/Text_DayOrNight");
|
||||
imgDay.sprite = await LoadAssetAsync<Sprite>(dayNightConfig.Icon);
|
||||
txtDay.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
|
||||
|
||||
var imgWeather = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_weather");
|
||||
var txtWeather = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_weather/Text_WeatherAndLand01");
|
||||
imgWeather.sprite = await LoadAssetAsync<Sprite>(weatherConfig.Icon);
|
||||
txtWeather.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
|
||||
|
||||
var imgEnvironment = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_environment");
|
||||
var txtEnvironment = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_environment/Text_WeatherAndLand02");
|
||||
imgEnvironment.sprite = await LoadAssetAsync<Sprite>(environmentConfig.Icon);
|
||||
txtEnvironment.text = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
|
||||
var dayNightConfig = CommonUtils.GetDayNightConfig(curLevelInfo.Cfg.LevelTime);
|
||||
var weatherConfig = CommonUtils.GetWeatherConfig(curLevelInfo.Cfg.LevelWeather);
|
||||
var environmentConfig = CommonUtils.GetEnvironmentConfig(curLevelInfo.Environment);
|
||||
|
||||
var txtMissionName = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo,"Text_MissionName");
|
||||
var txtLevelNum = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo,"Text_LevelNum");
|
||||
var levelNum = CommonUtils.GetLevelLabel(curLevelInfo);
|
||||
txtMissionName.text = curLevelInfo.Desc;
|
||||
txtLevelNum.text = levelNum;
|
||||
}
|
||||
var imgDay = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_DayOrNight");
|
||||
var txtDay = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_DayOrNight/Text_DayOrNight");
|
||||
imgDay.sprite = await LoadAssetAsync<Sprite>(dayNightConfig.Icon);
|
||||
txtDay.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
|
||||
|
||||
var imgWeather = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_weather");
|
||||
var txtWeather = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_weather/Text_WeatherAndLand01");
|
||||
imgWeather.sprite = await LoadAssetAsync<Sprite>(weatherConfig.Icon);
|
||||
txtWeather.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
|
||||
|
||||
var imgEnvironment = CommonUtils.GetComponent<Image>(_goTopLevelInfo, "Image_Weather/Image_environment");
|
||||
var txtEnvironment = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Image_Weather/Image_environment/Text_WeatherAndLand02");
|
||||
imgEnvironment.sprite = await LoadAssetAsync<Sprite>(environmentConfig.Icon);
|
||||
txtEnvironment.text = CommonUtils.GetLocalizeText(environmentConfig.NameLocal);
|
||||
|
||||
var txtMissionName = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Text_MissionName");
|
||||
var txtLevelNum = CommonUtils.GetComponent<TMP_Text>(_goTopLevelInfo, "Text_LevelNum");
|
||||
var levelNum = CommonUtils.GetLevelLabel(curLevelInfo);
|
||||
txtMissionName.text = curLevelInfo.Desc;
|
||||
txtLevelNum.text = levelNum;
|
||||
}
|
||||
|
||||
|
||||
private void _OnPreEnterBattle()
|
||||
{
|
||||
if (_goTopLevelInfo.activeSelf)
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ public class UIPauseController : UIWindow
|
|||
|
||||
private void Refresh()
|
||||
{
|
||||
var levelData = LevelManager.Instance.CurrentLevel.GetLevelData();
|
||||
var levelInfo = LevelManager.Instance.GetLevelInfoByID(LevelManager.Instance.CurrentLevel.ID);
|
||||
LevelData levelData = LevelManager.Instance.CurrentLevel.GetLevelData();
|
||||
LevelManager.Instance.TryGetLevelInfoByID(LevelManager.Instance.CurrentLevel.ID, out LevelInfo levelInfo);
|
||||
RefreshLevelInfo(levelData);
|
||||
RefreshFinish(levelData);
|
||||
RefreshWeather(levelInfo);
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ public class RedPointNodeLevel : RedPointNode
|
|||
|
||||
protected override int GetCount()
|
||||
{
|
||||
if (param == null)
|
||||
if (null == param)
|
||||
throw new Exception($"param is null! id:{ID}");
|
||||
var levelID = (int)param;
|
||||
var levelInfo = LevelManager.Instance.GetLevelInfoByID(levelID);
|
||||
if (levelInfo != null)
|
||||
{
|
||||
if (!levelInfo.IsLock && !levelInfo.IsPass)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int levelID = (int)param;
|
||||
if (!LevelManager.Instance.TryGetLevelInfoByID(levelID, out LevelInfo levelInfo))
|
||||
return 0;
|
||||
|
||||
if (!levelInfo.IsLock && !levelInfo.IsPass)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading;
|
|||
using cfg.FightCfg;
|
||||
using cfg.LevelCfg;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Framework;
|
||||
using Gameplay;
|
||||
using Gameplay.Common;
|
||||
|
|
@ -69,6 +70,10 @@ public class UI_LevelSelectController : UIWindow
|
|||
/// 章节类型
|
||||
/// </summary>
|
||||
private readonly E_ChapterType chapterType;
|
||||
/// <summary>
|
||||
/// 箭头旋转动画
|
||||
/// </summary>
|
||||
private readonly Tweener tweener;
|
||||
|
||||
public bool IsSelect
|
||||
{
|
||||
|
|
@ -77,6 +82,10 @@ public class UI_LevelSelectController : UIWindow
|
|||
goSelect.IsScaleShow(value);
|
||||
goTriangle.IsScaleShow(value);
|
||||
goUnSelect.IsScaleShow(!value);
|
||||
if (value)
|
||||
tweener.Restart();
|
||||
else
|
||||
tweener.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +99,8 @@ public class UI_LevelSelectController : UIWindow
|
|||
goUnSelect = FindObj("Image_Unselect");
|
||||
goTriangle = FindObj("Image_Triangle");
|
||||
|
||||
tweener = goTriangle.transform.DOLocalRotateQuaternion(Quaternion.Euler(0f, 180f, 0f), 1f).SetLoops(-1);
|
||||
|
||||
IsSelect = false;
|
||||
|
||||
BindButton(button, OnClick);
|
||||
|
|
@ -1150,6 +1161,10 @@ public class UI_LevelSelectController : UIWindow
|
|||
/// 不能领取奖励状态
|
||||
/// </summary>
|
||||
private GameObject goGetRewardOff;
|
||||
/// <summary>
|
||||
/// 资源选择根节点
|
||||
/// </summary>
|
||||
private GameObject goResourceRoot;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1170,6 +1185,8 @@ public class UI_LevelSelectController : UIWindow
|
|||
textStarProgress = GetComponent<TMP_Text>("UI_StarProgress/Image_StarProgress/Text_Progress");
|
||||
imageStarProgress = GetComponent<Image>("UI_StarProgress/Image_StarProgress/Image_ProgressBar");
|
||||
goGetRewardOff = FindObj("UI_StarProgress/Button_GetRewardOff");
|
||||
goResourceRoot = FindObj("Image_ResourcesCollection");
|
||||
goResourceRoot.IsScaleShow(false);
|
||||
|
||||
BindButton(buttonGetReward, OnStarReward);
|
||||
}
|
||||
|
|
@ -1626,7 +1643,12 @@ public class UI_LevelSelectController : UIWindow
|
|||
|
||||
public bool IsEnableRecycleView
|
||||
{
|
||||
set { recycleView.ScrollRect.enabled = value; }
|
||||
set
|
||||
{
|
||||
recycleView.ScrollRect.enabled = value;
|
||||
if (value)
|
||||
recycleView.ScrollRect.horizontalNormalizedPosition = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public LevelList(GameObject root, Action<LevelInfo> level) : base(root)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public class PVPTools
|
|||
public static void PrintPvpDefendRegion()
|
||||
{
|
||||
var pvpLevelID = TableManager.Instance.Tables.GlobalConfig.PVPLevelID;
|
||||
var pvpLevelInfo = LevelManager.Instance.GetLevelInfoByID(pvpLevelID);
|
||||
LevelManager.Instance.TryGetLevelInfoByID(pvpLevelID, out LevelInfo pvpLevelInfo);
|
||||
var mapData = pvpLevelInfo.MapData;
|
||||
var levelData = pvpLevelInfo.LevelData;
|
||||
var region = mapData.GetRegion(levelData.pvpDefendRegionId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue