ChangePlayCost.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. using System.Runtime.CompilerServices;
  7. public partial class CardEffectCommons
  8. {
  9. #region Player gains effect to change play cost
  10. public static IEnumerator ChangePlayCostPlayerEffect(
  11. Func<Permanent, bool> permanentCondition,
  12. int changeValue,
  13. bool setFixedCost,
  14. EffectDuration effectDuration,
  15. ICardEffect activateClass)
  16. {
  17. if (activateClass == null) yield break;
  18. if (activateClass.EffectSourceCard == null) yield break;
  19. if (changeValue == 0) yield break;
  20. bool PermanentCondition(Permanent permanent)
  21. {
  22. if (IsPermanentExistsOnBattleArea(permanent))
  23. {
  24. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  25. {
  26. if (permanentCondition == null || permanentCondition(permanent))
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition()
  35. {
  36. return true;
  37. }
  38. ChangeCostClass changeCostClass = CardEffectFactory.ChangePlayCostStaticEffect(
  39. changeValue: changeValue,
  40. permanentCondition: PermanentCondition,
  41. isInheritedEffect: false,
  42. card: activateClass.EffectSourceCard,
  43. condition: CanUseCondition,
  44. setFixedCost: setFixedCost);
  45. AddEffectToPlayer(effectDuration: effectDuration, card: activateClass.EffectSourceCard, cardEffect: changeCostClass, timing: EffectTiming.None);
  46. foreach (Permanent permanent in GManager.instance.turnStateMachine.gameContext.PermanentsForTurnPlayer)
  47. {
  48. if (PermanentCondition(permanent))
  49. {
  50. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  51. }
  52. }
  53. }
  54. #endregion
  55. }