P_011.cs 6.3 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 P_011 : 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 3 cards from deck top to gain DP +2000", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] If you have a blue Tamer, you may trash the top 3 cards of your deck to give this Digimon +2000 DP for the turn.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.LibraryCards.Count >= 3)
  32. {
  33. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Blue) && permanent.IsTamer))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  42. {
  43. if (isExistOnField(card))
  44. {
  45. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  46. {
  47. if (card.Owner.LibraryCards.Count >= 3)
  48. {
  49. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(3, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  50. if (isExistOnField(card))
  51. {
  52. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. if (timing == EffectTiming.OnAllyAttack)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("Return cards from trash to the bottom of deck to Draw 1", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  64. activateClass.SetIsInheritedEffect(true);
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[When Attacking] You may place 3 non-Digi-Egg cards from your trash at the bottom of your deck in any order to activate <Draw 1>. (Draw 1 card from your deck.)";
  69. }
  70. bool CanSelectCardCondition(CardSource cardSource)
  71. {
  72. return !cardSource.IsDigiEgg;
  73. }
  74. bool CanUseCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  77. }
  78. bool CanActivateCondition(Hashtable hashtable)
  79. {
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  83. {
  84. return true;
  85. }
  86. }
  87. return false;
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  90. {
  91. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  92. {
  93. int maxCount = 3;
  94. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  95. selectCardEffect.SetUp(
  96. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. canNoSelect: () => true,
  100. selectCardCoroutine: null,
  101. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  102. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  103. maxCount: maxCount,
  104. canEndNotMax: false,
  105. isShowOpponent: false,
  106. mode: SelectCardEffect.Mode.Custom,
  107. root: SelectCardEffect.Root.Trash,
  108. customRootCardList: null,
  109. canLookReverseCard: true,
  110. selectPlayer: card.Owner,
  111. cardEffect: activateClass);
  112. selectCardEffect.SetNotShowCard();
  113. selectCardEffect.SetNotAddLog();
  114. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  115. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  116. {
  117. if (cardSources.Count == 3)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  120. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  121. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  122. }
  123. }
  124. }
  125. }
  126. }
  127. return cardEffects;
  128. }
  129. }