BT5_019.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_019 : 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.OnEnterFieldAnyone)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlitzSelfEffect(isInheritedEffect: false, card: card, condition: null, isWhenDigivolving: true));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Place a Card to digivolution cards and Delete Digimon", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[When Digivolving] You may place 1 red Digimon card from your hand at the top of this Digimon's digivolution cards. Then, for each [OmniShoutmon] or [ZeigGreymon] in this Digimon's digivolution cards, delete 1 of your opponent's Digimon with 5000 DP or less.";
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. if (cardSource.HasCardColor(CardColor.Red))
  30. {
  31. if (cardSource.IsDigimon)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  41. {
  42. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  43. {
  44. if (permanent.CanSelectBySkill(activateClass))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. return true;
  61. }
  62. return false;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  69. {
  70. List<CardSource> selectedCards = new List<CardSource>();
  71. int maxCount = 1;
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectCardCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: maxCount,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.", "The opponent is selecting 1 card to place on top of digivolution cards.");
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCards.Add(cardSource);
  91. yield return null;
  92. }
  93. if (selectedCards.Count >= 1)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(selectedCards, activateClass));
  96. }
  97. }
  98. }
  99. int digivolutionCardsCount = card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("OmniShoutmon") || cardSource.CardNames.Contains("ZeigGreymon"));
  100. if (digivolutionCardsCount >= 1)
  101. {
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. int maxCount = Math.Min(digivolutionCardsCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  105. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  106. selectPermanentEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectPermanentCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: false,
  113. canEndNotMax: false,
  114. selectPermanentCoroutine: null,
  115. afterSelectPermanentCoroutine: null,
  116. mode: SelectPermanentEffect.Mode.Destroy,
  117. cardEffect: activateClass);
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. }
  120. }
  121. }
  122. }
  123. return cardEffects;
  124. }
  125. }