BT2_066.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 BT2_066 : 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.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("De-Digivolve 2 to 2 Digimon", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[On Play] Trigger <De-Digivolve 2> on 2 of your opponent's Digimon. (Trash up to 2 cards from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.)";
  26. }
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent.CanSelectBySkill(activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. if (isExistOnField(card))
  56. {
  57. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. int degenrationMaxCount = 2;
  62. int degenrationCount = 0;
  63. SelectCountEffect selectCountEffect = GManager.instance.GetComponent<SelectCountEffect>();
  64. if (selectCountEffect != null)
  65. {
  66. selectCountEffect.SetUp(
  67. SelectPlayer: card.Owner,
  68. targetPermanent: null,
  69. MaxCount: degenrationMaxCount,
  70. CanNoSelect: false,
  71. Message: "How much will you De-Digivolve?",
  72. Message_Enemy: "The opponent is choosing how much to De-Digivolve.",
  73. SelectCountCoroutine: SelectCountCoroutine);
  74. yield return ContinuousController.instance.StartCoroutine(selectCountEffect.Activate());
  75. IEnumerator SelectCountCoroutine(int count)
  76. {
  77. degenrationCount = count;
  78. yield return null;
  79. }
  80. }
  81. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: CanEndSelectCondition,
  88. maxCount: maxCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select Digimon to De-Digivolve.", "The opponent is selecting Digimon to De-Digivolve.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. bool CanEndSelectCondition(List<Permanent> permanents)
  98. {
  99. if (permanents.Count <= 0)
  100. {
  101. return false;
  102. }
  103. return true;
  104. }
  105. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  106. {
  107. Permanent selectedPermanent = permanent;
  108. if (selectedPermanent != null)
  109. {
  110. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, degenrationCount, activateClass).Degeneration());
  111. }
  112. yield return null;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. return cardEffects;
  120. }
  121. }