BT5_082.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 BT5_082 : 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.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Activate Effects", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] Activate 1 of the effects below. If you have no other Digimon in play, activate all of the effects below instead. - Gain 1 memory. - This Digimon gets +2000 DP for the turn. - Delete up to 3 of your opponent's level 3 Digimon.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  36. {
  37. #region メモリー+1
  38. Func<IEnumerator> _Gain1Memory = () => Gain1Memory();
  39. IEnumerator Gain1Memory()
  40. {
  41. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  42. }
  43. #endregion
  44. #region DP+2000
  45. Func<IEnumerator> _DP2000Plus = () => DP2000Plus();
  46. IEnumerator DP2000Plus()
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  51. }
  52. }
  53. #endregion
  54. #region レベル3デジモン消滅
  55. Func<IEnumerator> _DeleteDigimons = () => DeleteDigimons();
  56. IEnumerator DeleteDigimons()
  57. {
  58. bool CanSelectPermanentCondition(Permanent permanent)
  59. {
  60. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  61. {
  62. if (permanent.Level == 3)
  63. {
  64. if (permanent.TopCard.HasLevel)
  65. {
  66. return true;
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  73. {
  74. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  75. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectPermanentCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: CanEndSelectCondition,
  81. maxCount: maxCount,
  82. canNoSelect: false,
  83. canEndNotMax: true,
  84. selectPermanentCoroutine: null,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Destroy,
  87. cardEffect: activateClass);
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. bool CanEndSelectCondition(List<Permanent> permanents)
  90. {
  91. if (CardEffectCommons.HasNoElement(permanents))
  92. {
  93. return false;
  94. }
  95. return true;
  96. }
  97. }
  98. }
  99. #endregion
  100. List<Func<IEnumerator>> canSelectEffects = new List<Func<IEnumerator>>() { _Gain1Memory, _DP2000Plus, _DeleteDigimons };
  101. #region 他のデジモンがいない場合(順番を選択)
  102. if (card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard()) == 0)
  103. {
  104. List<Func<IEnumerator>> activatedEffects = new List<Func<IEnumerator>>();
  105. while (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 1)
  106. {
  107. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) >= 2)
  108. {
  109. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  110. {
  111. new SelectionElement<int>(message: $"Memory +1", value : 0, spriteIndex: 0),
  112. new SelectionElement<int>(message: $"DP +2000", value : 1, spriteIndex: 0),
  113. new SelectionElement<int>(message: $"Delete Digimons", value : 2, spriteIndex: 0),
  114. };
  115. string selectPlayerMessage = "Which effect will you activate?";
  116. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  117. if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) == 3)
  118. {
  119. selectPlayerMessage = "Which effect will you activate the first?";
  120. }
  121. else if (canSelectEffects.Count((effect) => !activatedEffects.Contains(effect)) == 2)
  122. {
  123. selectPlayerMessage = "Which effect will you activate the second?";
  124. }
  125. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  126. }
  127. else
  128. {
  129. for (int i = 0; i < canSelectEffects.Count; i++)
  130. {
  131. if (!activatedEffects.Contains(canSelectEffects[i]))
  132. {
  133. GManager.instance.userSelectionManager.SetInt(i);
  134. break;
  135. }
  136. }
  137. }
  138. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  139. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  140. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  141. {
  142. IEnumerator effect = canSelectEffects[effectIndex]();
  143. yield return ContinuousController.instance.StartCoroutine(effect);
  144. if (!activatedEffects.Contains(canSelectEffects[effectIndex]))
  145. {
  146. activatedEffects.Add(canSelectEffects[effectIndex]);
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. #region 他のデジモンがいる場合(1つ選択)
  153. else
  154. {
  155. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  156. {
  157. new SelectionElement<int>(message: $"Memory +1", value : 0, spriteIndex: 0),
  158. new SelectionElement<int>(message: $"DP +2000", value : 1, spriteIndex: 0),
  159. new SelectionElement<int>(message: $"Delete Digimons", value : 2, spriteIndex: 0),
  160. };
  161. string selectPlayerMessage = "Which effect will you activate?";
  162. string notSelectPlayerMessage = "The opponent is choosing which effect activates.";
  163. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  164. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  165. int effectIndex = GManager.instance.userSelectionManager.SelectedIntValue;
  166. if (0 <= effectIndex && effectIndex <= canSelectEffects.Count - 1)
  167. {
  168. IEnumerator effect = canSelectEffects[effectIndex]();
  169. yield return ContinuousController.instance.StartCoroutine(effect);
  170. }
  171. }
  172. #endregion
  173. }
  174. }
  175. return cardEffects;
  176. }
  177. }