MindLink.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. public class MindLinkClass
  6. {
  7. public MindLinkClass(Permanent tamer, Func<Permanent, bool> digimonCondition, ICardEffect activateClass)
  8. {
  9. _tamer = tamer;
  10. _digimonCondition = digimonCondition;
  11. _activateClass = activateClass;
  12. }
  13. Permanent _tamer = null;
  14. Func<Permanent, bool> _digimonCondition = null;
  15. ICardEffect _activateClass = null;
  16. bool CanSelectPermanentCondition(Permanent permanent)
  17. {
  18. if (CardEffectCommons.IsPermanentExistsOnBattleArea(_tamer))
  19. {
  20. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, _tamer.TopCard))
  21. {
  22. if (!permanent.IsToken)
  23. {
  24. if (permanent.DigivolutionCards.Count(cardSource => cardSource.IsTamer && !cardSource.IsFlipped) == 0)
  25. {
  26. if (_digimonCondition == null || _digimonCondition(permanent))
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. public IEnumerator MindLink()
  37. {
  38. if (_tamer == null) yield break;
  39. if (_tamer.TopCard == null) yield break;
  40. if (_digimonCondition == null) yield break;
  41. if (_activateClass == null) yield break;
  42. if (_activateClass.EffectSourceCard == null) yield break;
  43. CardSource card = _activateClass.EffectSourceCard;
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: maxCount,
  54. canNoSelect: true,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: _activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  61. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  62. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  63. {
  64. Permanent selectedPermanent = permanent;
  65. if (selectedPermanent != null)
  66. {
  67. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { _tamer, selectedPermanent } }, false, _activateClass).PlacePermanentToDigivolutionCards());
  68. }
  69. }
  70. }
  71. }
  72. }