Fragment.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Can activate [Fragment]
  9. public static bool CanActivateFragment(Permanent permanent, int trashValue, ICardEffect activateClass)
  10. {
  11. if (IsPermanentExistsOnBattleArea(permanent))
  12. {
  13. if (permanent.CanBeDestroyedBySkill(activateClass))
  14. {
  15. return (permanent.DigivolutionCards.Count < trashValue);
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Fragment]
  22. public static IEnumerator FragmentProcess(ICardEffect activateClass, Permanent permanent, int trashValue)
  23. {
  24. if (permanent == null) yield break;
  25. if (permanent.TopCard == null) yield break;
  26. if (permanent.DigivolutionCards.Count < trashValue) yield break;
  27. bool cardsTrashed = false;
  28. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  29. permanentCondition: (target => target == permanent),
  30. cardCondition: (CardSource) => true,
  31. maxCount: 3,
  32. canNoTrash: true,
  33. isFromOnly1Permanent: false,
  34. activateClass: activateClass,
  35. afterSelectionCoroutine: AfterTrashedCards
  36. ));
  37. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  38. {
  39. if (cards.Count == trashValue)
  40. cardsTrashed = true;
  41. yield return null;
  42. }
  43. if (cardsTrashed)
  44. {
  45. permanent.willBeRemoveField = false;
  46. permanent.HideDeleteEffect();
  47. }
  48. }
  49. #endregion
  50. }