ChangeSAttack.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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 Change target 1 Digimon's SAttack
  9. public static IEnumerator ChangeDigimonSAttack(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass)
  10. {
  11. if (targetPermanent == null) yield break;
  12. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  13. if (changeValue == 0) yield break;
  14. if (activateClass == null) yield break;
  15. if (activateClass.EffectSourceCard == null) yield break;
  16. CardSource card = activateClass.EffectSourceCard;
  17. bool isUpValue = changeValue > 0;
  18. bool CanUseCondition()
  19. {
  20. if (IsPermanentExistsOnBattleArea(targetPermanent))
  21. {
  22. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  23. {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. ChangeSAttackClass changeSAttackClass = CardEffectFactory.ChangeTargetSAttackStaticEffect(
  30. targetPermanent: targetPermanent,
  31. changeValue: changeValue,
  32. isInheritedEffect: false,
  33. card: card,
  34. condition: CanUseCondition);
  35. AddEffectToPermanent(
  36. targetPermanent: targetPermanent,
  37. effectDuration: effectDuration,
  38. card: card,
  39. cardEffect: changeSAttackClass,
  40. timing: EffectTiming.None);
  41. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  42. {
  43. if (isUpValue)
  44. {
  45. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  46. }
  47. else
  48. {
  49. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  50. }
  51. }
  52. }
  53. public static IEnumerator ChangeDigimonSAttack(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass, bool activateAnimation, string hashstring = null)
  54. {
  55. if (targetPermanent == null) yield break;
  56. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  57. if (changeValue == 0) yield break;
  58. if (activateClass == null) yield break;
  59. if (activateClass.EffectSourceCard == null) yield break;
  60. CardSource card = activateClass.EffectSourceCard;
  61. bool isUpValue = changeValue > 0;
  62. bool CanUseCondition()
  63. {
  64. if (IsPermanentExistsOnBattleArea(targetPermanent))
  65. {
  66. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. ChangeSAttackClass changeSAttackClass = CardEffectFactory.ChangeTargetSAttackStaticEffect(
  74. targetPermanent: targetPermanent,
  75. changeValue: changeValue,
  76. isInheritedEffect: false,
  77. card: card,
  78. condition: CanUseCondition,
  79. hashstring: hashstring);
  80. AddEffectToPermanent(
  81. targetPermanent: targetPermanent,
  82. effectDuration: effectDuration,
  83. card: card,
  84. cardEffect: changeSAttackClass,
  85. timing: EffectTiming.None);
  86. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  87. {
  88. if (isUpValue)
  89. {
  90. if (activateAnimation)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  93. }
  94. }
  95. else
  96. {
  97. if (activateAnimation)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  100. }
  101. }
  102. }
  103. }
  104. #endregion
  105. #region Invert target 1 Digimon's SAttack
  106. public static IEnumerator InverteDigimonSAttack(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass)
  107. {
  108. if (targetPermanent == null) yield break;
  109. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  110. if (changeValue == 0) yield break;
  111. if (activateClass == null) yield break;
  112. if (activateClass.EffectSourceCard == null) yield break;
  113. CardSource card = activateClass.EffectSourceCard;
  114. bool isUpValue = changeValue > 0;
  115. bool CanUseCondition()
  116. {
  117. if (IsPermanentExistsOnBattleArea(targetPermanent))
  118. {
  119. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  120. {
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. InvertSAttackClass invertSAttackClass = CardEffectFactory.InvertTargetSAttackStaticEffect(
  127. targetPermanent: targetPermanent,
  128. changeValue: changeValue,
  129. isInheritedEffect: false,
  130. card: card,
  131. condition: CanUseCondition);
  132. AddEffectToPermanent(
  133. targetPermanent: targetPermanent,
  134. effectDuration: effectDuration,
  135. card: card,
  136. cardEffect: invertSAttackClass,
  137. timing: EffectTiming.None);
  138. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  139. {
  140. if (!isUpValue)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  143. }
  144. else
  145. {
  146. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  147. }
  148. }
  149. }
  150. public static IEnumerator InvertDigimonSAttack(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass, bool activateAnimation)
  151. {
  152. if (targetPermanent == null) yield break;
  153. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  154. if (changeValue == 0) yield break;
  155. if (activateClass == null) yield break;
  156. if (activateClass.EffectSourceCard == null) yield break;
  157. CardSource card = activateClass.EffectSourceCard;
  158. bool isUpValue = changeValue > 0;
  159. bool CanUseCondition()
  160. {
  161. if (IsPermanentExistsOnBattleArea(targetPermanent))
  162. {
  163. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  164. {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170. InvertSAttackClass invertSAttackClass = CardEffectFactory.InvertTargetSAttackStaticEffect(
  171. targetPermanent: targetPermanent,
  172. changeValue: changeValue,
  173. isInheritedEffect: false,
  174. card: card,
  175. condition: CanUseCondition);
  176. AddEffectToPermanent(
  177. targetPermanent: targetPermanent,
  178. effectDuration: effectDuration,
  179. card: card,
  180. cardEffect: invertSAttackClass,
  181. timing: EffectTiming.None);
  182. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  183. {
  184. if (activateAnimation)
  185. {
  186. if (!isUpValue)
  187. {
  188. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  189. }
  190. else
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  193. }
  194. }
  195. }
  196. }
  197. #endregion
  198. }