Pierce.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 trigger [Pierce]
  9. public static bool CanTriggerPierce(Hashtable hashtable, Permanent piercePermanent)
  10. {
  11. if (piercePermanent == null) return false;
  12. if (piercePermanent.TopCard == null) return false;
  13. return CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: (permanent) => permanent.cardSources.Contains(piercePermanent.TopCard), loserCondition: (permanent) => IsOpponentPermanent(permanent, piercePermanent.TopCard), isOnlyWinnerSurvive: true);
  14. }
  15. #endregion
  16. #region Can activate [Pierce]
  17. public static bool CanActivatePierce(Permanent permanent)
  18. {
  19. if (permanent == null) return false;
  20. if (permanent.TopCard == null) return false;
  21. if (GManager.instance.attackProcess.AttackingPermanent == null) return false;
  22. if (GManager.instance.attackProcess.AttackingPermanent.TopCard == null) return false;
  23. if (IsPermanentExistsOnBattleArea(permanent))
  24. {
  25. if (permanent.TopCard.Owner.Enemy.SecurityCards.Count >= 1)
  26. {
  27. if (GManager.instance.attackProcess.AttackingPermanent.cardSources.Contains(permanent.TopCard))
  28. {
  29. if (!GManager.instance.attackProcess.DoSecurityCheck)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. #endregion
  39. #region Effect process of [Pierce]
  40. public static IEnumerator PierceProcess()
  41. {
  42. GManager.instance.attackProcess.DoSecurityCheck = true;
  43. yield return null;
  44. }
  45. #endregion
  46. #region Target 1 Digimon gains [Pierce]
  47. public static IEnumerator GainPierce(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  48. {
  49. if (targetPermanent == null) yield break;
  50. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  51. if (activateClass == null) yield break;
  52. if (activateClass.EffectSourceCard == null) yield break;
  53. CardSource card = activateClass.EffectSourceCard;
  54. bool CanUseCondition()
  55. {
  56. if (IsPermanentExistsOnBattleArea(targetPermanent))
  57. {
  58. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. ActivateClass pierce = CardEffectFactory.PierceEffect(targetPermanent: targetPermanent, isInheritedEffect: false, condition: CanUseCondition, rootCardEffect: activateClass, targetPermanent.TopCard);
  66. AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: pierce, timing: EffectTiming.OnDetermineDoSecurityCheck);
  67. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  70. }
  71. }
  72. #endregion
  73. }