Fragment.cs 3.1 KB

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