EX3_070.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. yield return GManager.instance.photonWaitController.StartWait("AvalonsGate_selectFirst");
  121. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 2)
  122. {
  123. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  124. {
  125. new SelectionElement<int>(message: $"Suspend & gain Pierce", value : 0, spriteIndex: 0),
  126. new SelectionElement<int>(message: $"Unsuspend", value : 1, spriteIndex: 0),
  127. };
  128. string selectPlayerMessage = "Which effect will you activate?";
  129. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  130. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) == 2)
  131. {
  132. selectPlayerMessage = "Which effect will you activate the first?";
  133. }
  134. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  135. }
  136. else
  137. {
  138. for (int i = 0; i < canSelectEffects.Count; i++)
  139. {
  140. if (!activatedEffects.Contains(canSelectEffects[i]))
  141. {
  142. GManager.instance.userSelectionManager.SetInt(i);
  143. break;
  144. }
  145. }
  146. }
  147. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  148. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  149. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  150. {
  151. IEnumerator effect = canSelectEffects[effectIndex]();
  152. yield return ContinuousController.instance.StartCoroutine(effect);
  153. if (!activatedEffects.Contains(canSelectEffects[effectIndex]))
  154. {
  155. activatedEffects.Add(canSelectEffects[effectIndex]);
  156. }
  157. }
  158. }
  159. }
  160. #endregion
  161. #region 名称に「エグザモン」を含むデジモンがいない場合(1つ選択)
  162. else
  163. {
  164. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  165. {
  166. new SelectionElement<int>(message: $"Suspend & gain Pierce", value : 0, spriteIndex: 0),
  167. new SelectionElement<int>(message: $"Unsuspend", value : 1, spriteIndex: 0),
  168. };
  169. string selectPlayerMessage = "Which effect will you activate?";
  170. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  171. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  172. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  173. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  174. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  175. {
  176. IEnumerator effect = canSelectEffects[effectIndex]();
  177. yield return ContinuousController.instance.StartCoroutine(effect);
  178. }
  179. }
  180. #endregion
  181. }
  182. }
  183. if (timing == EffectTiming.SecuritySkill)
  184. {
  185. ActivateClass activateClass = new ActivateClass();
  186. activateClass.SetUpICardEffect($"Suspend 1 Digimon and unsuspend 1 Digimon", CanUseCondition, card);
  187. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  188. activateClass.SetIsSecurityEffect(true);
  189. cardEffects.Add(activateClass);
  190. string EffectDiscription()
  191. {
  192. return "[Security] Suspend 1 of your opponent's Digimon, and unsuspend 1 of your Digimon.";
  193. }
  194. bool CanSelectPermanentCondition(Permanent permanent)
  195. {
  196. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  197. }
  198. bool CanSelectPermanentCondition1(Permanent permanent)
  199. {
  200. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  205. }
  206. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  207. {
  208. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  209. {
  210. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  211. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  212. selectPermanentEffect.SetUp(
  213. selectPlayer: card.Owner,
  214. canTargetCondition: CanSelectPermanentCondition,
  215. canTargetCondition_ByPreSelecetedList: null,
  216. canEndSelectCondition: null,
  217. maxCount: maxCount,
  218. canNoSelect: false,
  219. canEndNotMax: false,
  220. selectPermanentCoroutine: null,
  221. afterSelectPermanentCoroutine: null,
  222. mode: SelectPermanentEffect.Mode.Tap,
  223. cardEffect: activateClass);
  224. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  225. }
  226. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  227. {
  228. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  229. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: CanSelectPermanentCondition1,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: maxCount,
  236. canNoSelect: false,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: null,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.UnTap,
  241. cardEffect: activateClass);
  242. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  243. }
  244. }
  245. }
  246. return cardEffects;
  247. }
  248. }
  249. }