Ascension.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can Trigger [Ascension]
  9. public static bool CanTriggerAscension(Hashtable hashtable, CardSource card)
  10. {
  11. return CanTriggerOnDeletion(hashtable, card);
  12. }
  13. public static bool CanTriggerPermanentAscension(Hashtable hashtable, Func<Permanent, bool> permanentCondition)
  14. {
  15. return CanTriggerOnPermanentDeleted(hashtable, permanentCondition);
  16. }
  17. #endregion
  18. #region Can activate [Ascension]
  19. public static bool CanActivateAscension(Hashtable hashtable, CardSource card)
  20. {
  21. return CanActivateOnDeletion(card);
  22. }
  23. #endregion
  24. #region Effect process of [Ascension]
  25. public static IEnumerator AscensionProcess(Hashtable hashtable, ICardEffect activateClass, CardSource card)
  26. {
  27. if (card.Owner.CanAddSecurity(activateClass))
  28. {
  29. string selectPlayerMessage = "Will you place this card in security?";
  30. string notSelectPlayerMessage = "The opponent is choosing if they will use Ascension.";
  31. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  32. {
  33. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  34. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  35. };
  36. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  37. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  38. if(GManager.instance.userSelectionManager.SelectedBoolValue)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, true));
  41. }
  42. }
  43. }
  44. #endregion
  45. #region Target 1 Digimon gains [Ascension]
  46. public static IEnumerator GainAscension(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
  47. {
  48. if (targetPermanent == null) yield break;
  49. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  50. if (activateClass == null) yield break;
  51. if (activateClass.EffectSourceCard == null) yield break;
  52. CardSource card = activateClass.EffectSourceCard;
  53. bool CanUseCondition()
  54. {
  55. if (IsPermanentExistsOnBattleArea(targetPermanent))
  56. {
  57. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. ActivateClass ascension = CardEffectFactory.AscensionEffect(
  65. targetPermanent: targetPermanent,
  66. isInheritedEffect: false,
  67. condition: CanUseCondition,
  68. rootCardEffect: activateClass,
  69. card: activateClass.EffectSourceCard);
  70. AddEffectToPermanent(
  71. targetPermanent: targetPermanent,
  72. effectDuration: effectDuration,
  73. card: card,
  74. cardEffect: ascension,
  75. timing: EffectTiming.OnDestroyedAnyone);
  76. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
  79. }
  80. }
  81. #endregion
  82. }