BT1_112.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 BT1_112 : 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.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] 1 of your Digimon gains the following effect for the turn: When this Digimon deletes an opponent's Digimon in battle and survives, unsuspend it.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  32. {
  33. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  34. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  35. selectPermanentEffect.SetUp(
  36. selectPlayer: card.Owner,
  37. canTargetCondition: CanSelectPermanentCondition,
  38. canTargetCondition_ByPreSelecetedList: null,
  39. canEndSelectCondition: null,
  40. maxCount: maxCount,
  41. canNoSelect: false,
  42. canEndNotMax: false,
  43. selectPermanentCoroutine: SelectPermanentCoroutine,
  44. afterSelectPermanentCoroutine: null,
  45. mode: SelectPermanentEffect.Mode.Custom,
  46. cardEffect: activateClass);
  47. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  48. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  49. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  50. {
  51. Permanent selectedPermanent = permanent;
  52. if (selectedPermanent != null)
  53. {
  54. ActivateClass activateClass1 = new ActivateClass();
  55. activateClass1.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  56. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  57. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  58. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndBattle);
  59. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  60. string EffectDiscription1()
  61. {
  62. return "When this Digimon deletes an opponent's Digimon in battle and survives, unsuspend it.";
  63. }
  64. bool CanUseCondition1(Hashtable hashtable1)
  65. {
  66. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  67. {
  68. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(selectedPermanent.TopCard);
  69. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  70. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable1, winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: true))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanActivateCondition1(Hashtable hashtable)
  78. {
  79. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  80. {
  81. if (CardEffectCommons.CanUnsuspend(selectedPermanent))
  82. {
  83. return true;
  84. }
  85. }
  86. return false;
  87. }
  88. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass1).Unsuspend());
  91. }
  92. }
  93. }
  94. }
  95. }
  96. if (timing == EffectTiming.SecuritySkill)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  101. activateClass.SetIsSecurityEffect(true);
  102. cardEffects.Add(activateClass);
  103. string EffectDiscription()
  104. {
  105. return "[Security] Add this card to its owner's hand.";
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  114. }
  115. }
  116. return cardEffects;
  117. }
  118. }