StartOfMainAttack.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Collections;
  2. public partial class CardEffectCommons
  3. {
  4. public static IEnumerator StartOfMainAttack(Permanent targetPermanent, ICardEffect cardEffect)
  5. {
  6. ActivateClass activateClass = new ActivateClass();
  7. activateClass.SetUpICardEffect("Attack with this Digimon", CanUseCondition, targetPermanent.TopCard);
  8. activateClass.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription());
  9. activateClass.SetEffectSourcePermanent(targetPermanent);
  10. targetPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  11. string EffectDiscription()
  12. {
  13. return "[Start of Your Main Phase] Attack with this Digimon.";
  14. }
  15. bool CanUseCondition(Hashtable hashtable1)
  16. {
  17. if (IsPermanentExistsOnBattleArea(targetPermanent))
  18. {
  19. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  20. {
  21. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == targetPermanent.TopCard.Owner)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. bool CanActivateCondition1(Hashtable hashtable1)
  30. {
  31. if (IsPermanentExistsOnBattleArea(targetPermanent))
  32. {
  33. if (!targetPermanent.TopCard.CanNotBeAffected(cardEffect))
  34. {
  35. if (targetPermanent.CanAttack(activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  44. {
  45. if (IsPermanentExistsOnBattleArea(targetPermanent))
  46. {
  47. if (targetPermanent.CanAttack(activateClass))
  48. {
  49. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  50. selectAttackEffect.SetUp(
  51. attacker: targetPermanent,
  52. canAttackPlayerCondition: () => true,
  53. defenderCondition: (permanent) => true,
  54. cardEffect: activateClass);
  55. selectAttackEffect.SetCanNotSelectNotAttack();
  56. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  57. }
  58. }
  59. }
  60. ICardEffect GetCardEffect(EffectTiming _timing)
  61. {
  62. if (_timing == EffectTiming.OnStartMainPhase) return activateClass;
  63. return null;
  64. }
  65. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  66. }
  67. }