ChangeBaseDPClass.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class ChangeBaseDPClass : ICardEffect, IChangeBaseDPEffect
  6. {
  7. Func<Permanent, int, int> _changeDPFunc { get; set; }
  8. Func<Permanent, bool> _permanentCondition { get; set; }
  9. Func<bool> _isUpDown { get; set; }
  10. Func<bool> _isMinusDP { get; set; }
  11. public void SetUpChangeBaseDPClass(Func<Permanent, int, int> changeDPFunc, Func<Permanent, bool> permanentCondition, Func<bool> isUpDownFunc, Func<bool> isMinusDPFunc)
  12. {
  13. this._changeDPFunc = changeDPFunc;
  14. this._permanentCondition = permanentCondition;
  15. this._isUpDown = isUpDownFunc;
  16. this._isMinusDP = isMinusDPFunc;
  17. }
  18. public int GetDP(int DP, Permanent permanent)
  19. {
  20. if (_changeDPFunc != null)
  21. {
  22. if (permanent != null)
  23. {
  24. if (permanent.TopCard != null)
  25. {
  26. if (PermanentCondition(permanent))
  27. {
  28. DP = _changeDPFunc(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. }