EX3_070.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX3
  8. {
  9. public class EX3_070 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] Activate 1 of the effects below. If you have a Digimon with [Examon] in its name in play, activate all of the effects below instead. - Suspend 1 of your opponent's Digimon, and 1 of your Digimon gains <Piercing> for the turn. - Unsuspend 1 of your Digimon.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  27. }
  28. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  29. {
  30. #region レスト&貫通
  31. Func<IEnumerator> _SuspendAndPierce = () => SuspendAndPierce();
  32. IEnumerator SuspendAndPierce()
  33. {
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  37. }
  38. bool CanSelectPermanentCondition1(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  41. }
  42. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  43. {
  44. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: CanSelectPermanentCondition,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: maxCount,
  52. canNoSelect: false,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: null,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.Tap,
  57. cardEffect: activateClass);
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. }
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition1,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain Pierce.", "The opponent is selecting 1 Digimon that will gain Pierce.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(targetPermanent: permanent, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  81. }
  82. }
  83. }
  84. #endregion
  85. #region アクティブ
  86. Func<IEnumerator> _Unsuspend = () => Unsuspend();
  87. IEnumerator Unsuspend()
  88. {
  89. bool CanSelectPermanentCondition(Permanent permanent)
  90. {
  91. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  92. }
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  94. {
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: null,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.UnTap,
  108. cardEffect: activateClass);
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. }
  111. }
  112. #endregion
  113. List<Func<IEnumerator>> canSelectEffects = new List<Func<IEnumerator>>() { _SuspendAndPierce, _Unsuspend };
  114. #region 名称に「エグザモン」を含むデジモンがいる場合(順番を選択)
  115. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.ContainsCardName("Examon")))
  116. {
  117. List<Func<IEnumerator>> activatedEffects = new List<Func<IEnumerator>>();
  118. while (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 1)
  119. {
  120. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 2)
  121. {
  122. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  123. {
  124. new SelectionElement<int>(message: $"Suspend & gain Pierce", value : 0, spriteIndex: 0),
  125. new SelectionElement<int>(message: $"Unsuspend", value : 1, spriteIndex: 0),
  126. };
  127. string selectPlayerMessage = "Which effect will you activate?";
  128. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  129. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) == 2)
  130. {
  131. selectPlayerMessage = "Which effect will you activate the first?";
  132. }
  133. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  134. }
  135. else
  136. {
  137. for (int i = 0; i < canSelectEffects.Count; i++)
  138. {
  139. if (!activatedEffects.Contains(canSelectEffects[i]))
  140. {
  141. GManager.instance.userSelectionManager.SetInt(i);
  142. break;
  143. }
  144. }
  145. }
  146. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  147. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  148. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  149. {
  150. IEnumerator effect = canSelectEffects[effectIndex]();
  151. yield return ContinuousController.instance.StartCoroutine(effect);
  152. if (!activatedEffects.Contains(canSelectEffects[effectIndex]))
  153. {
  154. activatedEffects.Add(canSelectEffects[effectIndex]);
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. #region 名称に「エグザモン」を含むデジモンがいない場合(1つ選択)
  161. else
  162. {
  163. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  164. {
  165. new SelectionElement<int>(message: $"Suspend & gain Pierce", value : 0, spriteIndex: 0),
  166. new SelectionElement<int>(message: $"Unsuspend", value : 1, spriteIndex: 0),
  167. };
  168. string selectPlayerMessage = "Which effect will you activate?";
  169. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  170. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  171. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  172. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  173. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  174. {
  175. IEnumerator effect = canSelectEffects[effectIndex]();
  176. yield return ContinuousController.instance.StartCoroutine(effect);
  177. }
  178. }
  179. #endregion
  180. }
  181. }
  182. if (timing == EffectTiming.SecuritySkill)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect($"Suspend 1 Digimon and unsuspend 1 Digimon", CanUseCondition, card);
  186. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  187. activateClass.SetIsSecurityEffect(true);
  188. cardEffects.Add(activateClass);
  189. string EffectDiscription()
  190. {
  191. return "[Security] Suspend 1 of your opponent's Digimon, and unsuspend 1 of your Digimon.";
  192. }
  193. bool CanSelectPermanentCondition(Permanent permanent)
  194. {
  195. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  196. }
  197. bool CanSelectPermanentCondition1(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  204. }
  205. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  206. {
  207. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  208. {
  209. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  210. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  211. selectPermanentEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: CanSelectPermanentCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: maxCount,
  217. canNoSelect: false,
  218. canEndNotMax: false,
  219. selectPermanentCoroutine: null,
  220. afterSelectPermanentCoroutine: null,
  221. mode: SelectPermanentEffect.Mode.Tap,
  222. cardEffect: activateClass);
  223. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  224. }
  225. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  226. {
  227. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  228. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  229. selectPermanentEffect.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: CanSelectPermanentCondition1,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: maxCount,
  235. canNoSelect: false,
  236. canEndNotMax: false,
  237. selectPermanentCoroutine: null,
  238. afterSelectPermanentCoroutine: null,
  239. mode: SelectPermanentEffect.Mode.UnTap,
  240. cardEffect: activateClass);
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. }
  243. }
  244. }
  245. return cardEffects;
  246. }
  247. }
  248. }