BT2_051.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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_051 : 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. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  16. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack to unsuspended Digimon", CanUseCondition, card);
  17. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(
  18. attackerCondition: AttackerCondition,
  19. defenderCondition: DefenderCondition,
  20. cardEffectCondition: CardEffectCondition);
  21. cardEffects.Add(canAttackTargetDefendingPermanentClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleArea(card))
  25. {
  26. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool AttackerCondition(Permanent permanent)
  37. {
  38. return permanent == card.PermanentOfThisCard();
  39. }
  40. bool DefenderCondition(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  43. {
  44. if (!permanent.IsSuspended)
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CardEffectCondition(ICardEffect cardEffect)
  52. {
  53. return true;
  54. }
  55. }
  56. if (timing == EffectTiming.OnEndBattle)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  61. cardEffects.Add(activateClass);
  62. string EffectDiscription()
  63. {
  64. return "[Your Turn] When this Digimon deletes one of your opponent's Digimon in battle and survives, suspend 1 of your opponent's Digimon.";
  65. }
  66. bool CanSelectPermanentCondition(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. if (CardEffectCommons.IsExistOnBattleArea(card))
  73. {
  74. if (CardEffectCommons.IsOwnerTurn(card))
  75. {
  76. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  77. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  78. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: true))
  79. {
  80. return true;
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. if (CardEffectCommons.IsExistOnBattleArea(card))
  89. {
  90. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  98. {
  99. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  100. {
  101. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectPermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: maxCount,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Tap,
  114. cardEffect: activateClass);
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. }
  117. }
  118. }
  119. return cardEffects;
  120. }
  121. }