SelectCardEffect.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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. // PutLibraryTop,
  146. // PutLibraryBottom,
  147. Custom,
  148. }
  149. Mode _mode;
  150. public enum Root
  151. {
  152. Library,
  153. Trash,
  154. Clock,
  155. Security,
  156. Custom,
  157. Hand,
  158. Recollection,
  159. Execution,
  160. DigivolutionCards,
  161. LinkedCards,
  162. None,
  163. }
  164. Root _root;
  165. bool _endSelect = false;
  166. bool _isDeckBottom = false;
  167. bool _isDeckTop = false;
  168. string _customMessage = null;
  169. string _customMessage_Enemy = null;
  170. string _customMessage_ShowCard = null;
  171. string _customCountText = null;
  172. List<SkillInfo> _skillInfos = new List<SkillInfo>();
  173. List<int> _slectedInexesInList = new List<int>();
  174. Func<List<int>, IEnumerator> _afterSelectIndexCoroutine = null;
  175. public void SetUpAfterSelectIndexCoroutine(Func<List<int>, IEnumerator> AfterSelectIndexCoroutine)
  176. {
  177. _afterSelectIndexCoroutine = AfterSelectIndexCoroutine;
  178. }
  179. public virtual List<CardSource> RootCardList()
  180. {
  181. List<CardSource> RootCardList = new List<CardSource>();
  182. switch (_root)
  183. {
  184. case Root.Library:
  185. if (_customRootCardList.Count > 0)
  186. {
  187. foreach (CardSource cardSource in _customRootCardList)
  188. {
  189. RootCardList.Add(cardSource);
  190. }
  191. }
  192. else
  193. {
  194. foreach (CardSource cardSource in _selectPlayer.LibraryCards)
  195. {
  196. RootCardList.Add(cardSource);
  197. }
  198. }
  199. break;
  200. case Root.Trash:
  201. foreach (CardSource cardSource in _selectPlayer.TrashCards)
  202. {
  203. RootCardList.Add(cardSource);
  204. }
  205. break;
  206. case Root.Security:
  207. foreach (CardSource cardSource in _selectPlayer.SecurityCards)
  208. {
  209. RootCardList.Add(cardSource);
  210. }
  211. break;
  212. case Root.Recollection:
  213. foreach (CardSource cardSource in _selectPlayer.LostCards)
  214. {
  215. RootCardList.Add(cardSource);
  216. }
  217. break;
  218. case Root.Custom:
  219. foreach (CardSource cardSource in _customRootCardList)
  220. {
  221. RootCardList.Add(cardSource);
  222. }
  223. break;
  224. }
  225. return RootCardList;
  226. }
  227. private bool CanSelectCard(CardSource cardSource)
  228. {
  229. if (_root != Root.Library && _root != Root.Security && _root != Root.Custom)
  230. {
  231. if (cardSource.IsFlipped)
  232. return false;
  233. }
  234. if (_canTargetCondition != null)
  235. {
  236. if (_canTargetCondition(cardSource))
  237. {
  238. if (!_allowFaceDown)
  239. {
  240. if (cardSource.IsFlipped)
  241. return false;
  242. }
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. public bool active()
  249. {
  250. if (RootCardList().Count > 0)
  251. {
  252. if (_root != Root.Library && _root != Root.Security)
  253. {
  254. if (RootCardList().Count(CanSelectCard) > 0)
  255. {
  256. return true;
  257. }
  258. }
  259. else
  260. {
  261. if (_root == Root.Library)
  262. SetUseFaceDown();
  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.Custom:
  340. message = "Select cards.";
  341. break;
  342. }
  343. if (!string.IsNullOrEmpty(message))
  344. {
  345. GManager.instance.commandText.OpenCommandText(message, _isDigiXros, _isAssembly);
  346. }
  347. }
  348. #endregion
  349. List<CardSource> RootCards = new List<CardSource>();
  350. foreach (CardSource cardSource in RootCardList())
  351. {
  352. RootCards.Add(cardSource);
  353. }
  354. #region Sort
  355. if (_root == Root.Library || _root == Root.Trash)
  356. {
  357. RootCards = DeckData.SortedCardsList(RootCards);
  358. List<CardSource> matchConditionCards = new List<CardSource>();
  359. List<CardSource> notMatchConditionCards = new List<CardSource>();
  360. foreach (CardSource cardSource in RootCards)
  361. {
  362. if (CanSelectCard(cardSource))
  363. {
  364. matchConditionCards.Add(cardSource);
  365. }
  366. else
  367. {
  368. notMatchConditionCards.Add(cardSource);
  369. }
  370. }
  371. RootCards = new List<CardSource>();
  372. foreach (CardSource cardSource in matchConditionCards)
  373. {
  374. RootCards.Add(cardSource);
  375. }
  376. foreach (CardSource cardSource in notMatchConditionCards)
  377. {
  378. RootCards.Add(cardSource);
  379. }
  380. }
  381. #endregion
  382. #region Effect in progress/waiting to be activated
  383. if (_cardEffect != null)
  384. {
  385. if (_cardEffect.EffectSourceCard != null)
  386. {
  387. if (_skillInfos.Count == 0)
  388. {
  389. if (_root == Root.Trash)
  390. {
  391. SkillInfo[] skillInfoArray = new SkillInfo[RootCards.Count];
  392. for (int i = 0; i < skillInfoArray.Length; i++)
  393. {
  394. if (0 <= i && i <= RootCards.Count - 1)
  395. {
  396. if (RootCards[i] == _cardEffect.EffectSourceCard)
  397. {
  398. ICardEffect cardEffect = new ChangeBaseDPClass();
  399. cardEffect.SetUpICardEffect("Effect Processing", null, RootCards[i]);
  400. skillInfoArray[i] = new SkillInfo(cardEffect, null, EffectTiming.None);
  401. }
  402. else
  403. {
  404. if (GManager.instance.autoProcessing.executingMultipleSkills != null)
  405. {
  406. bool isEffectWaiting(SkillInfo skillInfo)
  407. {
  408. if (skillInfo != null)
  409. {
  410. if (skillInfo.CardEffect != null)
  411. {
  412. if (skillInfo.CardEffect.EffectSourceCard != null)
  413. {
  414. if (skillInfo.CardEffect.EffectSourceCard == RootCards[i])
  415. {
  416. return true;
  417. }
  418. }
  419. }
  420. }
  421. return false;
  422. }
  423. if (GManager.instance.autoProcessing.executingMultipleSkills.StackedSkillInfos.Count(isEffectWaiting) >= 1)
  424. {
  425. ICardEffect cardEffect = new ChangeBaseDPClass();
  426. cardEffect.SetUpICardEffect("Effect Waiting", null, RootCards[i]);
  427. skillInfoArray[i] = new SkillInfo(cardEffect, null, EffectTiming.None);
  428. }
  429. }
  430. }
  431. }
  432. }
  433. _skillInfos = skillInfoArray.ToList();
  434. }
  435. }
  436. }
  437. }
  438. #endregion
  439. GManager.instance.selectCardPanel._customCountText = _customCountText;
  440. yield return StartCoroutine(GManager.instance.selectCardPanel.OpenSelectCardPanel(
  441. Message: _message,
  442. RootCardSources: RootCards,
  443. _CanTargetCondition: CanSelectCard,
  444. _CanTargetCondition_ByPreSelecetedList: _canTargetCondition_ByPreSelecetedList,
  445. _CanEndSelectCondition: _canEndSelectCondition,
  446. _MaxCount: _maxCount,
  447. _CanEndNotMax: _canEndNotMax,
  448. _CanNoSelect: _canNoSelect,
  449. CanLookReverseCard: _canLookReverseCard,
  450. skillInfos: _skillInfos,
  451. root: _root));
  452. foreach (CardSource selectedCard in GManager.instance.selectCardPanel.SelectedList)
  453. {
  454. targetCardIDs.Add(selectedCard.CardIndex);
  455. }
  456. foreach (int selectedIndex in GManager.instance.selectCardPanel.SelectedIndex)
  457. {
  458. _slectedInexesInList.Add(selectedIndex);
  459. }
  460. photonView.RPC("SetTargetIndicies", RpcTarget.All, _slectedInexesInList.ToArray());
  461. photonView.RPC("SetTargetCard", RpcTarget.All, targetCardIDs.ToArray());
  462. }
  463. }
  464. else
  465. {
  466. if (!string.IsNullOrEmpty(_customMessage_Enemy))
  467. {
  468. GManager.instance.commandText.OpenCommandText(_customMessage_Enemy, _isDigiXros, _isAssembly);
  469. }
  470. else
  471. {
  472. GManager.instance.commandText.OpenCommandText("The opponent is selecting cards.", _isDigiXros, _isAssembly);
  473. }
  474. #region AI
  475. if (GManager.instance.IsAI)
  476. {
  477. AutoSelect();
  478. }
  479. #endregion
  480. }
  481. void AutoSelect()
  482. {
  483. List<CardSource> ValidCards = new List<CardSource>();
  484. foreach (CardSource cardSource in RootCardList())
  485. {
  486. if (CanSelectCard(cardSource))
  487. {
  488. ValidCards.Add(cardSource);
  489. }
  490. }
  491. IList<int> indexList = Enumerable.Range(0, ValidCards.Count).ToList();
  492. if (ValidCards.Count >= _maxCount)
  493. {
  494. for (int i = 0; i < 1000; i++)
  495. {
  496. List<int> GetIndexes = indexList.GetRandom(_maxCount).ToList();
  497. List<CardSource> GetCards = new List<CardSource>();
  498. foreach (int index in GetIndexes)
  499. {
  500. GetCards.Add(ValidCards[index]);
  501. }
  502. if (_canEndSelectCondition != null)
  503. {
  504. if (!_canEndSelectCondition(GetCards))
  505. {
  506. continue;
  507. }
  508. }
  509. List<int> CardIDs = new List<int>();
  510. foreach (CardSource cardSource in GetCards)
  511. {
  512. CardIDs.Add(cardSource.CardIndex);
  513. }
  514. if (GManager.instance.IsAI)
  515. {
  516. SetTargetCard(CardIDs.ToArray());
  517. }
  518. else
  519. {
  520. photonView.RPC("SetTargetCard", RpcTarget.All, CardIDs.ToArray());
  521. }
  522. break;
  523. }
  524. }
  525. if (GManager.instance.IsAI)
  526. {
  527. _endSelect = true;
  528. }
  529. }
  530. yield return new WaitWhile(() => !_endSelect);
  531. _endSelect = false;
  532. GManager.instance.commandText.CloseCommandText();
  533. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  534. #region Show selected card
  535. if (_targetCards.Count > 0 && _showCard)
  536. {
  537. if (_targetCards.Count((cardSource) => cardSource.IsFlipped) > 0 && !_showReverseCard)
  538. {
  539. //表示しない
  540. }
  541. else
  542. {
  543. if (_isShowOpponent || (_selectPlayer.isYou && _targetCards.Count((cardSource) => cardSource.Owner == _selectPlayer) > 0))
  544. {
  545. if (!string.IsNullOrEmpty(_customMessage_ShowCard))
  546. {
  547. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, _customMessage_ShowCard, true, true));
  548. }
  549. else
  550. {
  551. switch (_mode)
  552. {
  553. case Mode.AddHand:
  554. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Cards added to hand", true, true));
  555. break;
  556. case Mode.Discard:
  557. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Cards put on the trash", true, true));
  558. break;
  559. case Mode.Custom:
  560. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_targetCards, "Selected Cards", true, true));
  561. break;
  562. }
  563. }
  564. }
  565. }
  566. }
  567. #endregion
  568. Hashtable hashtable = CardEffectCommons.CardEffectHashtable(_cardEffect);
  569. string log = "";
  570. if (_mode == Mode.AddHand)
  571. {
  572. log += $"\nCard{Utils.PluralFormSuffix(_targetCards.Count)} added to hand:";
  573. }
  574. else if (_mode == Mode.AddHand)
  575. {
  576. log += $"\nTrash Card{Utils.PluralFormSuffix(_targetCards.Count)}:";
  577. }
  578. else
  579. {
  580. log += $"\nSelected Card{Utils.PluralFormSuffix(_targetCards.Count)}:";
  581. }
  582. if (_root == Root.Library)
  583. {
  584. //yield return ContinuousController.instance.StartCoroutine(CardObjectController.Shuffle(_selectPlayer));
  585. }
  586. foreach (CardSource cardSource in _targetCards)
  587. {
  588. log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
  589. }
  590. switch (_mode)
  591. {
  592. case Mode.AddHand:
  593. foreach (CardSource cardSource in _targetCards)
  594. {
  595. cardSource.SetFace();
  596. if (cardSource.IsDigiEgg) yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(new List<CardSource> { cardSource }));
  597. else
  598. {
  599. if (cardSource.PermanentOfThisCard() != null)
  600. {
  601. if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  602. {
  603. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, cardSource.PermanentOfThisCard()));
  604. }
  605. }
  606. handCards.Add(cardSource);
  607. }
  608. }
  609. break;
  610. case Mode.Discard:
  611. foreach (CardSource cardSource in _targetCards)
  612. {
  613. if (CardEffectCommons.IsExistOnHand(cardSource))
  614. {
  615. List<IDiscardHand> discardHands = _targetCards.Map(cardSource => new IDiscardHand(cardSource, hashtable));
  616. yield return ContinuousController.instance.StartCoroutine(new IDiscardHands(discardHands, _cardEffect).DiscardHands());
  617. }
  618. else if (CardEffectCommons.IsExistLinked(cardSource))
  619. {
  620. yield return ContinuousController.instance.StartCoroutine(cardSource.PermanentOfThisCard().RemoveLinkedCard(cardSource));
  621. }
  622. else
  623. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(cardSource));
  624. }
  625. break;
  626. case Mode.Custom:
  627. if (_selectCardCoroutine != null)
  628. {
  629. foreach (CardSource cardSource in _targetCards)
  630. {
  631. yield return StartCoroutine(_selectCardCoroutine(cardSource));
  632. }
  633. }
  634. break;
  635. }
  636. if (handCards.Count >= 1)
  637. {
  638. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(handCards, false, _cardEffect));
  639. }
  640. #region ログ追加
  641. if (!_notAddLog)
  642. {
  643. if (_isShowOpponent || _selectPlayer.isYou)
  644. {
  645. if (_targetCards.Count >= 1)
  646. {
  647. log += "\n";
  648. PlayLog.OnAddLog?.Invoke(log);
  649. }
  650. }
  651. }
  652. #endregion
  653. }
  654. if (_afterSelectCardCoroutine != null)
  655. {
  656. yield return StartCoroutine(_afterSelectCardCoroutine(_targetCards));
  657. }
  658. if (_afterSelectIndexCoroutine != null)
  659. {
  660. yield return StartCoroutine(_afterSelectIndexCoroutine(_slectedInexesInList));
  661. }
  662. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  663. GManager.instance.turnStateMachine.IsSelecting = oldIsSelecting;
  664. }
  665. [PunRPC]
  666. public void SetTargetCard(int[] CardIDs)
  667. {
  668. _targetCards = new List<CardSource>();
  669. foreach (int CardID in CardIDs)
  670. {
  671. _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[CardID]);
  672. }
  673. _endSelect = true;
  674. }
  675. [PunRPC]
  676. public void SetTargetIndicies(int[] CardIDs)
  677. {
  678. _slectedInexesInList = new List<int>();
  679. foreach (int index in CardIDs)
  680. {
  681. _slectedInexesInList.Add(index);
  682. }
  683. }
  684. }