MountData.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using JetBrains.Annotations;
  2. using System;
  3. using System.Collections.Generic;
  4. using XGame.Database;
  5. using XGame.Framework.Data;
  6. namespace FL
  7. {
  8. public class MountData : DataSingleton<MountData>, IDisposable
  9. {
  10. /// <summary>
  11. /// 每个星级(黄|紫|红)最多拥有5个星星数量
  12. /// </summary>
  13. public const int MaxStarNum = 5;
  14. #region 通用坐骑数据
  15. /// <summary>
  16. /// 通用坐骑的星阶对应的zuoqiInfo表的id
  17. /// </summary>
  18. public int UniversalId { get; set; }
  19. /// <summary>
  20. /// 通用坐骑升星进度条
  21. /// </summary>
  22. public int UniversalExp { set; get; }
  23. /// <summary>
  24. /// 坐骑部位驯养经验条
  25. /// </summary>
  26. public int MountPartExp { set; get; }
  27. /// <summary>
  28. /// 通用坐骑部位驯养等级数据
  29. /// </summary>
  30. private Dictionary<int, int> _mountsPartsMap;
  31. public Dictionary<int, int> MountsPartsMap => _mountsPartsMap ??= new Dictionary<int, int>();
  32. /// <summary>
  33. /// 通用坐骑基础信息
  34. /// </summary>
  35. private mountBaseTable _universalMountConfig;
  36. /// <summary>
  37. /// 获取通用坐骑的基础信息
  38. /// </summary>
  39. /// <returns></returns>
  40. public mountBaseTable GetUniversalMountBaseInfo()
  41. {
  42. if (_universalMountConfig == null)
  43. {
  44. var mountBaseConfigList = mountBaseTableRepo.GetAll();
  45. for ( int i = 0; i < mountBaseConfigList.Length; i++)
  46. {
  47. if (mountBaseConfigList[i].Type == 1) //普通坐骑类型
  48. {
  49. _universalMountConfig = mountBaseConfigList[i];
  50. break;
  51. }
  52. }
  53. }
  54. return _universalMountConfig;
  55. }
  56. /// <summary>
  57. /// 获取基础坐骑的升级信息:序号ID(10000 + 阶级 * 100 + 阶段等级)
  58. /// </summary>
  59. /// <param name="step">阶级</param>
  60. /// <param name="level">阶段等级</param>
  61. /// <returns></returns>
  62. public mountLevelTable GetMountLevelTable(int step, int level)
  63. {
  64. return mountLevelTableRepo.Get(10000 + step * 100 + level);
  65. }
  66. #endregion
  67. #region 高级坐骑数据
  68. /// <summary>
  69. /// 启用的高级坐骑的技能的坐骑id
  70. /// </summary>
  71. public int UseSkillMountId { set; get; }
  72. /// <summary>
  73. /// 已解锁的坐骑星级数据
  74. /// key:zuoqiBase.id
  75. /// value:star(星级)
  76. /// </summary>
  77. private Dictionary<int, int> _advancedMountsMap;
  78. public Dictionary<int, int> AdvancedMountsMap => _advancedMountsMap ??= new Dictionary<int, int>();
  79. /// <summary>
  80. /// 获取高级坐骑升星表格信息(id:100*坐骑id+星级)
  81. /// </summary>
  82. /// <param name="mountId">坐骑id</param>
  83. /// <param name="starLevel">星级</param>
  84. /// <returns></returns>
  85. public mountStarTable GetMountStarTable(int mountId, int starLevel)
  86. {
  87. return mountStarTableRepo.Get(mountId * 100 + starLevel);
  88. }
  89. /// <summary>
  90. /// 高级坐骑是否已解锁状态
  91. /// </summary>
  92. /// <param name="advancedMountId"></param>
  93. /// <returns></returns>
  94. public bool IsUnLock(int advancedMountId)
  95. {
  96. return _advancedMountsMap.ContainsKey(advancedMountId);
  97. }
  98. /// <summary>
  99. /// 获取高级坐骑的星级
  100. /// </summary>
  101. /// <param name="mountId"></param>
  102. public int GetAdvancedMountLv(int mountId)
  103. {
  104. return _advancedMountsMap.ContainsKey(mountId) ? _advancedMountsMap[mountId] : 0;
  105. }
  106. #endregion
  107. /// <summary>
  108. /// 当前使用的骑乘坐骑外观模型id(通用坐骑用的是zuoqiInfo表格,高级坐骑对应的是zuoqiBase表格)
  109. /// 此字段只在坐骑内部使用,如果外部需要使用坐骑骑乘外观,GetRidingAppearance()
  110. /// </summary>
  111. public int MountModelId { set; get; }
  112. /// <summary>
  113. /// 获取当前骑乘的坐骑外观
  114. /// </summary>
  115. /// <returns></returns>
  116. public string GetRidingAppearance()
  117. {
  118. if (MountModelId == 0) return string.Empty;
  119. var mountBaseInfo = mountBaseTableRepo.Get(MountModelId);
  120. if (mountBaseInfo != null) return mountBaseInfo.Spine;
  121. var mountInfo = mountLevelTableRepo.Get(MountModelId);
  122. return mountInfo == null ? string.Empty : mountInfo.Spine;
  123. }
  124. void IDisposable.Dispose()
  125. {
  126. _mountsPartsMap?.Clear();
  127. _advancedMountsMap?.Clear();
  128. }
  129. }
  130. }