Evade.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 [Evade]
  9. public static bool CanTriggerEvade(Hashtable hashtable, Permanent targetPermanent)
  10. {
  11. if (IsPermanentExistsOnBattleArea(targetPermanent))
  12. {
  13. if (CanTriggerWhenPermanentRemoveField(hashtable, permanent => permanent == targetPermanent))
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Can activate [Evade]
  22. public static bool CanActivateEvade(Permanent targetPermanent)
  23. {
  24. if (IsPermanentExistsOnBattleArea(targetPermanent))
  25. {
  26. if (CanActivatePermanentSuspendCostEffect(targetPermanent))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. #endregion
  34. #region Effect process of [Evade]
  35. public static IEnumerator EvadeProcess(Permanent targetPermanent, ICardEffect activateClass)
  36. {
  37. if (IsPermanentExistsOnBattleArea(targetPermanent))
  38. {
  39. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { targetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  40. targetPermanent.willBeRemoveField = false;
  41. targetPermanent.HideDeleteEffect();
  42. }
  43. }
  44. #endregion
  45. #region Target 1 Digimon gains [Evade]
  46. public static IEnumerator GainEvade(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  47. {
  48. if (targetPermanent == null) yield break;
  49. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  50. if (activateClass == null) yield break;
  51. if (activateClass.EffectSourceCard == null) yield break;
  52. CardSource card = activateClass.EffectSourceCard;
  53. bool CanUseCondition()
  54. {
  55. if (IsPermanentExistsOnBattleArea(targetPermanent))
  56. {
  57. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. ActivateClass evade = CardEffectFactory.EvadeEffect(targetPermanent: targetPermanent, isInheritedEffect: false, condition: CanUseCondition, rootCardEffect: activateClass, targetPermanent.TopCard);
  65. AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: evade, timing: EffectTiming.WhenPermanentWouldBeDeleted);
  66. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  69. }
  70. }
  71. #endregion
  72. }