Blitz.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectFactory
  7. {
  8. #region Trigger effect of [Blitz] on oneself
  9. public static ActivateClass BlitzSelfEffect(
  10. bool isInheritedEffect,
  11. CardSource card,
  12. Func<bool> condition,
  13. bool isWhenDigivolving,
  14. ICardEffect rootCardEffect = null)
  15. {
  16. Permanent targetPermanent = card.PermanentOfThisCard() ?? new Permanent(new List<CardSource>() { card });
  17. bool CanUseCondition()
  18. {
  19. if (condition == null || condition())
  20. {
  21. return true;
  22. }
  23. return false;
  24. }
  25. return BlitzEffect(
  26. targetPermanent: targetPermanent,
  27. isInheritedEffect: isInheritedEffect,
  28. condition: CanUseCondition,
  29. isWhenDigivolving: isWhenDigivolving,
  30. rootCardEffect: rootCardEffect,
  31. card: card);
  32. }
  33. #endregion
  34. #region Trigger effect of [Blitz]
  35. public static ActivateClass BlitzEffect(
  36. Permanent targetPermanent,
  37. bool isInheritedEffect,
  38. Func<bool> condition,
  39. bool isWhenDigivolving,
  40. ICardEffect rootCardEffect,
  41. CardSource card,
  42. Func<IEnumerator> beforeOnAttackCoroutine = null)
  43. {
  44. if (targetPermanent == null) return null;
  45. if (targetPermanent.TopCard == null) return null;
  46. if (card == null) return null;
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("Blitz", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  50. activateClass.SetIsInheritedEffect(isInheritedEffect);
  51. string EffectDiscription()
  52. {
  53. if (isWhenDigivolving)
  54. {
  55. return $"[When Digivolving] {DataBase.BilitzEffectDiscription()}.";
  56. }
  57. else
  58. {
  59. return $"[On Play] {DataBase.BilitzEffectDiscription()}.";
  60. }
  61. }
  62. if (rootCardEffect != null)
  63. {
  64. activateClass.SetIsInheritedEffect(false);
  65. activateClass.SetEffectSourcePermanent(targetPermanent);
  66. activateClass.SetRootCardEffect(rootCardEffect);
  67. }
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. if (isWhenDigivolving)
  71. {
  72. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  73. {
  74. return true;
  75. }
  76. }
  77. else
  78. {
  79. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. if (CardEffectCommons.CanActivateBlitz(targetPermanent.TopCard, activateClass))
  89. {
  90. if (condition == null || condition())
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  98. {
  99. return CardEffectCommons.BlitzProcess(targetPermanent.TopCard, activateClass, beforeOnAttackCoroutine);
  100. }
  101. return activateClass;
  102. }
  103. #endregion
  104. }