BT9_077.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 BT9_077 : 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 card from hand to get DP +3000", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] You may trash 1 card with [Undead] or [Dark Animal] in its traits in your hand to have this Digimon get +3000 DP for the turn.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.Owner == card.Owner)
  28. {
  29. if (cardSource.CardTraits.Contains("Undead"))
  30. {
  31. return true;
  32. }
  33. if (cardSource.CardTraits.Contains("Dark Animal"))
  34. {
  35. return true;
  36. }
  37. if (cardSource.CardTraits.Contains("DarkAnimal"))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (card.Owner.HandCards.Count >= 1)
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  61. {
  62. if (isExistOnField(card))
  63. {
  64. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  65. {
  66. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  67. {
  68. bool discarded = false;
  69. int discardCount = 1;
  70. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  71. selectHandEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: discardCount,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. selectCardCoroutine: null,
  81. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  82. mode: SelectHandEffect.Mode.Discard,
  83. cardEffect: activateClass);
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  86. {
  87. if (cardSources.Count >= 1)
  88. {
  89. discarded = true;
  90. yield return null;
  91. }
  92. }
  93. if (discarded)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. if (timing == EffectTiming.None)
  103. {
  104. bool Condition()
  105. {
  106. return CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.IsExistOnBattleArea(card);
  107. }
  108. bool PermanentCondition(Permanent targetPermanent)
  109. {
  110. return targetPermanent == card.PermanentOfThisCard();
  111. }
  112. bool CardSourceCondition(CardSource cardSource)
  113. {
  114. return cardSource.IsDigimon && cardSource.Owner.TrashCards.Contains(cardSource);
  115. }
  116. bool RootCondition(SelectCardEffect.Root root)
  117. {
  118. return root == SelectCardEffect.Root.Trash;
  119. }
  120. cardEffects.Add(CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  121. changeValue: -1,
  122. permanentCondition: PermanentCondition,
  123. cardCondition: CardSourceCondition,
  124. rootCondition: RootCondition,
  125. isInheritedEffect: false,
  126. card: card,
  127. condition: Condition,
  128. setFixedCost: false));
  129. }
  130. return cardEffects;
  131. }
  132. }