Progress.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectFactory
  7. {
  8. #region Static effect of [Progress] on oneself
  9. public static CanNotAffectedClass ProgressSelfStaticEffect(bool isInheritedEffect, CardSource card, Func<bool> condition)
  10. {
  11. bool CanUseCondition()
  12. {
  13. return CardEffectCommons.CanActivateProgress(card) &&
  14. (condition == null || condition());
  15. }
  16. return ProgressStaticEffect(isInheritedEffect: isInheritedEffect, card: card, condition: CanUseCondition);
  17. }
  18. #endregion
  19. #region Static effect of [Progress]
  20. public static CanNotAffectedClass ProgressStaticEffect(
  21. bool isInheritedEffect,
  22. CardSource card,
  23. Func<bool> condition)
  24. {
  25. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  26. canNotAffectedClass.SetUpICardEffect("Progress", CanUseCondition, card);
  27. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  28. canNotAffectedClass.SetIsInheritedEffect(isInheritedEffect);
  29. canNotAffectedClass.SetIsBackgroundProcess(true);
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. if (condition == null || condition())
  33. {
  34. return true;
  35. }
  36. return false;
  37. }
  38. bool CardCondition(CardSource cardSource)
  39. {
  40. if (CardEffectCommons.IsExistOnBattleArea(card))
  41. {
  42. if (cardSource == card)
  43. {
  44. if (GManager.instance.attackProcess.IsAttacking)
  45. {
  46. if (GManager.instance.attackProcess.AttackingPermanent == cardSource.PermanentOfThisCard())
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool SkillCondition(ICardEffect cardEffect)
  56. {
  57. if (cardEffect != null)
  58. {
  59. if (cardEffect.EffectSourceCard != null)
  60. {
  61. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. return canNotAffectedClass;
  70. }
  71. #endregion
  72. }