Blitz.cs 3.4 KB

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