SelectCardEffect.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon.Pun;
  6. using System;
  7. public class SelectCardEffect : MonoBehaviourPunCallbacks
  8. {
  9. public void SetUp(
  10. Func<CardSource, bool> canTargetCondition,
  11. Func<List<CardSource>, CardSource, bool> canTargetCondition_ByPreSelecetedList,
  12. Func<List<CardSource>, bool> canEndSelectCondition,
  13. Func<bool> canNoSelect,
  14. Func<CardSource, IEnumerator> selectCardCoroutine,
  15. Func<List<CardSource>, IEnumerator> afterSelectCardCoroutine,
  16. string message,
  17. int maxCount,
  18. bool canEndNotMax,
  19. bool isShowOpponent,
  20. Mode mode,
  21. Root root,
  22. List<CardSource> customRootCardList,
  23. bool canLookReverseCard,
  24. Player selectPlayer,
  25. ICardEffect cardEffect)
  26. {
  27. _canTargetCondition = canTargetCondition;
  28. _canTargetCondition_ByPreSelecetedList = canTargetCondition_ByPreSelecetedList;
  29. _canEndSelectCondition = canEndSelectCondition;
  30. _canNoSelect = canNoSelect;
  31. _selectCardCoroutine = selectCardCoroutine;
  32. _afterSelectCardCoroutine = afterSelectCardCoroutine;
  33. _message = message;
  34. _maxCount = maxCount;
  35. _canEndNotMax = canEndNotMax;
  36. _isShowOpponent = isShowOpponent;
  37. _mode = mode;
  38. _root = root;
  39. _customRootCardList = customRootCardList;
  40. _canLookReverseCard = canLookReverseCard;
  41. _selectPlayer = selectPlayer;
  42. _cardEffect = cardEffect;
  43. _isLocal = false;
  44. _customMessage = null;
  45. _customMessage_Enemy = null;
  46. _customMessage_ShowCard = null;
  47. _customCountText = null;
  48. _showReverseCard = true;
  49. _showCard = true;
  50. _isDigiXros = false;
  51. _isAssembly = false;
  52. _isDeckBottom = false;
  53. _isDeckTop = false;
  54. _notAddLog = false;
  55. _isSecurity = false;
  56. _allowFaceDown = false;
  57. _skillInfos = new List<SkillInfo>();
  58. _afterSelectIndexCoroutine = null;
  59. _endSelect = false;
  60. }
  61. public void SetIsLocal()
  62. {
  63. _isLocal = true;
  64. }
  65. public void SetIsDeckBottom()
  66. {
  67. _isDeckBottom = true;
  68. }
  69. public void SetIsDeckTop()
  70. {
  71. _isDeckTop = true;
  72. }
  73. public void SetNotShowCard()
  74. {
  75. _showCard = false;
  76. }
  77. public void SetNotAddLog()
  78. {
  79. _notAddLog = true;
  80. }
  81. public void SetDigiXros()
  82. {
  83. _isDigiXros = true;
  84. }
  85. public void SetAssembly()
  86. {
  87. _isAssembly = true;
  88. }
  89. public void SetIsSecurity()
  90. {
  91. _isSecurity = true;
  92. }
  93. public void SetUseFaceDown()
  94. {
  95. _allowFaceDown = true;
  96. }
  97. public void SetUpSkillInfos(List<SkillInfo> skillInfos)
  98. {
  99. _skillInfos = skillInfos.Clone();
  100. }
  101. public void SetUpCustomMessage(string CustomMessage, string CustomMessage_Enemy)
  102. {
  103. _customMessage = CustomMessage;
  104. _customMessage_Enemy = CustomMessage_Enemy;
  105. }
  106. public void SetUpCustomMessage_ShowCard(string CustomMessage_ShowCard)
  107. {
  108. _customMessage_ShowCard = CustomMessage_ShowCard;
  109. }
  110. public void SetUpCustomCountText(string CustomCountText)
  111. {
  112. _customCountText = CustomCountText;
  113. }
  114. public void SetShowReverseCard()
  115. {
  116. _showReverseCard = false;
  117. }
  118. Func<CardSource, bool> _canTargetCondition = null;
  119. Func<List<CardSource>, CardSource, bool> _canTargetCondition_ByPreSelecetedList = null;
  120. Func<List<CardSource>, bool> _canEndSelectCondition = null;
  121. Func<bool> _canNoSelect = null;
  122. List<CardSource> _targetCards = new List<CardSource>();
  123. Func<CardSource, IEnumerator> _selectCardCoroutine = null;
  124. Func<List<CardSource>, IEnumerator> _afterSelectCardCoroutine = null;
  125. string _message = "";
  126. int _maxCount = 0;
  127. bool _canEndNotMax = false;
  128. bool _isShowOpponent = false;
  129. bool _canLookReverseCard = false;
  130. List<CardSource> _customRootCardList { get; set; } = new List<CardSource>();
  131. Player _selectPlayer = null;
  132. ICardEffect _cardEffect = null;
  133. bool _isLocal = false;
  134. bool _showReverseCard = true;
  135. bool _showCard = true;
  136. bool _notAddLog = false;
  137. bool _isDigiXros = false;
  138. bool _isAssembly = false;
  139. bool _isSecurity = false;
  140. bool _allowFaceDown = false;
  141. public enum Mode
  142. {
  143. AddHand,
  144. Discard,
  145. PlayForFree,
  146. // PutLibraryTop,
  147. // PutLibraryBottom,
  148. Custom,
  149. }
  150. Mode _mode;
  151. public enum Root
  152. {
  153. Library,
  154. Trash,
  155. Clock,
  156. Security,
  157. Custom,
  158. Hand,
  159. Recollection,
  160. Execution,
  161. DigivolutionCards,
  162. LinkedCards,
  163. None,
  164. }
  165. Root _root;
  166. bool _endSelect = false;
  167. bool _isDeckBottom = false;
  168. bool _isDeckTop = false;
  169. string _customMessage = null;
  170. string _customMessage_Enemy = null;
  171. string _customMessage_ShowCard = null;
  172. string _customCountText = null;
  173. List<SkillInfo> _skillInfos = new List<SkillInfo>();
  174. List<int> _slectedInexesInList = new List<int>();
  175. Func<List<int>, IEnumerator> _afterSelectIndexCoroutine = null;
  176. public void SetUpAfterSelectIndexCoroutine(Func<List<int>, IEnumerator> AfterSelectIndexCoroutine)
  177. {
  178. _afterSelectIndexCoroutine = AfterSelectIndexCoroutine;
  179. }
  180. public virtual List<CardSource> RootCardList()
  181. {
  182. List<CardSource> RootCardList = new List<CardSource>();
  183. if (_customRootCardList == null)
  184. {
  185. switch (_root)
  186. {
  187. case Root.Library:
  188. foreach (CardSource cardSource in _selectPlayer.LibraryCards)
  189. {
  190. RootCardList.Add(cardSource);
  191. }
  192. break;
  193. case Root.Trash:
  194. foreach (CardSource cardSource in _selectPlayer.TrashCards)
  195. {
  196. RootCardList.Add(cardSource);
  197. }
  198. break;
  199. case Root.Security:
  200. foreach (CardSource cardSource in _selectPlayer.SecurityCards)
  201. {
  202. RootCardList.Add(cardSource);
  203. }
  204. break;
  205. case Root.Recollection:
  206. foreach (CardSource cardSource in _selectPlayer.LostCards)
  207. {
  208. RootCardList.Add(cardSource);
  209. }
  210. break;
  211. }
  212. }
  213. else
  214. {
  215. foreach (CardSource cardSource in _customRootCardList)
  216. {
  217. RootCardList.Add(cardSource);
  218. }
  219. }
  220. return RootCardList;
  221. }
  222. private bool CanSelectCard(CardSource cardSource)
  223. {
  224. if (_root != Root.Library && _root != Root.Security && _root != Root.Custom)
  225. {
  226. if (cardSource.IsFlipped)
  227. return false;
  228. }
  229. if (_canTargetCondition != null)
  230. {
  231. if (_canTargetCondition(cardSource))
  232. {
  233. if (!_allowFaceDown)
  234. {
  235. if (cardSource.IsFlipped)
  236. return false;
  237. }
  238. return true;
  239. }
  240. }
  241. return false;
  242. }
  243. public bool active()
  244. {
  245. if (RootCardList().Count > 0)
  246. {
  247. if (_root != Root.Library && _root != Root.Security)
  248. {
  249. if (RootCardList().Count(CanSelectCard) > 0)
  250. {
  251. return true;
  252. }
  253. }
  254. else
  255. {
  256. if (_root == Root.Library)
  257. SetUseFaceDown();
  258. if(_root == Root.Security)
  259. {
  260. if (_canLookReverseCard)
  261. SetUseFaceDown();
  262. }
  263. return true;
  264. }
  265. }
  266. return false;
  267. }
  268. public virtual IEnumerator Activate()
  269. {
  270. bool oldIsSelecting = GManager.instance.turnStateMachine.IsSelecting;
  271. List<CardSource> handCards = new List<CardSource>();
  272. _targetCards = new List<CardSource>();
  273. _slectedInexesInList = new List<int>();
  274. if (!_isLocal)
  275. {
  276. yield return GManager.instance.photonWaitController.StartWait("SelectCardEffect");
  277. }
  278. bool oldIsActiveOutline_AttackingPermanent = false;
  279. if (GManager.instance.attackProcess.AttackingPermanent != null)
  280. {
  281. if (GManager.instance.attackProcess.AttackingPermanent.ShowingPermanentCard != null)
  282. {
  283. oldIsActiveOutline_AttackingPermanent = GManager.instance.attackProcess.AttackingPermanent.ShowingPermanentCard.Outline_Select.gameObject.activeSelf;
  284. }
  285. }
  286. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  287. {
  288. GManager.instance.turnStateMachine.OffFieldCardTarget(player);
  289. GManager.instance.turnStateMachine.OffHandCardTarget(player);
  290. }
  291. if (GManager.instance.attackProcess.AttackingPermanent != null)
  292. {
  293. if (GManager.instance.attackProcess.AttackingPermanent.ShowingPermanentCard != null)
  294. {
  295. GManager.instance.attackProcess.AttackingPermanent.ShowingPermanentCard.Outline_Select.gameObject.SetActive(oldIsActiveOutline_AttackingPermanent);
  296. }
  297. }
  298. if (_maxCount == 0)
  299. {
  300. _canNoSelect = () => true;
  301. }
  302. if (_root == Root.Security)
  303. {
  304. SetIsSecurity();
  305. }
  306. if (active())
  307. {
  308. if (_isSecurity)
  309. {
  310. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  311. }
  312. if (_selectPlayer.isYou)
  313. {
  314. if ((_isDeckBottom && ContinuousController.instance.autoDeckBottomOrder)
  315. || (_isDeckTop && ContinuousController.instance.autoDeckTopOrder))
  316. {
  317. AutoSelect();
  318. }
  319. else
  320. {
  321. List<int> targetCardIDs = new List<int>();
  322. GManager.instance.turnStateMachine.IsSelecting = true;
  323. #region Message Display
  324. if (!string.IsNullOrEmpty(_customMessage))
  325. {
  326. GManager.instance.commandText.OpenCommandText(_customMessage, _isDigiXros, _isAssembly);
  327. }
  328. else
  329. {
  330. string message = "";
  331. switch (_mode)
  332. {
  333. case Mode.AddHand:
  334. message = "Select cards to add to your hand.";
  335. break;
  336. case Mode.Discard:
  337. message = "Select cards to trash.";
  338. break;
  339. case Mode.PlayForFree:
  340. message = "Select cards to play without paying the cost.";
  341. break;
  342. case Mode.Custom:
  343. message = "Select cards.";
  344. break;
  345. }
  346. if (!string.IsNullOrEmpty(message))
  347. {
  348. GManager.instance.commandText.OpenCommandText(message, _isDigiXros, _isAssembly);
  349. }
  350. }
  351. #endregion
  352. List<CardSource> RootCards = new List<CardSource>();
  353. foreach (CardSource cardSource in RootCardList())
  354. {
  355. RootCards.Add(cardSource);
  356. }
  357. #region Sort
  358. if (_root == Root.Library || _root == Root.Trash)
  359. {
  360. RootCards = DeckData.SortedCardsList(RootCards);
  361. List<CardSource> matchConditionCards = new List<CardSource>();
  362. List<CardSource> notMatchConditionCards = new List<CardSource>();
  363. foreach (CardSource cardSource in RootCards)
  364. {
  365. if (CanSelectCard(cardSource))
  366. {
  367. matchConditionCards.Add(cardSource);
  368. }
  369. else
  370. {
  371. notMatchConditionCards.Add(cardSource);
  372. }
  373. }
  374. RootCards = new List<CardSource>();
  375. foreach (CardSource cardSource in matchConditionCards)
  376. {
  377. RootCards.Add(cardSource);
  378. }
  379. foreach (CardSource cardSource in notMatchConditionCards)
  380. {
  381. RootCards.Add(cardSource);
  382. }
  383. }
  384. #endregion
  385. #region Effect in progress/waiting to be activated
  386. if (_cardEffect != null)
  387. {
  388. if (_cardEffect.EffectSourceCard != null)
  389. {
  390. if (_skillInfos.Count == 0)
  391. {
  392. if (_root == Root.Trash || _root == Root.DigivolutionCards || _root == Root.LinkedCards)
  393. {
  394. SkillInfo[] skillInfoArray = new SkillInfo[RootCards.Count];
  395. for (int i = 0; i < skillInfoArray.Length; i++)
  396. {
  397. if (0 <= i && i <= RootCards.Count - 1)
  398. {
  399. if (RootCards[i] == _cardEffect.EffectSourceCard)
  400. {
  401. ICardEffect cardEffect = new ChangeBaseDPClass();
  402. cardEffect.SetUpICardEffect("Effect Processing", null, RootCards[i]);
  403. skillInfoArray[i] = new SkillInfo(cardEffect, null, EffectTiming.None);
  404. }
  405. else
  406. {
  407. if (GManager.instance.autoProcessing.executingMultipleSkills != null)
  408. {
  409. bool isEffectWaiting(SkillInfo skillInfo)
  410. {
  411. if (skillInfo != null)
  412. {
  413. if (skillInfo.CardEffect != null)
  414. {
  415. if (skillInfo.CardEffect.EffectSourceCard != null)
  416. {
  417. if (skillInfo.CardEffect.EffectSourceCard == RootCards[i])
  418. {
  419. return true;
  420. }
  421. }
  422. }
  423. }
  424. return false;
  425. }
  426. if (GManager.instance.autoProcessing.executingMultipleSkills.StackedSkillInfos.Count(isEffectWaiting) >= 1)
  427. {
  428. ICardEffect cardEffect = new ChangeBaseDPClass();
  429. cardEffect.SetUpICardEffect("Effect Waiting", null, RootCards[i]);
  430. skillInfoArray[i] = new SkillInfo(cardEffect, null, EffectTiming.None);
  431. }
  432. }
  433. }
  434. }
  435. }
  436. _skillInfos = skillInfoArray.ToList();
  437. }
  438. }
  439. }
  440. }
  441. #endregion
  442. GManager.instance.selectCardPanel._customCountText = _customCountText;
  443. yield return StartCoroutine(GManager.instance.selectCardPanel.OpenSelectCardPanel(
  444. Message: _message,
  445. RootCardSources: RootCards,
  446. _CanTargetCondition: CanSelectCard,
  447. _CanTargetCondition_ByPreSelecetedList: _canTargetCondition_ByPreSelecetedList,
  448. _CanEndSelectCondition: _canEndSelectCondition,
  449. _MaxCount: _maxCount,
  450. _CanEndNotMax: _canEndNotMax,
  451. _CanNoSelect: _canNoSelect,
  452. CanLookReverseCard: _canLookReverseCard,
  453. skillInfos: _skillInfos,
  454. root: _root));
  455. foreach (CardSource selectedCard in GManager.instance.selectCardPanel.SelectedList)
  456. {
  457. targetCardIDs.Add(selectedCard.CardIndex);
  458. }
  459. foreach (int selectedIndex in GManager.instance.selectCardPanel.SelectedIndex)
  460. {
  461. _slectedInexesInList.Add(selectedIndex);
  462. }
  463. photonView.RPC("SetTargetIndicies", RpcTarget.All, _slectedInexesInList.ToArray());
  464. photonView.RPC("SetTargetCard", RpcTarget.All, targetCardIDs.ToArray());
  465. }
  466. }
  467. else
  468. {
  469. if (!string.IsNullOrEmpty(_customMessage_Enemy))
  470. {
  471. GManager.instance.commandText.OpenCommandText(_customMessage_Enemy, _isDigiXros, _isAssembly);
  472. }
  473. else
  474. {
  475. GManager.instance.commandText.OpenCommandText("The opponent is selecting cards.", _isDigiXros, _isAssembly);
  476. }
  477. #region AI
  478. if (GManager.instance.IsAI)
  479. {
  480. AutoSelect();
  481. }
  482. #endregion
  483. }
  484. void AutoSelect()
  485. {
  486. List<CardSource> ValidCards = new List<CardSource>();
  487. foreach (CardSource cardSource in RootCardList())
  488. {
  489. if (CanSelectCard(cardSource))
  490. {
  491. ValidCards.Add(cardSource);
  492. }
  493. }
  494. IList<int> indexList = Enumerable.Range(0, ValidCards.Count).ToList();
  495. if (ValidCards.Count >= _maxCount)
  496. {
  497. for (int i = 0; i < 1000; i++)
  498. {
  499. List<int> GetIndexes = indexList.GetRandom(_maxCount).ToList();
  500. List<CardSource> GetCards = new List<CardSource>();
  501. foreach (int index in GetIndexes)
  502. {
  503. GetCards.Add(ValidCards[index]);
  504. }
  505. if (_canEndSelectCondition != null)
  506. {
  507. if (!_canEndSelectCondition(GetCards))
  508. {
  509. continue;
  510. }
  511. }
  512. List<int> CardIDs = new List<int>();
  513. foreach (CardSource cardSource in GetCards)
  514. {
  515. CardIDs.Add(cardSource.CardIndex);
  516. }
  517. if (GManager.instance.IsAI)
  518. {
  519. SetTargetCard(CardIDs.ToArray());
  520. }
  521. else
  522. {
  523. photonView.RPC("SetTargetCard", RpcTarget.All, CardIDs.ToArray());
  524. }
  525. break;
  526. }
  527. }
  528. if (GManager.instance.IsAI)
  529. {
  530. _endSelect = true;
  531. }
  532. }
  533. yield return new WaitWhile(() => !_endSelect);
  534. _endSelect = false;
  535. GManager.instance.commandText.CloseCommandText();
  536. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  537. #region Show selected card
  538. if (_targetCards.Count > 0 && _showCard)
  539. {
  540. if (_targetCards.Count((cardSource) => cardSource.IsFlipped) > 0 && !_showReverseCard)
  541. {
  542. //表示しない
  543. }
  544. else
  545. {
  546. if (_isShowOpponent || (_selectPlayer.isYou && _targetCards.Count((cardSource) => cardSource.Owner == _selectPlayer) > 0))
  547. {
  548. if (!string.IsNullOrEmpty(_customMessage_ShowCard))
  549. {
  550. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, _customMessage_ShowCard, true, true));
  551. }
  552. else
  553. {
  554. switch (_mode)
  555. {
  556. case Mode.AddHand:
  557. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Cards added to hand", true, true));
  558. break;
  559. case Mode.Discard:
  560. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Cards put on the trash", true, true));
  561. break;
  562. case Mode.PlayForFree:
  563. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Played cards", true, true));
  564. break;
  565. case Mode.Custom:
  566. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Selected Cards", true, true));
  567. break;
  568. }
  569. }
  570. }
  571. }
  572. }
  573. #endregion
  574. Hashtable hashtable = CardEffectCommons.CardEffectHashtable(_cardEffect);
  575. string log = "";
  576. if (_mode == Mode.AddHand)
  577. {
  578. log += $"\nCard{Utils.PluralFormSuffix(_targetCards.Count)} added to hand:";
  579. }
  580. else if (_mode == Mode.AddHand)
  581. {
  582. log += $"\nTrash Card{Utils.PluralFormSuffix(_targetCards.Count)}:";
  583. }
  584. else
  585. {
  586. log += $"\nSelected Card{Utils.PluralFormSuffix(_targetCards.Count)}:";
  587. }
  588. if (_root == Root.Library)
  589. {
  590. //yield return ContinuousController.instance.StartCoroutine(CardObjectController.Shuffle(_selectPlayer));
  591. }
  592. foreach (CardSource cardSource in _targetCards)
  593. {
  594. log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
  595. }
  596. switch (_mode)
  597. {
  598. case Mode.AddHand:
  599. foreach (CardSource cardSource in _targetCards)
  600. {
  601. cardSource.SetFace();
  602. if (cardSource.IsDigiEgg) yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(new List<CardSource> { cardSource }));
  603. else
  604. {
  605. if (cardSource.PermanentOfThisCard() != null)
  606. {
  607. if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  608. {
  609. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, cardSource.PermanentOfThisCard()));
  610. }
  611. }
  612. handCards.Add(cardSource);
  613. }
  614. }
  615. break;
  616. case Mode.Discard:
  617. foreach (CardSource cardSource in _targetCards)
  618. {
  619. if (CardEffectCommons.IsExistOnHand(cardSource))
  620. {
  621. List<IDiscardHand> discardHands = _targetCards.Map(cardSource => new IDiscardHand(cardSource, hashtable));
  622. yield return ContinuousController.instance.StartCoroutine(new IDiscardHands(discardHands, _cardEffect).DiscardHands());
  623. }
  624. else if (CardEffectCommons.IsExistLinked(cardSource))
  625. {
  626. yield return ContinuousController.instance.StartCoroutine(new ITrashLinkCards(
  627. cardSource.PermanentOfThisCard(),
  628. new List<CardSource> { cardSource },
  629. _cardEffect).TrashLinkCards());
  630. }
  631. else
  632. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  633. }
  634. break;
  635. case Mode.PlayForFree:
  636. yield return ContinuousController.instance.StartCoroutine(
  637. CardEffectCommons.PlayPermanentCards(
  638. cardSources: _targetCards,
  639. activateClass: _cardEffect,
  640. payCost: false,
  641. isTapped: false,
  642. root: _root,
  643. activateETB: true));
  644. break;
  645. case Mode.Custom:
  646. if (_selectCardCoroutine != null)
  647. {
  648. foreach (CardSource cardSource in _targetCards)
  649. {
  650. yield return StartCoroutine(_selectCardCoroutine(cardSource));
  651. }
  652. }
  653. break;
  654. }
  655. if (handCards.Count >= 1)
  656. {
  657. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(handCards, false, _cardEffect));
  658. }
  659. #region ログ追加
  660. if (!_notAddLog)
  661. {
  662. if (_isShowOpponent || _selectPlayer.isYou)
  663. {
  664. if (_targetCards.Count >= 1)
  665. {
  666. log += "\n";
  667. PlayLog.OnAddLog?.Invoke(log);
  668. }
  669. }
  670. }
  671. #endregion
  672. }
  673. if (_afterSelectCardCoroutine != null)
  674. {
  675. yield return StartCoroutine(_afterSelectCardCoroutine(_targetCards));
  676. }
  677. if (_afterSelectIndexCoroutine != null)
  678. {
  679. yield return StartCoroutine(_afterSelectIndexCoroutine(_slectedInexesInList));
  680. }
  681. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  682. GManager.instance.turnStateMachine.IsSelecting = oldIsSelecting;
  683. }
  684. [PunRPC]
  685. public void SetTargetCard(int[] CardIDs)
  686. {
  687. _targetCards = new List<CardSource>();
  688. foreach (int CardID in CardIDs)
  689. {
  690. _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[CardID]);
  691. }
  692. _endSelect = true;
  693. }
  694. [PunRPC]
  695. public void SetTargetIndicies(int[] CardIDs)
  696. {
  697. _slectedInexesInList = new List<int>();
  698. foreach (int index in CardIDs)
  699. {
  700. _slectedInexesInList.Add(index);
  701. }
  702. }
  703. }