ChangeCardDPClass.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class ChangeCardDPClass : ICardEffect, IChangeCardDPEffect
  6. {
  7. Func<CardSource, int, int> _changeDPFunc { get; set; }
  8. Func<CardSource, bool> _cardSourceCondition { get; set; }
  9. Func<bool> _isUpDown { get; set; }
  10. Func<bool> _isMinusDP { get; set; }
  11. public void SetUpChangeCardDPClass(Func<CardSource, int, int> changeDPFunc, Func<CardSource, bool> cardSourceCondition, Func<bool> isUpDown, Func<bool> isMinusDP)
  12. {
  13. _changeDPFunc = changeDPFunc;
  14. _cardSourceCondition = cardSourceCondition;
  15. _isUpDown = isUpDown;
  16. _isMinusDP = isMinusDP;
  17. }
  18. public int GetDP(int DP, CardSource cardSource)
  19. {
  20. if (_changeDPFunc != null)
  21. {
  22. if (cardSource != null)
  23. {
  24. if (CardCondition(cardSource))
  25. {
  26. DP = _changeDPFunc(cardSource, DP);
  27. }
  28. }
  29. }
  30. return DP;
  31. }
  32. public bool CardCondition(CardSource cardSource)
  33. {
  34. if (_cardSourceCondition != null)
  35. {
  36. return _cardSourceCondition(cardSource);
  37. }
  38. return false;
  39. }
  40. public bool IsUpDown()
  41. {
  42. if (_isUpDown != null)
  43. {
  44. return _isUpDown();
  45. }
  46. return false;
  47. }
  48. public bool IsMinusDP()
  49. {
  50. if (_isMinusDP != null)
  51. {
  52. return _isMinusDP();
  53. }
  54. return false;
  55. }
  56. }