BT10_095.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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_095 : 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.OptionSkill)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Main] Activate 1 of the effects below. If you have a Digimon with [Shoutmon X5] in its name in play, activate all of the effects below instead. - 1 of your Digimon with [Xros Heart] in its traits gains <Security Attack +1> for the turn. - <Draw 2> (Draw 2 cards from your deck.)";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  28. }
  29. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  30. {
  31. #region セキュリティアタック
  32. Func<IEnumerator> _SecurityAttack1Plus = () => SecurityAttack1Plus();
  33. IEnumerator SecurityAttack1Plus()
  34. {
  35. bool CanSelectPermanentCondition(Permanent permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.CardTraits.Contains("Xros Heart") || permanent.TopCard.CardTraits.Contains("XrosHeart"))
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  49. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  50. selectPermanentEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: CanSelectPermanentCondition,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: maxCount,
  56. canNoSelect: false,
  57. canEndNotMax: false,
  58. selectPermanentCoroutine: SelectPermanentCoroutine,
  59. afterSelectPermanentCoroutine: null,
  60. mode: SelectPermanentEffect.Mode.Custom,
  61. cardEffect: activateClass);
  62. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack +1.", "The opponent is selecting 1 Digimon that will get Security Attack +1.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  65. {
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  67. }
  68. }
  69. }
  70. #endregion
  71. #region 2ドロー
  72. Func<IEnumerator> _Draw2 = () => Draw2();
  73. IEnumerator Draw2()
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  76. }
  77. #endregion
  78. List<Func<IEnumerator>> canSelectEffects = new List<Func<IEnumerator>>() { _SecurityAttack1Plus, _Draw2 };
  79. #region シャウトモンX5がいる場合(順番を選択
  80. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.ContainsCardName("Shoutmon X5")))
  81. {
  82. List<Func<IEnumerator>> activatedEffects = new List<Func<IEnumerator>>();
  83. while (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 1)
  84. {
  85. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 2)
  86. {
  87. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  88. {
  89. new SelectionElement<int>(message: $"S Attack +1", value : 0, spriteIndex: 0),
  90. new SelectionElement<int>(message: $"Draw 2", value : 1, spriteIndex: 0),
  91. };
  92. string selectPlayerMessage = "Which effect will you activate the first?";
  93. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  94. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  95. }
  96. else
  97. {
  98. for (int i = 0; i < canSelectEffects.Count; i++)
  99. {
  100. if (!activatedEffects.Contains(canSelectEffects[i]))
  101. {
  102. GManager.instance.userSelectionManager.SetInt(i);
  103. break;
  104. }
  105. }
  106. }
  107. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  108. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  109. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  110. {
  111. IEnumerator effect = canSelectEffects[effectIndex]();
  112. yield return ContinuousController.instance.StartCoroutine(effect);
  113. if (!activatedEffects.Contains(canSelectEffects[effectIndex]))
  114. {
  115. activatedEffects.Add(canSelectEffects[effectIndex]);
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region シャウトモンX5がいない場合(1つ選択
  122. else
  123. {
  124. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  125. {
  126. new SelectionElement<int>(message: $"S Attack +1", value : 0, spriteIndex: 0),
  127. new SelectionElement<int>(message: $"Draw 2", value : 1, spriteIndex: 0),
  128. };
  129. string selectPlayerMessage = "Which effect will you activate?";
  130. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  131. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  132. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  133. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  134. GManager.instance.commandText.CloseCommandText();
  135. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  136. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  137. {
  138. IEnumerator effect = canSelectEffects[effectIndex]();
  139. yield return ContinuousController.instance.StartCoroutine(effect);
  140. }
  141. }
  142. #endregion
  143. }
  144. }
  145. if (timing == EffectTiming.SecuritySkill)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  150. activateClass.SetIsSecurityEffect(true);
  151. cardEffects.Add(activateClass);
  152. string EffectDiscription()
  153. {
  154. return "[Security] Add this card to its owner's hand.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  163. }
  164. }
  165. return cardEffects;
  166. }
  167. }
  168. }