12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- namespace XGame.Database
- {
- public partial class ChapterTableRepo
- {
- public static ChapterTable Next(int chapterId)
- {
- var tables = GetAll();
- var index = Array.FindIndex(tables, (a) => a.Id == chapterId);
- if (index < 0)
- {
- Log.Error($"没有找到ChapterTable. chapterId: {chapterId}");
- return default;
- }
- if (index == tables.Length - 1)
- {
- Log.Debug($"ChapterTable已经是最后一个. chapterId: {chapterId}");
- return default;
- }
- return tables[index + 1];
- }
- /// <summary>
- /// 查找最近的boss节点
- /// </summary>
- /// <param name="chapterId"></param>
- /// <returns></returns>
- public static ChapterTable FindNearestBoss(int chapterId)
- {
- var tables = GetAll();
- var index = Array.FindIndex(tables, (a) => a.Id == chapterId);
- if (index < 0)
- {
- Log.Error($"没有找到ChapterTable. chapterId: {chapterId}");
- return default;
- }
- if (index == tables.Length - 1)
- {
- Log.Debug($"ChapterTable已经是最后一个. chapterId: {chapterId}");
- return default;
- }
- for(var i = index; i < tables.Length; i++)
- {
- if (tables[i].Part_type == 1)
- {
- return tables[i];
- }
- }
- return default;
- }
- }
- }
|