EpigraphicsComponent.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using UnityEngine;
  2. using XGame.Database;
  3. using XGame.Framework.Components;
  4. namespace FL.Battle.Components
  5. {
  6. public interface IEpigraphicsContext
  7. {
  8. IEntity Entity { get; }
  9. int EpigraphId { get; }
  10. ITargetSelector Selector { get; }
  11. }
  12. /// <summary>
  13. /// 铭文组件
  14. /// 只有随从可以装配,且只能装配一个
  15. /// </summary>
  16. public class EpigraphicsComponent : Component<IEpigraphicsContext>
  17. {
  18. protected override void OnDispose()
  19. {
  20. }
  21. /// <summary>
  22. /// 是否铭文的目标debuff
  23. /// </summary>
  24. /// <param name="buffId"></param>
  25. /// <returns></returns>
  26. public bool IsTargetBuff(int buffId, out int epigrapId)
  27. {
  28. if (Context.EpigraphId == 20300)
  29. {
  30. var table = EpigraphTableRepo.Get(Context.EpigraphId);
  31. if (buffId == table.EffectArgs[0])
  32. {
  33. epigrapId = Context.EpigraphId;
  34. return true;
  35. }
  36. }
  37. epigrapId = 0;
  38. return false;
  39. }
  40. /// <summary>
  41. /// 尝试触发远古毒素
  42. /// 冰->毒
  43. /// </summary>
  44. /// <param name="targetId"></param>
  45. /// <param name="skillElementType"></param>
  46. /// <param name="damage"></param>
  47. /// <returns></returns>
  48. public bool TryTickIceToPoison(long targetId, EElementType skillElementType, int damage)
  49. {
  50. //EffectArgs: [目标buffId,层数,伤害转吸血万分比,不满足层数时buff触发概率,buffid1,buffid2,buffid3]
  51. if (Context.EpigraphId != 20300 || skillElementType != EElementType.Ice)
  52. return false;
  53. var target = Context.Selector.GetTarget(targetId);
  54. if (target == null) return false;
  55. var table = EpigraphTableRepo.Get(Context.EpigraphId);
  56. var tarBuffId = table.EffectArgs[0];
  57. var tarLayers = target.Buffs.GetLayers(tarBuffId);
  58. if (tarLayers == 0)
  59. return false;
  60. if (tarLayers == table.EffectArgs[1])
  61. { // 触发5层特效
  62. // 吸血比例,吸血给玩家
  63. var suckBloodPer = table.EffectArgs[2];
  64. var player = Context.Selector.GetPlayer();
  65. player.Calculation.Damage(Mathf.Abs(damage * suckBloodPer), EElementType.None);
  66. return true;
  67. }
  68. if (MathUtils.Random(table.EffectArgs[3]) == false)
  69. {
  70. return false;
  71. }
  72. var buffId1 = table.EffectArgs[4];
  73. var buffId2 = table.EffectArgs[5];
  74. var buffId3 = table.EffectArgs[6];
  75. target.Calculation.TickBuff(buffId1);
  76. target.Calculation.TickBuff(buffId2);
  77. target.Calculation.TickBuff(buffId3);
  78. return true;
  79. }
  80. }
  81. }