RB1_002.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 RB1_002 : 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.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1 Digivolution Cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  18. activateClass.SetIsInheritedEffect(true);
  19. activateClass.SetHashString("TrashDigivolutionCards_RB1_002");
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Attacking][Once Per Turn] By trashing 1 blue card in your hand, trash the bottom digivolution card of 1 of your opponent's Digimon.";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. return cardSource.HasCardColor(CardColor.Blue);
  28. }
  29. bool CanSelectPermanentCondition(Permanent permanent)
  30. {
  31. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  32. {
  33. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  58. {
  59. bool discarded = false;
  60. int discardCount = 1;
  61. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  62. selectHandEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectCardCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: discardCount,
  68. canNoSelect: true,
  69. canEndNotMax: false,
  70. isShowOpponent: true,
  71. selectCardCoroutine: null,
  72. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  73. mode: SelectHandEffect.Mode.Discard,
  74. cardEffect: activateClass);
  75. yield return StartCoroutine(selectHandEffect.Activate());
  76. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  77. {
  78. if (cardSources.Count >= 1)
  79. {
  80. discarded = true;
  81. yield return null;
  82. }
  83. }
  84. if (discarded)
  85. {
  86. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  87. {
  88. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectPermanentCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: maxCount,
  96. canNoSelect: false,
  97. canEndNotMax: false,
  98. selectPermanentCoroutine: SelectPermanentCoroutine,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.Custom,
  101. cardEffect: activateClass);
  102. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. Permanent selectedPermanent = permanent;
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 1, isFromTop: false, activateClass: activateClass));
  108. }
  109. }
  110. }
  111. }
  112. }
  113. }
  114. return cardEffects;
  115. }
  116. }