EX5_031.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 EX5_031 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash a security and unsuspend this Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] By trashing the top card of your security stack, unsuspend this Digimon.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.SecurityCards.Count >= 1)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  41. player: card.Owner,
  42. destroySecurityCount: 1,
  43. cardEffect: activateClass,
  44. fromTop: true).DestroySecurity());
  45. Permanent selectedPermanent = card.PermanentOfThisCard();
  46. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  47. }
  48. }
  49. if (timing == EffectTiming.OnAllyAttack)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect("Place 1 card from hand at the top of security", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  54. activateClass.SetIsInheritedEffect(true);
  55. activateClass.SetHashString("SecurityPlus_EX5_031");
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[When Attacking] [Once Per Turn] If there're 6 or fewer total cards in both players' security stacks, you may place 1 yellow card from your hand on top of your security stack.";
  60. }
  61. bool CanSelectCardCondition(CardSource cardSource)
  62. {
  63. return cardSource.HasCardColor(CardColor.Yellow);
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.IsExistOnBattleArea(card))
  72. {
  73. if (card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count <= 6)
  74. {
  75. if (card.Owner.HandCards.Count >= 1)
  76. {
  77. if (card.Owner.CanAddSecurity(activateClass))
  78. {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  87. {
  88. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  89. {
  90. List<CardSource> selectedCards = new List<CardSource>();
  91. int maxCount = 1;
  92. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  93. selectHandEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: CanSelectCardCondition,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: true,
  100. canEndNotMax: false,
  101. isShowOpponent: true,
  102. selectCardCoroutine: SelectCardCoroutine1,
  103. afterSelectCardCoroutine: null,
  104. mode: SelectHandEffect.Mode.Custom,
  105. cardEffect: activateClass);
  106. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the top of security.", "The opponent is selecting 1 card to place at the top of security.");
  107. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  108. yield return StartCoroutine(selectHandEffect.Activate());
  109. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  110. {
  111. selectedCards.Add(cardSource);
  112. yield return null;
  113. }
  114. foreach (CardSource cardSource in selectedCards)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: true));
  117. }
  118. }
  119. }
  120. }
  121. return cardEffects;
  122. }
  123. }