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