Vortex.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System;
  3. public partial class CardEffectFactory
  4. {
  5. #region Trigger effect of [Vortex] on oneself
  6. public static ActivateClass VortexSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition,
  7. ICardEffect rootCardEffect = null)
  8. {
  9. Permanent targetPermanent = card.PermanentOfThisCard();
  10. bool CanUseCondition()
  11. {
  12. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  13. (condition == null || condition());
  14. }
  15. return VortexEffect(targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect, condition: CanUseCondition,
  16. rootCardEffect: rootCardEffect, card);
  17. }
  18. #endregion
  19. #region Trigger effect of [Vortex]
  20. public static ActivateClass VortexEffect(Permanent targetPermanent, bool isInheritedEffect, Func<bool> condition,
  21. ICardEffect rootCardEffect, CardSource card)
  22. {
  23. if (targetPermanent == null) return null;
  24. if (targetPermanent.TopCard == null) return null;
  25. if (card == null) return null;
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Vortex", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.VortexEffectDiscription());
  29. activateClass.SetIsInheritedEffect(isInheritedEffect);
  30. if (rootCardEffect != null)
  31. {
  32. activateClass.SetIsInheritedEffect(false);
  33. activateClass.SetEffectSourcePermanent(targetPermanent);
  34. activateClass.SetRootCardEffect(rootCardEffect);
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleArea(card) &&
  39. CardEffectCommons.IsOwnerTurn(card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanActivateVortex(targetPermanent.TopCard, activateClass) &&
  44. (condition == null || condition());
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.VortexProcess(targetPermanent.TopCard, activateClass);
  49. }
  50. return activateClass;
  51. }
  52. #endregion
  53. }