P_044.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 P_044 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Suspend Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Suspend 1 of your opponent's Digimon, or 2 of your opponent's Digimon with 5000 DP or less.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectPermanentCondition1(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent.DP <= 5000)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. bool canSuspend1 = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  47. bool canSuspend2 = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1);
  48. if (canSuspend1 || canSuspend2)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. bool canSuspend1 = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  58. bool canSuspend2 = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1);
  59. if (canSuspend1 || canSuspend2)
  60. {
  61. if (canSuspend1 && canSuspend2)
  62. {
  63. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  64. {
  65. new SelectionElement<bool>(message: $"Suspend 1", value : true, spriteIndex: 0),
  66. new SelectionElement<bool>(message: $"Suspend 2", value : false, spriteIndex: 1),
  67. };
  68. string selectPlayerMessage = "Which effect do you choose?";
  69. string notSelectPlayerMessage = "The opponent is choosing the effect.";
  70. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  71. }
  72. else
  73. {
  74. GManager.instance.userSelectionManager.SetBool(canSuspend1);
  75. }
  76. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  77. bool _isSuspendOne = GManager.instance.userSelectionManager.SelectedBoolValue;
  78. int maxCount = _isSuspendOne ? Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition)) : Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. selectPermanentEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: _isSuspendOne ? CanSelectPermanentCondition : CanSelectPermanentCondition1,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: maxCount,
  86. canNoSelect: false,
  87. canEndNotMax: false,
  88. selectPermanentCoroutine: null,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Tap,
  91. cardEffect: activateClass);
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. }
  94. }
  95. }
  96. return cardEffects;
  97. }
  98. }