BT7_107.cs 5.8 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 BT7_107 : 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] Delete 1 of your Digimon. Then, return up to 2 purple Digimon cards from your trash to your hand.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. if (cardSource != null)
  30. {
  31. if (cardSource.IsDigimon)
  32. {
  33. if (cardSource.Owner == card.Owner)
  34. {
  35. if (cardSource.HasCardColor(CardColor.Purple))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  51. {
  52. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  53. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  54. selectPermanentEffect.SetUp(
  55. selectPlayer: card.Owner,
  56. canTargetCondition: CanSelectPermanentCondition,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. maxCount: maxCount,
  60. canNoSelect: false,
  61. canEndNotMax: false,
  62. selectPermanentCoroutine: null,
  63. afterSelectPermanentCoroutine: null,
  64. mode: SelectPermanentEffect.Mode.Destroy,
  65. cardEffect: activateClass);
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. }
  68. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  69. {
  70. int maxCount = Math.Min(2, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  71. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  72. selectCardEffect.SetUp(
  73. canTargetCondition: CanSelectCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: CanEndSelectCondition,
  76. canNoSelect: () => false,
  77. selectCardCoroutine: null,
  78. afterSelectCardCoroutine: null,
  79. message: "Select cards to add to your hand.",
  80. maxCount: maxCount,
  81. canEndNotMax: true,
  82. isShowOpponent: true,
  83. mode: SelectCardEffect.Mode.AddHand,
  84. root: SelectCardEffect.Root.Trash,
  85. customRootCardList: null,
  86. canLookReverseCard: true,
  87. selectPlayer: card.Owner,
  88. cardEffect: activateClass);
  89. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  90. bool CanEndSelectCondition(List<CardSource> cardSources)
  91. {
  92. if (maxCount >= 1)
  93. {
  94. if (cardSources.Count <= 0)
  95. {
  96. return false;
  97. }
  98. }
  99. return true;
  100. }
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.SecuritySkill)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  109. activateClass.SetIsSecurityEffect(true);
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[Security] Add this card to its owner's hand.";
  114. }
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  122. }
  123. }
  124. return cardEffects;
  125. }
  126. }