Blitz.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 [Blitz]
  9. public static bool CanActivateBlitz(CardSource cardSource, ICardEffect activateClass)
  10. {
  11. if (IsExistOnBattleArea(cardSource))
  12. {
  13. if (cardSource.PermanentOfThisCard().CanAttack(activateClass))
  14. {
  15. if (cardSource.Owner.Enemy.MemoryForPlayer >= 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 BlitzProcess(CardSource cardSource, ICardEffect activateClass, Func<IEnumerator> beforeOnAttackCoroutine = null)
  29. {
  30. if (CanActivateBlitz(cardSource, activateClass))
  31. {
  32. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  33. selectAttackEffect.SetUp(
  34. attacker: cardSource.PermanentOfThisCard(),
  35. canAttackPlayerCondition: () => true,
  36. defenderCondition: (permanent) => true,
  37. cardEffect: activateClass);
  38. selectAttackEffect.SetBeforeOnAttackCoroutine(beforeOnAttackCoroutine);
  39. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  40. }
  41. }
  42. #endregion
  43. #region Target 1 Digimon gains [Blitz]
  44. public static IEnumerator GainBlitz(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass, bool isWhenDigivolving)
  45. {
  46. if (targetPermanent == null) yield break;
  47. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  48. if (activateClass == null) yield break;
  49. if (activateClass.EffectSourceCard == null) yield break;
  50. CardSource card = activateClass.EffectSourceCard;
  51. bool CanUseCondition()
  52. {
  53. if (IsPermanentExistsOnBattleArea(targetPermanent))
  54. {
  55. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. ActivateClass blitz = CardEffectFactory.BlitzEffect(
  63. targetPermanent: targetPermanent,
  64. isInheritedEffect: false,
  65. condition: CanUseCondition,
  66. isWhenDigivolving: isWhenDigivolving,
  67. rootCardEffect: activateClass,
  68. card: targetPermanent.TopCard);
  69. AddEffectToPermanent(
  70. targetPermanent: targetPermanent,
  71. effectDuration: effectDuration,
  72. card: card,
  73. cardEffect: blitz,
  74. timing: EffectTiming.OnEnterFieldAnyone);
  75. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  78. }
  79. }
  80. #endregion
  81. }