ST10_14.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 ST10_14 : 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] Place 1 of your opponent's Digimon face down at the top or bottom of your opponent's security stack. If you do, trash the top card of your opponent's security stack.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  32. {
  33. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  34. {
  35. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  36. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  37. selectPermanentEffect.SetUp(
  38. selectPlayer: card.Owner,
  39. canTargetCondition: CanSelectPermanentCondition,
  40. canTargetCondition_ByPreSelecetedList: null,
  41. canEndSelectCondition: null,
  42. maxCount: maxCount,
  43. canNoSelect: false,
  44. canEndNotMax: false,
  45. selectPermanentCoroutine: SelectPermanentCoroutine,
  46. afterSelectPermanentCoroutine: null,
  47. mode: SelectPermanentEffect.Mode.Custom,
  48. cardEffect: activateClass);
  49. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  50. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  51. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  52. {
  53. Permanent selectedPermanent = permanent;
  54. if (selectedPermanent != null)
  55. {
  56. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  57. {
  58. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  59. {
  60. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  61. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  62. };
  63. string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
  64. string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
  65. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  66. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  67. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  68. if (toTop)
  69. {
  70. GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
  71. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
  72. }
  73. else
  74. {
  75. GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
  76. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
  77. }
  78. yield return new WaitForSeconds(0.4f);
  79. GManager.instance.commandText.CloseCommandText();
  80. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  81. Permanent securityPermanent = selectedPermanent;
  82. CardSource securityCard = securityPermanent.TopCard;
  83. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  84. securityPermanent,
  85. CardEffectCommons.CardEffectHashtable(activateClass),
  86. toTop).PutSecurity());
  87. if (securityPermanent.TopCard == null)
  88. {
  89. if (securityCard.Owner.SecurityCards.Contains(securityCard) || securityCard.IsToken)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  92. player: card.Owner.Enemy,
  93. destroySecurityCount: 1,
  94. cardEffect: activateClass,
  95. fromTop: true).DestroySecurity());
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.SecuritySkill)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect($"Place an opponent's Digimon to security", 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] You may place 1 of your opponent's Digimon face down at the top or bottom of its owner's security stack.";
  114. }
  115. bool CanSelectPermanentCondition(Permanent permanent)
  116. {
  117. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  126. {
  127. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectPermanentCondition,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: SelectPermanentCoroutine,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Custom,
  140. cardEffect: activateClass);
  141. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  142. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  143. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  144. {
  145. Permanent selectedPermanent = permanent;
  146. if (selectedPermanent != null)
  147. {
  148. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  149. {
  150. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  151. {
  152. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  153. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  154. };
  155. string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
  156. string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
  157. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  158. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  159. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  160. if (toTop)
  161. {
  162. GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
  163. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
  164. }
  165. else
  166. {
  167. GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
  168. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
  169. }
  170. yield return new WaitForSeconds(0.4f);
  171. GManager.instance.commandText.CloseCommandText();
  172. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  173. Permanent securityPermanent = selectedPermanent;
  174. CardSource securityCard = securityPermanent.TopCard;
  175. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  176. securityPermanent,
  177. CardEffectCommons.CardEffectHashtable(activateClass),
  178. toTop).PutSecurity());
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. return cardEffects;
  186. }
  187. }