CanNotSuspend.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 have Digimon can't suspend
  9. public static IEnumerator GainCanNotSuspendPlayerEffect(Func<Permanent, bool> permanentCondition, EffectDuration effectDuration, ICardEffect activateClass, bool isOnlyActivePhase, string effectName)
  10. {
  11. if (activateClass == null) yield break;
  12. if (activateClass.EffectSourceCard == null) yield break;
  13. CardSource card = activateClass.EffectSourceCard;
  14. bool _PermanentCondition(Permanent permanent)
  15. {
  16. if (IsPermanentExistsOnBattleArea(permanent))
  17. {
  18. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  19. {
  20. if (permanentCondition == null || permanentCondition(permanent))
  21. {
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. }
  28. bool PermanentCondition(Permanent permanent)
  29. {
  30. if (_PermanentCondition(permanent))
  31. {
  32. if (!isOnlyActivePhase || GManager.instance.turnStateMachine.gameContext.TurnPlayer == permanent.TopCard.Owner)
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition()
  40. {
  41. return !isOnlyActivePhase || GManager.instance.turnStateMachine.gameContext.TurnPhase == GameContext.phase.Active;
  42. }
  43. CanNotUnsuspendClass canNotSuspendClass = CardEffectFactory.CantSuspendStaticEffect(
  44. permanentCondition: PermanentCondition,
  45. isInheritedEffect: false,
  46. card: card,
  47. condition: CanUseCondition,
  48. effectName: effectName);
  49. AddEffectToPlayer(effectDuration: effectDuration, card: card, cardEffect: canNotSuspendClass, timing: EffectTiming.None);
  50. foreach (Permanent permanent in GManager.instance.turnStateMachine.gameContext.PermanentsForTurnPlayer)
  51. {
  52. if (_PermanentCondition(permanent))
  53. {
  54. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  55. }
  56. }
  57. }
  58. #endregion
  59. }