BT4_090.cs 6.2 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 BT4_090 : 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.OnDetermineDoSecurityCheck)
  14. {
  15. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Unsuspend this Digimon and it can Attack", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[When Digivolving] Unsuspend this Digimon. Then, it can attack your opponent's Digimon. This effect allows you to attack unsuspended Digimon as well.";
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. return true;
  36. }
  37. return false;
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  40. {
  41. if (isExistOnField(card))
  42. {
  43. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  44. {
  45. Permanent selectedPermanent = card.PermanentOfThisCard();
  46. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  47. if (card.PermanentOfThisCard().CanAttack(activateClass))
  48. {
  49. //Permanent selectedPermanent = card.PermanentOfThisCard();
  50. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  51. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack to unsuspended Digimon", CanUseCondition1, card);
  52. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(attackerCondition: AttackerCondition, defenderCondition: DefenderCondition, CardEffectCondition);
  53. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  54. selectedPermanent.UntilEndAttackEffects.Add(GetCardEffect);
  55. bool CanUseCondition1(Hashtable hashtable)
  56. {
  57. if (selectedPermanent.TopCard != null)
  58. {
  59. return true;
  60. }
  61. return false;
  62. }
  63. bool AttackerCondition(Permanent permanent)
  64. {
  65. return permanent == card.PermanentOfThisCard();
  66. }
  67. bool DefenderCondition(Permanent permanent)
  68. {
  69. if (permanent != null)
  70. {
  71. if (permanent.TopCard != null)
  72. {
  73. if (permanent.TopCard.Owner == card.Owner.Enemy)
  74. {
  75. if (permanent.IsDigimon)
  76. {
  77. if (!permanent.IsSuspended)
  78. {
  79. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. return false;
  89. }
  90. bool CardEffectCondition(ICardEffect cardEffect)
  91. {
  92. if (cardEffect == activateClass)
  93. {
  94. return true;
  95. }
  96. return false;
  97. }
  98. ICardEffect GetCardEffect(EffectTiming _timing)
  99. {
  100. return canAttackTargetDefendingPermanentClass;
  101. }
  102. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  103. selectAttackEffect.SetUp(
  104. attacker: selectedPermanent,
  105. canAttackPlayerCondition: () => false,
  106. defenderCondition: (permanent) => true,
  107. cardEffect: activateClass);
  108. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  109. if (selectedPermanent.TopCard != null)
  110. {
  111. selectedPermanent.UntilEndAttackEffects.Remove(GetCardEffect);
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. return cardEffects;
  119. }
  120. }