Progress.cs 4.0 KB

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