ST18_14.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.ST18
  4. {
  5. public class ST18_14 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Start of Your Turn
  11. if (timing == EffectTiming.OnStartTurn)
  12. {
  13. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  14. }
  15. #endregion
  16. #region Your Turn
  17. if (timing == EffectTiming.OnAllyAttack)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Switch attack target of own Digimon", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  22. cardEffects.Add(activateClass);
  23. string EffectDescription()
  24. {
  25. return
  26. "[Your Turn] When one of your Digimon attacks your opponent's Digimon, by suspending this Tamer, you may change the attack target to another of your opponent's Digimon or the player.";
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleArea(card) &&
  31. CardEffectCommons.IsOwnerTurn(card) &&
  32. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent) &&
  33. CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(
  34. GManager.instance.attackProcess.DefendingPermanent, card);
  35. }
  36. bool AttackingPermanent(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsOwnerPermanent(permanent, card);
  39. }
  40. bool DefendingPermanent(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  43. GManager.instance.attackProcess.DefendingPermanent != permanent;
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleArea(card) &&
  48. CardEffectCommons.CanActivateSuspendCostEffect(card) &&
  49. GManager.instance.attackProcess.AttackingPermanent != null &&
  50. GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. yield return ContinuousController.instance.StartCoroutine(
  55. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  56. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  57. if (CardEffectCommons.HasMatchConditionPermanent(DefendingPermanent))
  58. {
  59. GManager.instance.userSelectionManager.SetBoolSelection(
  60. selectionElements: new List<SelectionElement<bool>>
  61. {
  62. new(message: "Attack Digimon", value: true, spriteIndex: 0),
  63. new(message: "Attack Player", value: false, spriteIndex: 1),
  64. },
  65. selectPlayer: card.Owner,
  66. selectPlayerMessage: "Choose a new target for the attack",
  67. notSelectPlayerMessage: "The opponent is choosing a new target for the attack.");
  68. }
  69. else
  70. {
  71. GManager.instance.userSelectionManager.SetBool(false);
  72. }
  73. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  74. .WaitForEndSelect());
  75. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  76. {
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: DefendingPermanent,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: SelectPermanentCoroutine,
  87. afterSelectPermanentCoroutine: null,
  88. mode: SelectPermanentEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.",
  91. "The opponent is selecting 1 Digimon to attack.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  96. activateClass,
  97. false,
  98. permanent));
  99. }
  100. }
  101. else
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  104. activateClass,
  105. false,
  106. null));
  107. }
  108. }
  109. }
  110. #endregion
  111. #region Security Effect
  112. if (timing == EffectTiming.SecuritySkill)
  113. {
  114. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  115. }
  116. #endregion
  117. return cardEffects;
  118. }
  119. }
  120. }