BT8_040.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 BT8_040 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1 card from hand to get colors and draw 2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may trash 1 card in your hand to treat this Digimon as also having the colors of the trashed card for the turn. Then, if this Digimon has 2 or more colors, <Draw 2>. (Draw 2 cards from your deck.)";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.HandCards.Count >= 1)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (isExistOnField(card))
  41. {
  42. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  43. {
  44. if (card.Owner.HandCards.Count >= 1)
  45. {
  46. bool discarded = false;
  47. CardSource discardedCard = null;
  48. int discardCount = 1;
  49. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  50. selectHandEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: (cardSource) => true,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: discardCount,
  56. canNoSelect: true,
  57. canEndNotMax: false,
  58. isShowOpponent: true,
  59. selectCardCoroutine: null,
  60. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  61. mode: SelectHandEffect.Mode.Discard,
  62. cardEffect: activateClass);
  63. yield return StartCoroutine(selectHandEffect.Activate());
  64. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  65. {
  66. if (cardSources.Count >= 1)
  67. {
  68. discarded = true;
  69. yield return null;
  70. if (cardSources.Count == 1)
  71. {
  72. discardedCard = cardSources[0];
  73. }
  74. }
  75. }
  76. if (discarded)
  77. {
  78. if (discardedCard != null)
  79. {
  80. List<CardColor> cardColors = new List<CardColor>();
  81. foreach (CardColor cardColor in discardedCard.CardColors)
  82. {
  83. cardColors.Add(cardColor);
  84. }
  85. Permanent selectedPermanent = card.PermanentOfThisCard();
  86. if (cardColors.Count >= 1)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  89. foreach (CardColor cardColor in cardColors)
  90. {
  91. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  92. changeCardColorClass.SetUpICardEffect($"Also treated as {DataBase.CardColorNameDictionary[cardColor]}", CanUseCondition1, card);
  93. changeCardColorClass.SetUpChangeCardColorClass(ChangeCardColors: ChangeCardColors);
  94. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => changeCardColorClass);
  95. bool CanUseCondition1(Hashtable hashtable)
  96. {
  97. if (selectedPermanent.TopCard != null)
  98. {
  99. return true;
  100. }
  101. return false;
  102. }
  103. List<CardColor> ChangeCardColors(CardSource cardSource, List<CardColor> CardColors)
  104. {
  105. if (cardSource == selectedPermanent.TopCard)
  106. {
  107. CardColors.Add(cardColor);
  108. }
  109. return CardColors;
  110. }
  111. }
  112. }
  113. if (selectedPermanent.TopCard.CardColors.Count >= 2)
  114. {
  115. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. return cardEffects;
  125. }
  126. }