ChangeSAttackClass.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class ChangeSAttackClass : ICardEffect, IChangeSAttackEffect
  6. {
  7. public void SetUpChangeSAttackClass(Func<Permanent, int, int> changeSAttackFunc, Func<Permanent, bool> permanentCondition, Func<CalculateOrder> isUpDown)
  8. {
  9. _changeSAttackFunc = changeSAttackFunc;
  10. _permanentCondition = permanentCondition;
  11. _isUpDown = isUpDown;
  12. }
  13. Func<Permanent, int, int> _changeSAttackFunc = null;
  14. Func<Permanent, bool> _permanentCondition = null;
  15. Func<CalculateOrder> _isUpDown = null;
  16. public int GetSAttack(int SAttack, Permanent permanent)
  17. {
  18. if (PermanentCondition(permanent))
  19. {
  20. SAttack = _changeSAttackFunc(permanent, SAttack);
  21. }
  22. return SAttack;
  23. }
  24. public CalculateOrder isUpDown()
  25. {
  26. if (_isUpDown != null)
  27. {
  28. return _isUpDown();
  29. }
  30. return CalculateOrder.UpToConstant;
  31. }
  32. public bool PermanentCondition(Permanent permanent)
  33. {
  34. if (permanent != null)
  35. {
  36. if (permanent.TopCard != null)
  37. {
  38. if (_permanentCondition != null)
  39. {
  40. if (_permanentCondition(permanent))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. }