SelectCardEffect.cs 28 KB

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