BT15_004.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT15
  4. {
  5. public class BT15_004 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OnEndTurn)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("This Digimon can attack to opponent's 1 Digimon", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  15. activateClass.SetIsInheritedEffect(true);
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[End of Your Turn] If this Digimon has the [Insectoid] trait, it may attack an opponent's Digimon.";
  20. }
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. if (CardEffectCommons.IsExistOnBattleArea(card))
  24. {
  25. if (CardEffectCommons.IsOwnerTurn(card))
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleArea(card))
  35. {
  36. if (card.PermanentOfThisCard().CanAttack(activateClass))
  37. {
  38. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && card.PermanentOfThisCard().CanAttackTargetDigimon(permanent, activateClass)))
  39. {
  40. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Insectoid"))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. Permanent selectedPermanent = card.PermanentOfThisCard();
  52. if (selectedPermanent != null)
  53. {
  54. if (selectedPermanent.CanAttack(activateClass))
  55. {
  56. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  57. selectAttackEffect.SetUp(
  58. attacker: selectedPermanent,
  59. canAttackPlayerCondition: () => false,
  60. defenderCondition: (permanent) => true,
  61. cardEffect: activateClass);
  62. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  63. }
  64. }
  65. }
  66. }
  67. return cardEffects;
  68. }
  69. }
  70. }