Collision.cs 3.7 KB

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