Blitz.cs 3.8 KB

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