OptionalSkill.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Photon;
  5. using Photon.Pun;
  6. using System.Linq;
  7. using System;
  8. public class OptionalSkill : MonoBehaviourPunCallbacks
  9. {
  10. public string waitingText { get; set; } = "The opponent is considering whether to use the effect.";
  11. bool _endSelect = false;
  12. bool _useOptional = false;
  13. public IEnumerator SelectOptional(ICardEffect cardEffect, Hashtable hash)
  14. {
  15. List<string> _YesNoTexts = new List<string>() { "Use", "Not use" };
  16. _endSelect = false;
  17. _useOptional = false;
  18. string _Message;
  19. List<Permanent> effectTargets = cardEffect.EffectTargets != null ? cardEffect.EffectTargets(hash) : null;
  20. if (effectTargets == null || effectTargets.Count == 0)
  21. {
  22. _Message = $"Will you use \"{cardEffect.EffectName}\"?";
  23. }
  24. else
  25. {
  26. _Message = $"Will you use \"{cardEffect.EffectName}\" targetting {string.Join(", ", effectTargets.Select(permanent => permanent.TopCard.CardNames[0]))}?";
  27. }
  28. yield return GManager.instance.photonWaitController.StartWait("SelectOptional");
  29. #region ƒgƒ‰ƒbƒVƒ…‚̃J[ƒh‚ð•\ަ
  30. if (cardEffect != null)
  31. {
  32. if (cardEffect.EffectSourceCard != null)
  33. {
  34. if (cardEffect.EffectSourceCard.Owner.TrashCards.Contains(cardEffect.EffectSourceCard) || cardEffect.EffectSourceCard.Owner.LostCards.Contains(cardEffect.EffectSourceCard))
  35. {
  36. if (cardEffect.EffectSourceCard.Owner.TrashHandCard != null)
  37. {
  38. if (!cardEffect.EffectSourceCard.Owner.TrashHandCard.gameObject.activeSelf)
  39. {
  40. cardEffect.EffectSourceCard.Owner.TrashHandCard.gameObject.SetActive(true);
  41. cardEffect.EffectSourceCard.Owner.TrashHandCard.SetUpHandCard(cardEffect.EffectSourceCard);
  42. cardEffect.EffectSourceCard.Owner.TrashHandCard.SetUpHandCardImage();
  43. cardEffect.EffectSourceCard.Owner.TrashHandCard.OnOutline();
  44. cardEffect.EffectSourceCard.Owner.TrashHandCard.SetBlueOutline();
  45. cardEffect.EffectSourceCard.Owner.TrashHandCard.transform.localScale = new Vector3(1.4f, 1.4f, 1.4f);
  46. }
  47. }
  48. }
  49. }
  50. }
  51. #endregion
  52. if (cardEffect.EffectSourceCard.Owner.isYou)
  53. {
  54. Permanent permanent = cardEffect.EffectSourceCard.PermanentOfThisCard();
  55. List<FieldPermanentCard> highlightPermanents = new List<FieldPermanentCard>();
  56. if (permanent != null)
  57. {
  58. if (permanent.ShowingPermanentCard != null)
  59. {
  60. highlightPermanents.Add(permanent.ShowingPermanentCard);
  61. }
  62. }
  63. if (effectTargets != null)
  64. {
  65. foreach (Permanent targetPermanent in effectTargets)
  66. {
  67. if (targetPermanent.ShowingPermanentCard != null)
  68. {
  69. highlightPermanents.Add(targetPermanent.ShowingPermanentCard);
  70. }
  71. }
  72. }
  73. if (highlightPermanents.Count > 0)
  74. {
  75. GManager.instance.hideCannotSelectObject.SetUpHideCannotSelectObject(highlightPermanents, false);
  76. }
  77. GManager.instance.commandText.OpenCommandText(_Message);
  78. List<Command_SelectCommand> commands = new List<Command_SelectCommand>()
  79. {
  80. new Command_SelectCommand(_YesNoTexts[0] ,() => photonView.RPC("SetUseOptional",RpcTarget.All,true),0),
  81. };
  82. GManager.instance.BackButton.OpenSelectCommandButton(_YesNoTexts[1], () => { photonView.RPC("SetUseOptional", RpcTarget.All, false); }, 0);
  83. GManager.instance.selectCommandPanel.SetUpCommandButton(commands);
  84. }
  85. else
  86. {
  87. bool ShowOpponentMessage = cardEffect.EffectDiscription.Contains("[Hand]") && GManager.instance.autoProcessing.executingMultipleSkills != null && !GManager.instance.autoProcessing.executingMultipleSkills.IsOnlyHandEffectStacked;
  88. if (ShowOpponentMessage)
  89. {
  90. GManager.instance.commandText.OpenCommandText(waitingText);
  91. }
  92. if (GManager.instance.IsAI)
  93. {
  94. _endSelect = true;
  95. _useOptional = RandomUtility.IsSucceedProbability(0.9f);
  96. }
  97. }
  98. yield return new WaitWhile(() => !_endSelect);
  99. _endSelect = false;
  100. GManager.instance.selectCommandPanel.Off();
  101. GManager.instance.BackButton.CloseSelectCommandButton();
  102. GManager.instance.hideCannotSelectObject.Close();
  103. GManager.instance.commandText.CloseCommandText();
  104. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  105. cardEffect.SetUseOptional(_useOptional);
  106. cardEffect.EffectSourceCard.Owner.TrashHandCard.gameObject.SetActive(false);
  107. }
  108. [PunRPC]
  109. public void SetUseOptional(bool useOptional)
  110. {
  111. _useOptional = useOptional;
  112. _endSelect = true;
  113. }
  114. }