BT6_111.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 BT6_111 : 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.SecuritySkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Add this card to hand at the end of the battle and opponent's Digimon can't attack", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. activateClass.SetIsSecurityEffect(true);
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Security] At the end of the battle, add this card to your hand. Then, if a Digimon with [Royal Knight] or [X-Antibody] in its type is in play, up to 12 of your opponent's Digimon can't attack players for the turn.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  27. }
  28. bool PermanentCondition(Permanent permanent)
  29. {
  30. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  31. {
  32. if (permanent.IsDigimon)
  33. {
  34. if (permanent.TopCard.HasRoyalKnightTraits)
  35. {
  36. return true;
  37. }
  38. if (permanent.TopCard.HasXAntibodyTraits)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (card.Owner.ExecutingCards.Contains(card))
  53. {
  54. return true;
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. yield return null;
  61. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  62. ActivateClass activateClass1 = new ActivateClass();
  63. activateClass1.SetUpICardEffect("Add this card to hand and opponent's Digimon cannot attack", CanUseCondition1, card);
  64. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  65. card.Owner.UntilEndBattleEffects.Add(GetCardEffect1);
  66. string EffectDiscription1()
  67. {
  68. return "Add this card to your hand. Then, if a Digimon with [Royal Knight] or [X-Antibody] in its type is in play, up to 12 of your opponent's Digimon can't attack players for the turn";
  69. }
  70. bool CanUseCondition1(Hashtable hashtable)
  71. {
  72. return true;
  73. }
  74. bool CanActivateCondition1(Hashtable hashtable)
  75. {
  76. if (card.Owner.ExecutingCards.Contains(card))
  77. {
  78. return true;
  79. }
  80. return false;
  81. }
  82. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  83. {
  84. if (card.Owner.ExecutingCards.Contains(card))
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(
  87. new List<CardSource>() { card },
  88. false,
  89. activateClass1));
  90. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  91. {
  92. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  93. {
  94. int maxCount = Math.Min(12, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectPermanentCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: CanEndSelectCondition,
  101. maxCount: maxCount,
  102. canNoSelect: false,
  103. canEndNotMax: true,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage(
  109. "Select Digimon that will get effects.",
  110. "The opponent is selecting Digimon that will get effects.");
  111. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  112. bool CanEndSelectCondition(List<Permanent> permanents)
  113. {
  114. if (CardEffectCommons.HasNoElement(permanents))
  115. {
  116. return false;
  117. }
  118. return true;
  119. }
  120. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  121. {
  122. bool DefenderCondition(Permanent defender)
  123. {
  124. return defender == null;
  125. }
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  127. targetPermanent: permanent,
  128. defenderCondition: DefenderCondition,
  129. effectDuration: EffectDuration.UntilEachTurnEnd,
  130. activateClass: activateClass,
  131. effectName: "Can't Attack to player"));
  132. }
  133. }
  134. }
  135. }
  136. }
  137. ICardEffect GetCardEffect1(EffectTiming _timing)
  138. {
  139. if (_timing == EffectTiming.OnEndBattle)
  140. {
  141. return activateClass1;
  142. }
  143. return null;
  144. }
  145. }
  146. }
  147. if (timing == EffectTiming.OnAllyAttack)
  148. {
  149. ActivateClass activateClass = new ActivateClass();
  150. activateClass.SetUpICardEffect("Pay memory cost and this Digimon gets +DP", CanUseCondition, card);
  151. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  152. cardEffects.Add(activateClass);
  153. string EffectDiscription()
  154. {
  155. return "[When Attacking] You may pay up to 5 memory. If you do, this Digimon gets +1000 DP for the turn for each memory paid.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleArea(card))
  164. {
  165. if (card.Owner.MaxMemoryCost >= 1)
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  173. {
  174. if (isExistOnField(card))
  175. {
  176. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  177. {
  178. int count = 0;
  179. while (card.Owner.MaxMemoryCost >= 1 && count < 5)
  180. {
  181. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  182. {
  183. new SelectionElement<bool>(message: $"Pay Cost", value : true, spriteIndex: 0),
  184. new SelectionElement<bool>(message: $"Not Pay Cost", value : false, spriteIndex: 1),
  185. };
  186. string selectPlayerMessage = $"Will you pay 1 memory cost?(already paid cost:{count})";
  187. string notSelectPlayerMessage = "The opponent is choosing whether to pay memory cost.";
  188. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  189. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  190. bool payCost = GManager.instance.userSelectionManager.SelectedBoolValue;
  191. if (payCost)
  192. {
  193. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-1, activateClass));
  194. count++;
  195. }
  196. else
  197. {
  198. break;
  199. }
  200. }
  201. if (count >= 1)
  202. {
  203. int plusDP = 1000 * count;
  204. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: plusDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  205. }
  206. }
  207. }
  208. }
  209. }
  210. if (timing == EffectTiming.OnEndAttack)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect("Memory +2", CanUseCondition, card);
  214. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  215. cardEffects.Add(activateClass);
  216. string EffectDiscription()
  217. {
  218. return "[End of Attack] Gain 2 memory.";
  219. }
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleArea(card))
  227. {
  228. if (card.Owner.CanAddMemory(activateClass))
  229. {
  230. return true;
  231. }
  232. }
  233. return false;
  234. }
  235. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  236. {
  237. if (isExistOnField(card))
  238. {
  239. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  242. }
  243. }
  244. }
  245. }
  246. return cardEffects;
  247. }
  248. }