Partition.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. public partial class CardEffectCommons
  5. {
  6. #region Can trigger [Partition]
  7. public static bool CanTriggerPartition(Hashtable hashtable, CardSource card)
  8. {
  9. if (CanTriggerWhenPermanentRemoveField(hashtable, (permanent) => permanent.cardSources.Contains(card)))
  10. {
  11. if (!IsByBattle(hashtable))
  12. {
  13. if (!IsByEffect(hashtable, cardEffect => IsOwnerEffect(cardEffect, card)))
  14. {
  15. return true;
  16. }
  17. }
  18. }
  19. return false;
  20. }
  21. #endregion
  22. #region Can activate [Partition]
  23. public static bool CanActivatePartition(Permanent permanent)
  24. {
  25. if (IsPermanentExistsOnBattleArea(permanent))
  26. {
  27. if (permanent.DigivolutionCards.Count >= 1)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. #endregion
  35. #region Effect process of [Partition]
  36. public static IEnumerator PartitionProcess(ICardEffect activateClass, Permanent permanent, Func<CardSource, bool> CanSelectFirstSourceCondition, Func<CardSource, bool> CanSelectSecondSourceCondition)
  37. {
  38. yield return ContinuousController.instance.StartCoroutine(new PartitionClass(permanent).Partition(activateClass, CanSelectFirstSourceCondition, CanSelectSecondSourceCondition));
  39. }
  40. #endregion
  41. #region Partition class
  42. public class PartitionClass
  43. {
  44. public PartitionClass(Permanent permanent)
  45. {
  46. _permanent = permanent;
  47. }
  48. Permanent _permanent = null;
  49. public IEnumerator Partition(ICardEffect activateClass, Func<CardSource, bool> CanSelectFristSourceCondition, Func<CardSource, bool> CanSelectSecondSourceCondition)
  50. {
  51. if (_permanent != null)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(_permanent));
  54. CardSource topCard = _permanent.TopCard;
  55. List<CardSource> selectedCards = new List<CardSource>();
  56. if (_permanent.TopCard != null)
  57. {
  58. //int maxCount = Math.Min(1, MatchConditionPermanentCount(CanSelectCardCondition));
  59. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  60. selectCardEffect.SetUp(
  61. canTargetCondition: CanSelectFristSourceCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. canNoSelect: () => false,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. message: "Select card to play",
  68. maxCount: 1,
  69. canEndNotMax: false,
  70. isShowOpponent: false,
  71. mode: SelectCardEffect.Mode.Custom,
  72. root: SelectCardEffect.Root.DigivolutionCards,
  73. customRootCardList: _permanent.cardSources,
  74. canLookReverseCard: true,
  75. selectPlayer: topCard.Owner,
  76. cardEffect: activateClass);
  77. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  78. selectCardEffect.SetUp(
  79. canTargetCondition: CanSelectSecondSourceCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. canNoSelect: () => false,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. message: "Select card to play",
  86. maxCount: 1,
  87. canEndNotMax: false,
  88. isShowOpponent: false,
  89. mode: SelectCardEffect.Mode.Custom,
  90. root: SelectCardEffect.Root.DigivolutionCards,
  91. customRootCardList: _permanent.cardSources,
  92. canLookReverseCard: true,
  93. selectPlayer: topCard.Owner,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  96. IEnumerator SelectCardCoroutine(CardSource cardSource)
  97. {
  98. selectedCards.Add(cardSource);
  99. yield return null;
  100. }
  101. }
  102. foreach(CardSource card in selectedCards)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(PlayPermanentCards(
  105. cardSources: new List<CardSource>() { card },
  106. activateClass: activateClass,
  107. payCost: false,
  108. isTapped: false,
  109. root: SelectCardEffect.Root.Trash,
  110. activateETB: true));
  111. }
  112. #region Play Log
  113. string log = "";
  114. log += $"\nPartition :";
  115. log += $"\n{topCard.BaseENGCardNameFromEntity}({topCard.CardID})";
  116. log += "\n";
  117. GManager.instance.playLog.AddLogString(log);
  118. #endregion
  119. }
  120. }
  121. }
  122. #endregion
  123. }