BT9_034.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 BT9_034 : 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.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Salamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Look at the top card of your Security", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] Look at the top card of your security stack, and you may add it to your hand. If you do, <Recovery +1 (Deck)>. (Place the top card of your deck on top of your security stack.)";
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (card.Owner.SecurityCards.Count >= 1)
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  47. {
  48. if (card.Owner.SecurityCards.Count >= 1)
  49. {
  50. List<CardSource> topCards = new List<CardSource>();
  51. for (int i = 0; i < 1; i++)
  52. {
  53. if (card.Owner.SecurityCards.Count > i)
  54. {
  55. topCards.Add(card.Owner.SecurityCards[i]);
  56. }
  57. }
  58. if (topCards.Count >= 1)
  59. {
  60. if (card.Owner.isYou)
  61. {
  62. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(topCards, "Security Top Card", true, true));
  63. }
  64. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  65. {
  66. new SelectionElement<bool>(message: $"Add to hand", value : true, spriteIndex: 0),
  67. new SelectionElement<bool>(message: $"Not add to hand", value : false, spriteIndex: 1),
  68. };
  69. string selectPlayerMessage = "Will you add the card to hand?";
  70. string notSelectPlayerMessage = "The opponent is choosing whether to add the card to hand.";
  71. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. bool addHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  74. if (addHand)
  75. {
  76. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(topCards, false, activateClass));
  77. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  78. player: card.Owner,
  79. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  80. activateClass).ReduceSecurity());
  81. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  82. }
  83. else
  84. {
  85. GManager.instance.commandText.OpenCommandText("The card was not added to hand.");
  86. yield return new WaitForSeconds(0.5f);
  87. GManager.instance.commandText.CloseCommandText();
  88. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. return cardEffects;
  95. }
  96. }