Collision.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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)
  10. {
  11. if (IsExistOnBattleArea(cardSource))
  12. {
  13. if (cardSource.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  14. {
  15. if (GManager.instance.attackProcess.IsAttacking)
  16. {
  17. return true;
  18. }
  19. }
  20. }
  21. return false;
  22. }
  23. #endregion
  24. #region Effect process of [Collision]
  25. public static IEnumerator CollisionProcess(CardSource cardSource, ICardEffect activateClass, Func<IEnumerator> beforeOnAttackCoroutine = null)
  26. {
  27. List<Permanent> enemyDigimons = new List<Permanent>();
  28. if (CanActivateCollision(cardSource))
  29. {
  30. foreach (Permanent enemyDigimon in cardSource.Owner.Enemy.GetBattleAreaDigimons())
  31. {
  32. if (enemyDigimon.TopCard.CanNotBeAffected(activateClass))
  33. continue;
  34. yield return ContinuousController.instance.StartCoroutine(GainBlocker(
  35. targetPermanent: enemyDigimon,
  36. effectDuration: EffectDuration.UntilEndAttack,
  37. activateClass: activateClass));
  38. GManager.instance.attackProcess.IsBlocking = true;
  39. }
  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: activateClass);
  55. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will block.", "The opponent is selecting 1 Digimon that will block.");
  56. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  57. bool CanSelectBlockerCondition(Permanent permanent)
  58. {
  59. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  60. {
  61. if (!permanent.TopCard.Owner.isYou)
  62. {
  63. if (permanent.HasBlocker && permanent.CanBlock(cardSource.PermanentOfThisCard()))
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(null, true, selectedPermanent));
  75. }*/
  76. }
  77. }
  78. #endregion
  79. }