Barrier.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. yield return ContinuousController.instance.StartCoroutine(new BarrierClass(permanent, activateClass).Barrier());
  25. }
  26. #endregion
  27. #region Barrier class
  28. public class BarrierClass
  29. {
  30. public BarrierClass(Permanent permanent, ICardEffect cardEffect)
  31. {
  32. _permanent = permanent;
  33. _cardEffect = cardEffect;
  34. }
  35. Permanent _permanent = null;
  36. ICardEffect _cardEffect = null;
  37. public IEnumerator Barrier()
  38. {
  39. if (_permanent != null)
  40. {
  41. if (_permanent.TopCard != null)
  42. {
  43. CardSource topCard = _permanent.TopCard;
  44. if (topCard.Owner.SecurityCards.Count >= 1)
  45. {
  46. _permanent.ShowDeleteEffect();
  47. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  48. player: topCard.Owner,
  49. destroySecurityCount: 1,
  50. cardEffect: _cardEffect,
  51. fromTop: true).DestroySecurity());
  52. _permanent.willBeRemoveField = false;
  53. _permanent.HideDeleteEffect();
  54. #region log
  55. string log = "";
  56. log += $"\nBarrier :";
  57. log += $"\n{topCard.BaseENGCardNameFromEntity}({topCard.CardID})";
  58. log += "\n";
  59. GManager.instance.playLog.AddLogString(log);
  60. #endregion
  61. }
  62. }
  63. }
  64. }
  65. }
  66. #endregion
  67. }