CanNotUnsuspend.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 Target 1 Digimon can't unsuspend at the next active phase
  9. public static IEnumerator GainCantUnsuspendNextActivePhase(Permanent targetPermanent, ICardEffect activateClass)
  10. {
  11. if (targetPermanent == null) yield break;
  12. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  13. if (activateClass == null) yield break;
  14. if (activateClass.EffectSourceCard == null) yield break;
  15. CardSource card = activateClass.EffectSourceCard;
  16. bool CanUseCondition()
  17. {
  18. if (IsOpponentTurn(card))
  19. {
  20. if (GManager.instance.turnStateMachine.gameContext.TurnPhase == GameContext.phase.Active)
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. string effectName = "Can't unsuspend during next unsuspend phase";
  28. yield return ContinuousController.instance.StartCoroutine(GainCanNotUnsuspend(
  29. targetPermanent: targetPermanent,
  30. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  31. activateClass: activateClass,
  32. condition: CanUseCondition,
  33. effectName: effectName
  34. ));
  35. }
  36. #endregion
  37. #region Target 1 Digimon can't unsuspend until opponent's turn end
  38. public static IEnumerator GainCantUnsuspendUntilOpponentTurnEnd(Permanent targetPermanent, ICardEffect activateClass)
  39. {
  40. if (targetPermanent == null) yield break;
  41. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  42. if (activateClass == null) yield break;
  43. if (activateClass.EffectSourceCard == null) yield break;
  44. CardSource card = activateClass.EffectSourceCard;
  45. static bool CanUseCondition() => true;
  46. string effectName = "Can't unsuspend until the end of this card's owner's turn";
  47. yield return ContinuousController.instance.StartCoroutine(GainCanNotUnsuspend(
  48. targetPermanent: targetPermanent,
  49. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  50. activateClass: activateClass,
  51. condition: CanUseCondition,
  52. effectName: effectName
  53. ));
  54. }
  55. #endregion
  56. #region Target 1 Digimon can't unsuspend
  57. public static IEnumerator GainCanNotUnsuspend(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass, Func<bool> condition, string effectName)
  58. {
  59. if (targetPermanent == null) yield break;
  60. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  61. if (activateClass == null) yield break;
  62. if (activateClass.EffectSourceCard == null) yield break;
  63. CardSource card = activateClass.EffectSourceCard;
  64. bool PermanentCondition(Permanent permanent) => permanent == targetPermanent;
  65. bool CanUseCondition()
  66. {
  67. if (IsPermanentExistsOnBattleArea(targetPermanent))
  68. {
  69. if (condition == null || condition())
  70. {
  71. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. CanNotUnsuspendClass canNotUnsuspendClass = CardEffectFactory.CantUnsuspendStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition, effectName: effectName);
  80. AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: canNotUnsuspendClass, timing: EffectTiming.None);
  81. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  82. {
  83. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  84. }
  85. }
  86. #endregion
  87. }