RB1_027.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RB1_027 : CEntity_Effect
  5. {
  6. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  7. {
  8. List<ICardEffect> cardEffects = new List<ICardEffect>();
  9. if (timing == EffectTiming.OnEnterFieldAnyone)
  10. {
  11. ActivateClass activateClass = new ActivateClass();
  12. activateClass.SetUpICardEffect("Reveal the top card of opponent's security", CanUseCondition, card);
  13. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  14. cardEffects.Add(activateClass);
  15. string EffectDiscription()
  16. {
  17. return "[On Play] Reveal the top card of your opponent's security stack. If that card is a Digimon card, gain 1 memory. If it's a non-Digimon card, <Draw 1>. Place the revealed card at the top or bottom of your opponent's security stack face down.";
  18. }
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  22. }
  23. bool CanActivateCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleArea(card))
  26. {
  27. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  35. {
  36. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  37. {
  38. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  39. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { topCard }, "Security Top card", true, true));
  40. if (topCard.IsDigimon)
  41. {
  42. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  43. }
  44. else
  45. {
  46. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  47. }
  48. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  49. {
  50. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  51. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  52. };
  53. string selectPlayerMessage = "Do you place the card on the top or bottom of the security?";
  54. string notSelectPlayerMessage = "The opponent is choosing whether to place the card on the top or bottom of security.";
  55. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  56. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  57. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  58. if (toTop)
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(new List<CardSource>() { topCard }, "Card placed at Security Top", true, true));
  61. }
  62. else
  63. {
  64. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(new List<CardSource>() { topCard }, "Card placed at Security Bottom", true, true));
  65. topCard.Owner.SecurityCards.Remove(topCard);
  66. topCard.Owner.SecurityCards.Add(topCard);
  67. }
  68. topCard.SetReverse();
  69. }
  70. }
  71. }
  72. if (timing == EffectTiming.OnEnterFieldAnyone)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Reveal the top card of opponent's security", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  77. cardEffects.Add(activateClass);
  78. string EffectDiscription()
  79. {
  80. return "[When Digivolving] Reveal the top card of your opponent's security stack. If that card is a Digimon card, gain 1 memory. If it's a non-Digimon card, <Draw 1>. Place the revealed card at the top or bottom of your opponent's security stack face down.";
  81. }
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. if (CardEffectCommons.IsExistOnBattleArea(card))
  89. {
  90. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  98. {
  99. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  100. {
  101. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  102. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { topCard }, "Security Top card", true, true));
  103. if (topCard.IsDigimon)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  106. }
  107. else
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  110. }
  111. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  112. {
  113. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  114. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  115. };
  116. string selectPlayerMessage = "Do you place the card on the top or bottom of the security?";
  117. string notSelectPlayerMessage = "The opponent is choosing whether to place the card on the top or bottom of security.";
  118. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  119. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  120. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  121. if (toTop)
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(new List<CardSource>() { topCard }, "Card placed at Security Top", true, true));
  124. }
  125. else
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(new List<CardSource>() { topCard }, "Card placed at Security Bottom", true, true));
  128. topCard.Owner.SecurityCards.Remove(topCard);
  129. topCard.Owner.SecurityCards.Add(topCard);
  130. }
  131. topCard.SetReverse();
  132. }
  133. }
  134. }
  135. if (timing == EffectTiming.None)
  136. {
  137. bool Condition()
  138. {
  139. if (CardEffectCommons.IsExistOnBattleArea(card))
  140. {
  141. if (CardEffectCommons.HasMatchConditionPermanent((permanent) => permanent.IsTamer))
  142. {
  143. return true;
  144. }
  145. }
  146. return false;
  147. }
  148. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: Condition));
  149. }
  150. if (timing == EffectTiming.None)
  151. {
  152. bool PermanentCondition(Permanent permanent)
  153. {
  154. return permanent == card.PermanentOfThisCard();
  155. }
  156. bool CardEffectCondition(ICardEffect cardEffect)
  157. {
  158. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  159. }
  160. bool CanUseCondition()
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent((permanent) => permanent.IsTamer))
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. string effectName = "This Digimon can't be deleted by opponent's effects";
  172. cardEffects.Add(CardEffectFactory.CanNotBeDestroyedBySkillStaticEffect(
  173. permanentCondition: PermanentCondition,
  174. cardEffectCondition: CardEffectCondition,
  175. isInheritedEffect: false,
  176. card: card,
  177. condition: CanUseCondition,
  178. effectName: effectName
  179. ));
  180. }
  181. return cardEffects;
  182. }
  183. }