Collision.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can activate [Collision]
  9. public static bool CanActivateCollision(CardSource cardSource, ICardEffect activateClass)
  10. {
  11. if (IsExistOnBattleArea(cardSource))
  12. {
  13. if (cardSource.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Blitz]
  22. public static IEnumerator CollisionProcess(CardSource cardSource, ICardEffect activateClass, Func<IEnumerator> beforeOnAttackCoroutine = null)
  23. {
  24. if (CanActivateCollision(cardSource, activateClass))
  25. {
  26. foreach(Permanent enemyDigimon in cardSource.Owner.Enemy.GetBattleAreaDigimons())
  27. {
  28. if (!enemyDigimon.TopCard.CanNotBeAffected(activateClass))
  29. {
  30. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  31. targetPermanent: enemyDigimon,
  32. effectDuration: EffectDuration.UntilEndAttack,
  33. activateClass: activateClass));
  34. int maxCount = 1;
  35. Permanent selectedPermanent = null;
  36. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  37. selectPermanentEffect.SetUp(
  38. selectPlayer: cardSource.Owner.Enemy,
  39. canTargetCondition: CanSelectBlockerCondition,
  40. canTargetCondition_ByPreSelecetedList: null,
  41. canEndSelectCondition: null,
  42. maxCount: maxCount,
  43. canNoSelect: false,
  44. canEndNotMax: false,
  45. selectPermanentCoroutine: SelectPermanentCoroutine,
  46. afterSelectPermanentCoroutine: null,
  47. mode: SelectPermanentEffect.Mode.Custom,
  48. cardEffect: null);
  49. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will block.", "The opponent is selecting 1 Digimon that will block.");
  50. selectPermanentEffect.SetUpCustomBackButtonMessage("Not Block");
  51. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  52. bool CanSelectBlockerCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  55. {
  56. if (permanent.TopCard.Owner.isYou)
  57. {
  58. if (permanent.HasBlocker && permanent.CanBlock(cardSource.PermanentOfThisCard()))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. selectedPermanent = permanent;
  69. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(null, true, selectedPermanent));
  70. }
  71. }
  72. }
  73. }
  74. }
  75. #endregion
  76. }