InvertSAttackClass.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using Unity.Mathematics;
  6. public class InvertSAttackClass : ICardEffect, IInvertSAttackEffect
  7. {
  8. public void SetUpChangeSAttackClass(Func<Permanent, int, int> changeInvertFunc, Func<Permanent, bool> permanentCondition)
  9. {
  10. _changeInvertFunc = changeInvertFunc;
  11. _permanentCondition = permanentCondition;
  12. }
  13. Func<Permanent, int, int> _changeInvertFunc = null;
  14. Func<Permanent, bool> _permanentCondition = null;
  15. public int InversionValue(Permanent permanent, int invertValue)
  16. {
  17. if (PermanentCondition(permanent))
  18. {
  19. invertValue = _changeInvertFunc(permanent, invertValue);
  20. }
  21. return invertValue;
  22. }
  23. public bool PermanentCondition(Permanent permanent)
  24. {
  25. if (permanent != null)
  26. {
  27. if (permanent.TopCard != null)
  28. {
  29. if (_permanentCondition != null)
  30. {
  31. if (_permanentCondition(permanent))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. }