ChangeDP.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Player gains effect to change Digimon's DP
  9. public static IEnumerator ChangeDigimonDPPlayerEffect(
  10. Func<Permanent, bool> permanentCondition,
  11. int changeValue,
  12. EffectDuration effectDuration,
  13. ICardEffect activateClass)
  14. {
  15. if (activateClass == null) yield break;
  16. if (activateClass.EffectSourceCard == null) yield break;
  17. if (changeValue == 0) yield break;
  18. CardSource card = activateClass.EffectSourceCard;
  19. bool isUpValue = changeValue > 0;
  20. bool PermanentCondition(Permanent permanent)
  21. {
  22. if (IsPermanentExistsOnBattleArea(permanent))
  23. {
  24. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  25. {
  26. if (permanentCondition == null || permanentCondition(permanent))
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition()
  35. {
  36. return true;
  37. }
  38. ChangeDPClass changeDPClass = CardEffectFactory.ChangeDPStaticEffect(
  39. permanentCondition: PermanentCondition,
  40. changeValue: changeValue,
  41. isInheritedEffect: false,
  42. card: card,
  43. condition: CanUseCondition,
  44. effectName: null);
  45. AddEffectToPlayer(effectDuration: effectDuration, card: card, cardEffect: changeDPClass, timing: EffectTiming.None);
  46. foreach (Permanent permanent in GManager.instance.turnStateMachine.gameContext.PermanentsForTurnPlayer)
  47. {
  48. if (PermanentCondition(permanent))
  49. {
  50. if (isUpValue)
  51. {
  52. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(permanent));
  53. }
  54. else
  55. {
  56. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  57. }
  58. }
  59. }
  60. }
  61. #endregion
  62. }