Link_Examples.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.Examples
  5. {
  6. public class Link_Examples : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Basic link effect keyword
  12. if (timing == EffectTiming.OnDeclaration)
  13. {
  14. cardEffects.Add(CardEffectFactory.LinkEffect(card, 1, 2000));
  15. }
  16. #endregion
  17. #region When Linked Example, Specifically When THIS card is added as a linked card
  18. if (timing == EffectTiming.WhenLinked)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Testing When Linking", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  23. activateClass.SetIsLinkedEffect(true);
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[When linked] Testing When linking";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. return isExistOnField(card);
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  38. {
  39. UnityEngine.Debug.Log("CARD SUCCESSFULLY LINKED");
  40. yield return null;
  41. }
  42. }
  43. #endregion
  44. #region When Linked Example, When A card is linked at all
  45. if (timing == EffectTiming.WhenLinked)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("Testing When Linked", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[Your Turn] When this Digimon gets linked";
  54. }
  55. bool PermanentCondition(Permanent permanent)
  56. {
  57. return permanent == card.PermanentOfThisCard();
  58. }
  59. bool CardCondition(CardSource source)
  60. {
  61. return true;
  62. }
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, CardCondition);
  66. }
  67. bool CanActivateCondition(Hashtable hashtable)
  68. {
  69. return isExistOnField(card);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. UnityEngine.Debug.Log("CARD LINKED");
  74. yield return null;
  75. }
  76. }
  77. #endregion
  78. #region Trash 1 Link card
  79. if (timing == EffectTiming.OnStartMainPhase)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  84. cardEffects.Add(activateClass);
  85. string EffectDiscription()
  86. {
  87. return "";
  88. }
  89. bool CanSelectPermanentCondition(Permanent permanent)
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  92. {
  93. if (permanent.LinkedCards.Map(link => link.Source).Count(CanSelectCardCondition) >= 1)
  94. {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. bool CanSelectCardCondition(CardSource cardSource)
  101. {
  102. return true;
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.IsExistOnBattleArea(card))
  107. {
  108. if (CardEffectCommons.IsOwnerTurn(card))
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.IsExistOnBattleArea(card))
  118. {
  119. return true;
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashLinkedCards(
  126. permanentCondition: CanSelectPermanentCondition,
  127. cardCondition: CanSelectCardCondition,
  128. maxCount: 1,
  129. canNoTrash: false,
  130. isFromOnly1Permanent: true,
  131. activateClass: activateClass
  132. ));
  133. }
  134. }
  135. #endregion
  136. #region Change Link Max Count
  137. if (timing == EffectTiming.None)
  138. {
  139. bool Condition()
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. return true;
  144. }
  145. return false;
  146. }
  147. cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(
  148. changeValue: 1,
  149. isInheritedEffect: true,
  150. card: card,
  151. condition: Condition));
  152. }
  153. return cardEffects;
  154. }
  155. #endregion
  156. }
  157. }