Vortex.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  27. }
  28. }
  29. #endregion
  30. #region Target 1 Digimon gains [Vortex]
  31. public static IEnumerator GainVortex(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  32. {
  33. if (targetPermanent == null) yield break;
  34. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  35. if (activateClass == null) yield break;
  36. if (activateClass.EffectSourceCard == null) yield break;
  37. CardSource card = activateClass.EffectSourceCard;
  38. bool CanUseCondition()
  39. {
  40. return IsPermanentExistsOnBattleArea(targetPermanent) &&
  41. !targetPermanent.TopCard.CanNotBeAffected(activateClass);
  42. }
  43. ActivateClass vortex = CardEffectFactory.VortexEffect(
  44. targetPermanent: targetPermanent,
  45. isInheritedEffect: false,
  46. condition: CanUseCondition,
  47. rootCardEffect: activateClass,
  48. targetPermanent.TopCard);
  49. AddEffectToPermanent(
  50. targetPermanent: targetPermanent,
  51. effectDuration: effectDuration,
  52. card: card,
  53. cardEffect: vortex,
  54. timing: EffectTiming.OnAllyAttack);
  55. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  58. .CreateBuffEffect(targetPermanent));
  59. }
  60. }
  61. #endregion
  62. }