ChapterTableRepo.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. namespace XGame.Database
  3. {
  4. public partial class ChapterTableRepo
  5. {
  6. public static ChapterTable Next(int chapterId)
  7. {
  8. var tables = GetAll();
  9. var index = Array.FindIndex(tables, (a) => a.Id == chapterId);
  10. if (index < 0)
  11. {
  12. Log.Error($"没有找到ChapterTable. chapterId: {chapterId}");
  13. return default;
  14. }
  15. if (index == tables.Length - 1)
  16. {
  17. Log.Debug($"ChapterTable已经是最后一个. chapterId: {chapterId}");
  18. return default;
  19. }
  20. return tables[index + 1];
  21. }
  22. /// <summary>
  23. /// 查找最近的boss节点
  24. /// </summary>
  25. /// <param name="chapterId"></param>
  26. /// <returns></returns>
  27. public static ChapterTable FindNearestBoss(int chapterId)
  28. {
  29. var tables = GetAll();
  30. var index = Array.FindIndex(tables, (a) => a.Id == chapterId);
  31. if (index < 0)
  32. {
  33. Log.Error($"没有找到ChapterTable. chapterId: {chapterId}");
  34. return default;
  35. }
  36. if (index == tables.Length - 1)
  37. {
  38. Log.Debug($"ChapterTable已经是最后一个. chapterId: {chapterId}");
  39. return default;
  40. }
  41. for(var i = index; i < tables.Length; i++)
  42. {
  43. if (tables[i].Part_type == 1)
  44. {
  45. return tables[i];
  46. }
  47. }
  48. return default;
  49. }
  50. }
  51. }