BT5_108.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT5_108 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Delete 1 of your opponent's unsuspended level 4 Digimon and 1 of your opponent's unsuspended level 5 Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (!permanent.IsSuspended)
  28. {
  29. if (permanent.Level == 4)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectPermanentCondition1(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  40. {
  41. if (!permanent.IsSuspended)
  42. {
  43. if (permanent.Level == 5)
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && CanSelectPermanentCondition(permanent) || CanSelectPermanentCondition1(permanent)))
  58. {
  59. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount((permanent) => CanSelectPermanentCondition(permanent) || CanSelectPermanentCondition1(permanent)));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: (permanent) => CanSelectPermanentCondition(permanent) || CanSelectPermanentCondition1(permanent),
  64. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  65. canEndSelectCondition: CanEndSelectCondition,
  66. maxCount: maxCount,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: null,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Destroy,
  72. cardEffect: activateClass);
  73. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  74. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  75. {
  76. if (permanents.Count(CanSelectPermanentCondition) >= 1)
  77. {
  78. if (CanSelectPermanentCondition(permanent))
  79. {
  80. return false;
  81. }
  82. }
  83. if (permanents.Count(CanSelectPermanentCondition1) >= 1)
  84. {
  85. if (CanSelectPermanentCondition1(permanent))
  86. {
  87. return false;
  88. }
  89. }
  90. return true;
  91. }
  92. bool CanEndSelectCondition(List<Permanent> permanents)
  93. {
  94. if (permanents.Count <= 0)
  95. {
  96. return false;
  97. }
  98. if (permanents.Count(CanSelectPermanentCondition) >= 2)
  99. {
  100. return false;
  101. }
  102. if (permanents.Count(CanSelectPermanentCondition1) >= 2)
  103. {
  104. return false;
  105. }
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. if (permanents.Count(CanSelectPermanentCondition) == 0)
  109. {
  110. return false;
  111. }
  112. }
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  114. {
  115. if (permanents.Count(CanSelectPermanentCondition1) == 0)
  116. {
  117. return false;
  118. }
  119. }
  120. return true;
  121. }
  122. }
  123. }
  124. }
  125. if (timing == EffectTiming.SecuritySkill)
  126. {
  127. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Delete unsuspended level 4 and 5 Digimon");
  128. }
  129. return cardEffects;
  130. }
  131. }