BT4_113.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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_113 : 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.None)
  14. {
  15. int count()
  16. {
  17. int count = 0;
  18. if (CardEffectCommons.IsExistOnBattleArea(card))
  19. {
  20. bool CanCountCondition(CardSource cardSource)
  21. {
  22. if (cardSource.IsDigimon)
  23. {
  24. if (cardSource.HasGreymonName || cardSource.CardTraits.Contains("Hybrid"))
  25. {
  26. return true;
  27. }
  28. }
  29. return false;
  30. }
  31. count = card.PermanentOfThisCard().DigivolutionCards.Count(CanCountCondition);
  32. }
  33. return count;
  34. }
  35. bool Condition()
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (CardEffectCommons.IsOwnerTurn(card))
  40. {
  41. if (count() >= 1)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect<Func<int>>(changeValue: () => count(), isInheritedEffect: false, card: card, condition: Condition));
  50. }
  51. if (timing == EffectTiming.OnDestroyedAnyone)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[On Deletion] You may play 1 red level 4 or lower Digimon card with [Hybrid] in its form from your hand without paying its memory cost.";
  60. }
  61. bool CanSelectCardCondition(CardSource cardSource)
  62. {
  63. if (cardSource.IsDigimon)
  64. {
  65. if (cardSource.HasCardColor(CardColor.Red))
  66. {
  67. if (cardSource.Level <= 4)
  68. {
  69. if (cardSource.CardTraits.Contains("Hybrid"))
  70. {
  71. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  72. {
  73. if (cardSource.HasLevel)
  74. {
  75. return true;
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  87. }
  88. bool CanActivateCondition(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  91. {
  92. if (card.Owner.HandCards.Count >= 1)
  93. {
  94. return true;
  95. }
  96. }
  97. return false;
  98. }
  99. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  100. {
  101. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  102. {
  103. List<CardSource> selectedCards = new List<CardSource>();
  104. int maxCount = 1;
  105. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  106. selectHandEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectCardCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: true,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. selectCardCoroutine: SelectCardCoroutine,
  116. afterSelectCardCoroutine: null,
  117. mode: SelectHandEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  120. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  121. yield return StartCoroutine(selectHandEffect.Activate());
  122. IEnumerator SelectCardCoroutine(CardSource cardSource)
  123. {
  124. selectedCards.Add(cardSource);
  125. yield return null;
  126. }
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  128. }
  129. }
  130. }
  131. return cardEffects;
  132. }
  133. }