Vortex.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System.Collections;
  2. public partial class CardEffectCommons
  3. {
  4. #region Can activate [Vortex]
  5. public static bool CanActivateVortex(CardSource cardSource, ICardEffect activateClass)
  6. {
  7. return IsExistOnBattleArea(cardSource) &&
  8. cardSource.PermanentOfThisCard().CanAttack(activateClass, isVortex: true) &&
  9. HasMatchConditionOpponentsPermanent(cardSource, permanent =>
  10. permanent.IsDigimon &&
  11. cardSource.PermanentOfThisCard().CanAttackTargetDigimon(permanent, activateClass, isVortex: true));
  12. }
  13. #endregion
  14. #region Effect process of [Vortex]
  15. public static IEnumerator VortexProcess(CardSource cardSource, ICardEffect activateClass)
  16. {
  17. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  18. if (selectedPermanent.CanAttack(activateClass, isVortex: true))
  19. {
  20. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  21. selectAttackEffect.SetUp(
  22. attacker: selectedPermanent,
  23. canAttackPlayerCondition: () => false,
  24. defenderCondition: _ => true,
  25. cardEffect: activateClass);
  26. selectAttackEffect.SetIsVortex();
  27. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  28. }
  29. }
  30. #endregion
  31. #region Target 1 Digimon gains [Vortex]
  32. public static IEnumerator GainVortex(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  33. {
  34. if (targetPermanent == null) yield break;
  35. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  36. if (activateClass == null) yield break;
  37. if (activateClass.EffectSourceCard == null) yield break;
  38. CardSource card = activateClass.EffectSourceCard;
  39. bool CanUseCondition()
  40. {
  41. return IsPermanentExistsOnBattleArea(targetPermanent) &&
  42. !targetPermanent.TopCard.CanNotBeAffected(activateClass);
  43. }
  44. ActivateClass vortex = CardEffectFactory.VortexEffect(
  45. targetPermanent: targetPermanent,
  46. isInheritedEffect: false,
  47. condition: CanUseCondition,
  48. rootCardEffect: activateClass,
  49. targetPermanent.TopCard);
  50. AddEffectToPermanent(
  51. targetPermanent: targetPermanent,
  52. effectDuration: effectDuration,
  53. card: card,
  54. cardEffect: vortex,
  55. timing: EffectTiming.OnEndTurn);
  56. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  59. .CreateBuffEffect(targetPermanent));
  60. }
  61. }
  62. #endregion
  63. }