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