P_012.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class P_012 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Draw 1 or your 1 Digimon gains DP +1000", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] If you have a Digimon with [Veedramon] in its name, you may suspend this Tamer to activate one of the following effects: - Trigger <Draw 1>. (Draw 1 card from your deck. - 1 of your Digimon gets +1000 DP for the turn.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (isExistOnField(card))
  26. {
  27. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  28. {
  29. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.ContainsCardName("Veedramon")))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  38. {
  39. if (isExistOnField(card))
  40. {
  41. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  42. {
  43. Hashtable hashtable = new Hashtable();
  44. hashtable.Add("CardEffect", activateClass);
  45. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, hashtable).Tap());
  46. yield return GManager.instance.photonWaitController.StartWait("Taichi_Select");
  47. if (card.Owner.isYou)
  48. {
  49. GManager.instance.commandText.OpenCommandText("Which effect will you activate?");
  50. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  51. {
  52. new Command_SelectCommand($"Draw 1", () => photonView.RPC("SetActionID", RpcTarget.All, 0), 0),
  53. new Command_SelectCommand($"DP +1000", () => photonView.RPC("SetActionID", RpcTarget.All, 1), 0),
  54. };
  55. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  56. }
  57. else
  58. {
  59. GManager.instance.commandText.OpenCommandText("The opponent is choosing which effect to activate.");
  60. #region AIƒ‚�[ƒh
  61. if (GManager.instance.IsAI)
  62. {
  63. SetActionID(UnityEngine.Random.Range(0, 2));
  64. }
  65. #endregion
  66. }
  67. yield return new WaitWhile(() => !endSelect);
  68. endSelect = false;
  69. GManager.instance.commandText.CloseCommandText();
  70. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  71. switch (actionID)
  72. {
  73. case 0:
  74. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  75. break;
  76. case 1:
  77. bool CanSelectPermanentCondition(Permanent permanent)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  80. }
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  82. {
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectPermanentCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP +1000.", "The opponent is selecting 1 Digimon that will get DP +1000.");
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: 1000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  102. }
  103. }
  104. break;
  105. }
  106. }
  107. }
  108. }
  109. }
  110. if (timing == EffectTiming.SecuritySkill)
  111. {
  112. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  113. }
  114. return cardEffects;
  115. }
  116. bool endSelect = false;
  117. int actionID = -1;
  118. [PunRPC]
  119. public void SetActionID(int actionID)
  120. {
  121. this.actionID = actionID;
  122. endSelect = true;
  123. }
  124. }