Progress.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  15. return ProgressStaticEffect(isInheritedEffect: isInheritedEffect, card: card, condition: CanUseCondition);
  16. }
  17. #endregion
  18. #region Static effect of [Progress]
  19. public static CanNotAffectedClass ProgressStaticEffect(
  20. bool isInheritedEffect,
  21. CardSource card,
  22. Func<bool> condition)
  23. {
  24. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  25. canNotAffectedClass.SetUpICardEffect("Progress", CanUseCondition, card);
  26. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  27. canNotAffectedClass.SetIsInheritedEffect(isInheritedEffect);
  28. canNotAffectedClass.SetIsBackgroundProcess(true);
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. if (condition == null || condition())
  32. {
  33. return true;
  34. }
  35. return false;
  36. }
  37. bool CardCondition(CardSource cardSource)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (cardSource == card)
  42. {
  43. if (GManager.instance.attackProcess.IsAttacking)
  44. {
  45. if (GManager.instance.attackProcess.AttackingPermanent == cardSource.PermanentOfThisCard())
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool SkillCondition(ICardEffect cardEffect)
  55. {
  56. if (cardEffect != null)
  57. {
  58. if (cardEffect.EffectSourceCard != null)
  59. {
  60. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. return canNotAffectedClass;
  69. }
  70. #endregion
  71. }