TableUtils.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using UnityEngine;
  2. namespace XGame.Database
  3. {
  4. public static class TableUtils
  5. {
  6. /// <summary>
  7. /// 属性缩放倍数
  8. /// </summary>
  9. public static readonly int Multiple = 10000;
  10. /// <summary>
  11. /// 数据库万分比字段转真实值
  12. /// </summary>
  13. /// <param name="val"></param>
  14. /// <returns></returns>
  15. public static float ToRealFloat(this int val)
  16. {
  17. return val * 0.0001f;
  18. }
  19. /// <summary>
  20. /// 数据库万分比字段转真实值
  21. /// </summary>
  22. /// <param name="val"></param>
  23. /// <returns></returns>
  24. public static int ToReal(this int val)
  25. {
  26. return Mathf.CeilToInt(val * 0.0001f);
  27. }
  28. /// <summary>
  29. /// 数据库万分比字段转真实值
  30. /// </summary>
  31. /// <param name="val"></param>
  32. /// <returns></returns>
  33. public static double ToRealDouble(this long val)
  34. {
  35. return val * 0.0001f;
  36. }
  37. /// <summary>
  38. /// 数据库万分比字段转真实值
  39. /// </summary>
  40. /// <param name="val"></param>
  41. /// <returns></returns>
  42. public static long ToReal(this long val)
  43. { //四舍五入
  44. return (val + 5000) / Multiple;
  45. }
  46. /// <summary>
  47. /// 检测技能或Buff的目标类型
  48. /// </summary>
  49. /// <param name="val"></param>
  50. /// <param name="targetType"></param>
  51. /// <returns></returns>
  52. public static bool IsContain(uint skillTargetType, ESkillTargetType targetType)
  53. {
  54. return (skillTargetType & (uint)targetType) != 0;
  55. }
  56. /// <summary>
  57. /// 是否基础属性
  58. /// </summary>
  59. /// <param name="type"></param>
  60. /// <returns></returns>
  61. public static bool IsBasic(this EAttributeType type)
  62. {
  63. return type is EAttributeType.Hp or EAttributeType.Atk or EAttributeType.Def or EAttributeType.AtkSpeed;
  64. }
  65. /// <summary>
  66. /// 是否装备特殊属性
  67. /// </summary>
  68. /// <param name="type"></param>
  69. /// <returns></returns>
  70. public static bool IsItemSpecial(this EAttributeType type)
  71. {
  72. return type is EAttributeType.Crit or EAttributeType.DoubleHit or EAttributeType.Counter or EAttributeType.Verti or
  73. EAttributeType.Eva or EAttributeType.CritRes or EAttributeType.VertigoRes or EAttributeType.EvaRes or
  74. EAttributeType.DoubleHitRes or EAttributeType.CounterRes;
  75. }
  76. }
  77. }