ChangeDPClass.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class ChangeDPClass : ICardEffect, IChangeDPEffect
  6. {
  7. Func<Permanent, int, int> _changeDP { get; set; }
  8. Func<Permanent, bool> _permanentCondition { get; set; }
  9. Func<bool> _isUpDown { get; set; }
  10. Func<bool> _isMinusDP { get; set; }
  11. public void SetUpChangeDPClass(Func<Permanent, int, int> ChangeDP, Func<Permanent, bool> permanentCondition, Func<bool> isUpDown, Func<bool> isMinusDP)
  12. {
  13. _changeDP = ChangeDP;
  14. _permanentCondition = permanentCondition;
  15. _isUpDown = isUpDown;
  16. _isMinusDP = isMinusDP;
  17. }
  18. public int GetDP(int DP, Permanent permanent)
  19. {
  20. if (_changeDP != null)
  21. {
  22. if (permanent != null)
  23. {
  24. if (permanent.TopCard != null)
  25. {
  26. if (PermanentCondition(permanent))
  27. {
  28. DP = _changeDP(permanent, DP);
  29. }
  30. }
  31. }
  32. }
  33. return DP;
  34. }
  35. public bool PermanentCondition(Permanent permanent)
  36. {
  37. if (_permanentCondition != null)
  38. {
  39. return _permanentCondition(permanent);
  40. }
  41. return false;
  42. }
  43. public bool IsUpDown()
  44. {
  45. if (_isUpDown != null)
  46. {
  47. return _isUpDown();
  48. }
  49. return false;
  50. }
  51. public bool IsMinusDP()
  52. {
  53. if (_isMinusDP != null)
  54. {
  55. return _isMinusDP();
  56. }
  57. return false;
  58. }
  59. }