BT10_036.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_036 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Select effects", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Digivolving] You may activate 1 of the effects below. - Return 1 Option card with [Plug-In] in its name from your trash to your hand. - By trashing 1 Option card with [Plug-In] in its name in your hand, <Draw 2>. (Draw 2 cards from your deck.)";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource.IsOption)
  28. {
  29. if (cardSource.ContainsCardName("Plug-In"))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  45. {
  46. return true;
  47. }
  48. if (card.Owner.HandCards.Count >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  58. bool canSelectHand = card.Owner.HandCards.Some(CanSelectCardCondition);
  59. if (canSelectTrash || canSelectHand)
  60. {
  61. if (canSelectTrash && canSelectHand)
  62. {
  63. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  64. {
  65. new SelectionElement<bool>(message: $"Return 1 card from trash", value : true, spriteIndex: 0),
  66. new SelectionElement<bool>(message: $"Discard 1 card to draw 2", value : false, spriteIndex: 1),
  67. };
  68. string selectPlayerMessage = "Which effect will you activate?";
  69. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  70. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  71. }
  72. else
  73. {
  74. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  75. }
  76. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  77. bool isReturnFromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  78. if (isReturnFromTrash)
  79. {
  80. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  81. {
  82. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  83. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  84. selectCardEffect.SetUp(
  85. canTargetCondition: CanSelectCardCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. canNoSelect: () => false,
  89. selectCardCoroutine: null,
  90. afterSelectCardCoroutine: null,
  91. message: "Select 1 card to add to your hand.",
  92. maxCount: maxCount,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. mode: SelectCardEffect.Mode.AddHand,
  96. root: SelectCardEffect.Root.Trash,
  97. customRootCardList: null,
  98. canLookReverseCard: true,
  99. selectPlayer: card.Owner,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  102. }
  103. }
  104. else
  105. {
  106. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  107. {
  108. bool discarded = false;
  109. int discardCount = 1;
  110. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  111. selectHandEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: CanSelectCardCondition,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: discardCount,
  117. canNoSelect: true,
  118. canEndNotMax: false,
  119. isShowOpponent: true,
  120. selectCardCoroutine: null,
  121. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  122. mode: SelectHandEffect.Mode.Discard,
  123. cardEffect: activateClass);
  124. yield return StartCoroutine(selectHandEffect.Activate());
  125. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  126. {
  127. if (cardSources.Count >= 1)
  128. {
  129. discarded = true;
  130. yield return null;
  131. }
  132. }
  133. if (discarded)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return cardEffects;
  143. }
  144. }
  145. }