Buff.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using FSRole;
  5. using FSEvent;
  6. using FSAssist;
  7. namespace FSBuff {
  8. public class Buff {
  9. public int Value { set; get; }
  10. public string ID;
  11. // 回合
  12. public int Round;
  13. // 叠加
  14. public int Overlay;
  15. public Role Target;
  16. // Use this for initialization
  17. void Start() {
  18. Overlay = 0;
  19. }
  20. // Update is called once per frame
  21. void Update() {
  22. }
  23. /*
  24. * Buff执行,当行动回合等于0时,Buff取消
  25. */
  26. public void Execute() {
  27. Debug.Log("Buff " + ID + " 执行, " + "剩余回合数 : " + Round + ", 叠加层数 : " + Overlay);
  28. if (Round == 0) {
  29. // 回合结束时,取消Buff
  30. Cancle();
  31. } else {
  32. // 各个BUFF的运行内容不同
  33. if (ID == AssistConfig.Bleed) {
  34. Debug.Log("流血 ... ");
  35. // 根据叠加层数来进行不同操作
  36. if (Overlay < 3) {
  37. // 当层数小于3时
  38. int damage = (int)Mathf.Max(Target.OriginAttr.MaxHp * 0.05f, 5);
  39. Target.GetDamage(damage * -1);
  40. } else if (Overlay >= 3 && Overlay < 6) {
  41. // 当层数小于6时
  42. int damage = (int)Mathf.Max(Target.OriginAttr.MaxHp * 0.1f, 20);
  43. Target.GetDamage(damage * -1);
  44. } else if (Overlay >= 6 && Overlay < 9) {
  45. // 当层数小于9时
  46. int damage = (int)Mathf.Max(Target.OriginAttr.MaxHp * 0.15f, 45);
  47. Target.GetDamage(damage * -1);
  48. } else {
  49. // 层数大于9时
  50. int damage = (int)Mathf.Max(Target.OriginAttr.MaxHp * 0.2f, 80);
  51. Target.GetDamage(damage * -1);
  52. if (Overlay > 9) {
  53. // 当层数小于3时
  54. int extraDamage = (int)Mathf.Max(Target.OriginAttr.MaxHp * 0.1f, 50);
  55. Target.GetDamage(extraDamage * -1);
  56. }
  57. }
  58. } else if (ID == AssistConfig.Fracture) {
  59. Debug.Log("骨折 ... ");
  60. } else if (ID == AssistConfig.Paralysis) {
  61. Debug.Log("麻痹 ... ");
  62. }
  63. // 当叠加层数超过9层时,将会是无限回合
  64. if (Overlay > 9) {
  65. Round = int.MaxValue;
  66. }
  67. Round--;
  68. }
  69. }
  70. /*
  71. * Buff取消,从目标中移除
  72. */
  73. public void Cancle() {
  74. if (Target != null) {
  75. Target.EraseBuff(this);
  76. }
  77. }
  78. }
  79. }