BT6_072.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 BT6_072 : 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 1 card from hand to delete 1 leve4 or lower Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may trash 1 card in your hand to delete 1 of your opponent's level 4 or lower Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.Level <= 4)
  28. {
  29. if (permanent.TopCard.HasLevel)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (card.Owner.HandCards.Count >= 1)
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. if (isExistOnField(card))
  55. {
  56. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  57. {
  58. if (card.Owner.HandCards.Count >= 1)
  59. {
  60. bool discarded = false;
  61. int discardCount = 1;
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: (cardSource) => true,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: discardCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: null,
  73. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  74. mode: SelectHandEffect.Mode.Discard,
  75. cardEffect: activateClass);
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  78. {
  79. if (cardSources.Count >= 1)
  80. {
  81. discarded = true;
  82. yield return null;
  83. }
  84. }
  85. if (discarded)
  86. {
  87. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  88. {
  89. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  90. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CanSelectPermanentCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: CanEndSelectCondition,
  96. maxCount: maxCount,
  97. canNoSelect: false,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: null,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Destroy,
  102. cardEffect: activateClass);
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. bool CanEndSelectCondition(List<Permanent> permanents)
  105. {
  106. if (permanents.Count <= 0)
  107. {
  108. return false;
  109. }
  110. return true;
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. return cardEffects;
  120. }
  121. }