Partition.cs 5.8 KB

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