SelectCardEffect.cs 28 KB

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