Fragment.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. public partial class CardEffectCommons
  4. {
  5. #region Can activate [Fragment]
  6. public static bool CanActivateFragment(Permanent permanent, int trashValue, ICardEffect activateClass)
  7. {
  8. if (IsPermanentExistsOnBattleArea(permanent))
  9. {
  10. if (permanent.CanBeDestroyedBySkill(activateClass))
  11. {
  12. return (permanent.DigivolutionCards.Count >= trashValue);
  13. }
  14. }
  15. return false;
  16. }
  17. #endregion
  18. #region Effect process of [Fragment]
  19. public static IEnumerator FragmentProcess(ICardEffect activateClass, Permanent permanent, int trashValue)
  20. {
  21. if (permanent == null) yield break;
  22. if (permanent.TopCard == null) yield break;
  23. if (permanent.DigivolutionCards.Count < trashValue) yield break;
  24. bool cardsTrashed = false;
  25. List<CardSource> selectedCards = new List<CardSource>();
  26. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  27. selectCardEffect.SetUp(
  28. canTargetCondition: (CardSource) => true,
  29. canTargetCondition_ByPreSelecetedList: null,
  30. canEndSelectCondition: null,
  31. canNoSelect: () => false,
  32. selectCardCoroutine: SelectCardCoroutine,
  33. afterSelectCardCoroutine: null,
  34. message: "Select digivolution cards to trash.",
  35. maxCount: 3,
  36. canEndNotMax: false,
  37. isShowOpponent: true,
  38. mode: SelectCardEffect.Mode.Custom,
  39. root: SelectCardEffect.Root.Custom,
  40. customRootCardList: permanent.DigivolutionCards,
  41. canLookReverseCard: true,
  42. selectPlayer: activateClass.EffectSourceCard.Owner,
  43. cardEffect: activateClass);
  44. selectCardEffect.SetUpCustomMessage("Select digivolution cards to trash.", "The opponent is selecting digivolution cards to trash.");
  45. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  46. IEnumerator SelectCardCoroutine(CardSource cardSource)
  47. {
  48. selectedCards.Add(cardSource);
  49. yield return null;
  50. }
  51. if (selectedCards.Count == trashValue)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
  54. permanent,
  55. selectedCards,
  56. activateClass).TrashDigivolutionCards());
  57. cardsTrashed = true;
  58. }
  59. if (cardsTrashed)
  60. {
  61. permanent.willBeRemoveField = false;
  62. permanent.HideDeleteEffect();
  63. }
  64. }
  65. #endregion
  66. }