Barrier.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 [Barrier]
  9. public static bool CanActivateBarrier(Permanent permanent)
  10. {
  11. if (IsPermanentExistsOnBattleArea(permanent))
  12. {
  13. if (permanent.TopCard.Owner.SecurityCards.Count >= 1)
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Barrier]
  22. public static IEnumerator BarrierProcess(Permanent permanent, ICardEffect activateClass)
  23. {
  24. if (permanent != null)
  25. {
  26. if (permanent.TopCard != null)
  27. {
  28. CardSource topCard = permanent.TopCard;
  29. if (topCard.Owner.SecurityCards.Count >= 1)
  30. {
  31. permanent.ShowDeleteEffect();
  32. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  33. player: topCard.Owner,
  34. destroySecurityCount: 1,
  35. cardEffect: activateClass,
  36. fromTop: true).DestroySecurity());
  37. permanent.willBeRemoveField = false;
  38. permanent.HideDeleteEffect();
  39. #region log
  40. string log = "";
  41. log += $"\nBarrier :";
  42. log += $"\n{topCard.BaseENGCardNameFromEntity}({topCard.CardID})";
  43. log += "\n";
  44. PlayLog.OnAddLog?.Invoke(log);
  45. #endregion
  46. }
  47. }
  48. }
  49. }
  50. #endregion
  51. #region Target 1 Digimon gains [Barrier]
  52. public static IEnumerator GainBarrier(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  53. {
  54. if (targetPermanent == null) yield break;
  55. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  56. if (activateClass == null) yield break;
  57. if (activateClass.EffectSourceCard == null) yield break;
  58. CardSource card = activateClass.EffectSourceCard;
  59. bool CanUseCondition()
  60. {
  61. if (IsPermanentExistsOnBattleArea(targetPermanent))
  62. {
  63. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. ActivateClass retaliation = CardEffectFactory.BarrierEffect(
  71. targetPermanent: targetPermanent,
  72. isInheritedEffect: false,
  73. condition: CanUseCondition,
  74. rootCardEffect: activateClass,
  75. card: targetPermanent.TopCard);
  76. AddEffectToPermanent(
  77. targetPermanent: targetPermanent,
  78. effectDuration: effectDuration,
  79. card: card,
  80. cardEffect: retaliation,
  81. timing: EffectTiming.WhenPermanentWouldBeDeleted);
  82. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  85. }
  86. }
  87. #endregion
  88. }