Save.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 activate [Save]
  9. public static bool CanActivateSave(Hashtable hashtable, Func<Permanent, bool> CanSelectPermanentCondition)
  10. {
  11. if (IsTopCardInTrashOnDeletion(hashtable))
  12. {
  13. if (HasMatchConditionPermanent(CanSelectPermanentCondition))
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Save]
  22. public static IEnumerator SaveProcess(Hashtable hashtable, ICardEffect activateClass, CardSource card, Func<Permanent, bool> CanSelectPermanentCondition)
  23. {
  24. if (!CanActivateSave(hashtable, CanSelectPermanentCondition)) yield break;
  25. int maxCount = Math.Min(1, MatchConditionPermanentCount(CanSelectPermanentCondition));
  26. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  27. selectPermanentEffect.SetUp(
  28. selectPlayer: card.Owner,
  29. canTargetCondition: CanSelectPermanentCondition,
  30. canTargetCondition_ByPreSelecetedList: null,
  31. canEndSelectCondition: null,
  32. maxCount: maxCount,
  33. canNoSelect: true,
  34. canEndNotMax: false,
  35. selectPermanentCoroutine: SelectPermanentCoroutine,
  36. afterSelectPermanentCoroutine: null,
  37. mode: SelectPermanentEffect.Mode.Custom,
  38. cardEffect: activateClass);
  39. selectPermanentEffect.SetUpCustomMessage(customMessageArray: customPermanentMessageArrayTemplate(customText: "that will get a digivolution card", maxCount: 1, CanSelectDigimon: false, CanSelectTamer: true));
  40. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  41. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  42. {
  43. Permanent selectedPermanent = permanent;
  44. if (selectedPermanent != null)
  45. {
  46. if (card.Owner.TrashHandCard.gameObject.activeSelf)
  47. {
  48. card.Owner.TrashHandCard.gameObject.SetActive(false);
  49. }
  50. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  51. }
  52. }
  53. }
  54. #endregion
  55. }