Progress.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 Target 1 Digimon gains [Progress]
  9. public static IEnumerator GainProgress(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  10. {
  11. if (targetPermanent == null) yield break;
  12. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  13. if (activateClass == null) yield break;
  14. if (activateClass.EffectSourceCard == null) yield break;
  15. CardSource card = activateClass.EffectSourceCard;
  16. bool CanUseCondition()
  17. {
  18. if (IsPermanentExistsOnBattleArea(targetPermanent))
  19. {
  20. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. CanNotAffectedClass progress = CardEffectFactory.ProgressStaticEffect(isInheritedEffect: false, card: card, condition: CanUseCondition);
  28. AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: progress, timing: EffectTiming.None);
  29. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  30. {
  31. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  32. }
  33. }
  34. #endregion
  35. #region Can activate [Progress]
  36. public static bool CanActivateProgress(CardSource cardSource)
  37. {
  38. if (IsExistOnBattleAreaDigimon(cardSource))
  39. {
  40. if (GManager.instance.attackProcess.IsAttacking)
  41. {
  42. if (GManager.instance.attackProcess.AttackingPermanent == cardSource.PermanentOfThisCard())
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. #endregion
  51. #region Effect process of [Progress]
  52. public static IEnumerator ProgressProcess(CardSource cardSource, ICardEffect activateClass, Func<IEnumerator> beforeOnAttackCoroutine = null)
  53. {
  54. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  55. if (CanActivateProgress(cardSource))
  56. {
  57. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  58. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effect", CanUseCondition1, cardSource);
  59. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  60. selectedPermanent.UntilEndAttackEffects.Add((_timing) => canNotAffectedClass);
  61. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  62. bool CanUseCondition1(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  65. }
  66. bool CardCondition(CardSource cardSource)
  67. {
  68. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  69. {
  70. if (cardSource == selectedPermanent.TopCard)
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. bool SkillCondition(ICardEffect cardEffect)
  78. {
  79. if (cardEffect != null)
  80. {
  81. if (cardEffect.EffectSourceCard != null)
  82. {
  83. if (IsOpponentEffect(cardEffect,cardSource))
  84. {
  85. return true;
  86. }
  87. }
  88. }
  89. return false;
  90. }
  91. }
  92. }
  93. #endregion
  94. }