SelectDigiXrosClass.cs 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using Photon.Pun;
  7. using System;
  8. using UnityEngine.Events;
  9. public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
  10. {
  11. public List<CardSource> selectedDigicrossCards { get; private set; } = new List<CardSource>();
  12. public List<AddDigivolutionCardsInfo> addDigivolutionCardInfos { get; private set; } = new List<AddDigivolutionCardsInfo>();
  13. public CardSource playCard { get; private set; } = null;
  14. public void ResetSelectDigiXrosClass()
  15. {
  16. selectedDigicrossCards = new List<CardSource>();
  17. addDigivolutionCardInfos = new List<AddDigivolutionCardsInfo>();
  18. playCard = null;
  19. }
  20. public void AddDigivolutionCardInfos(AddDigivolutionCardsInfo digivolutionCardsInfo)
  21. {
  22. addDigivolutionCardInfos.Add(digivolutionCardsInfo);
  23. }
  24. #region トラッシュのカードをデジクロスに選択できる最大枚数
  25. int maxTrashCount(CardSource card)
  26. {
  27. int maxTrashCount = 0;
  28. if (card != null)
  29. {
  30. List<int> maxTrashCountList = new List<int>();
  31. #region 選択可能トラッシュ枚数を変更する効果
  32. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  33. {
  34. #region 場のパーマネントの効果
  35. foreach (Permanent permanent in player.GetBattleAreaPermanents())
  36. {
  37. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  38. {
  39. if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
  40. {
  41. if (cardEffect.CanUse(null))
  42. {
  43. int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
  44. if (count >= 1)
  45. {
  46. maxTrashCountList.Add(count);
  47. }
  48. }
  49. }
  50. }
  51. }
  52. #endregion
  53. #region プレイヤーの効果
  54. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  55. {
  56. if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
  57. {
  58. if (cardEffect.CanUse(null))
  59. {
  60. int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
  61. if (count >= 1)
  62. {
  63. maxTrashCountList.Add(count);
  64. }
  65. }
  66. }
  67. }
  68. #endregion
  69. }
  70. #region カード自身の効果
  71. if (card.PermanentOfThisCard() == null)
  72. {
  73. foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.None))
  74. {
  75. if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
  76. {
  77. if (cardEffect.CanUse(null))
  78. {
  79. int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
  80. if (count >= 1)
  81. {
  82. maxTrashCountList.Add(count);
  83. }
  84. }
  85. }
  86. }
  87. }
  88. #endregion
  89. #endregion
  90. if (maxTrashCountList.Count >= 1)
  91. {
  92. maxTrashCount = maxTrashCountList.Max();
  93. }
  94. if (maxTrashCount > card.Owner.TrashCards.Count)
  95. {
  96. maxTrashCount = card.Owner.TrashCards.Count;
  97. }
  98. if (maxTrashCount < 0)
  99. {
  100. maxTrashCount = 0;
  101. }
  102. }
  103. return maxTrashCount;
  104. }
  105. #endregion
  106. #region テイマーの進化元のカードをデジクロスに選択できる最大枚数
  107. int maxTamerDigivolutionCardsCount(CardSource card)
  108. {
  109. int maxTamerDigivolutionCardsCount = 0;
  110. if (card != null)
  111. {
  112. List<int> maxTamerDigivolutionCardsCountList = new List<int>();
  113. #region 選択可能テイマー進化元枚数を変更する効果
  114. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  115. {
  116. #region 場のパーマネントの効果
  117. foreach (Permanent permanent in player.GetBattleAreaPermanents())
  118. {
  119. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  120. {
  121. if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
  122. {
  123. if (cardEffect.CanUse(null))
  124. {
  125. int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
  126. if (count >= 1)
  127. {
  128. maxTamerDigivolutionCardsCountList.Add(count);
  129. }
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region プレイヤーの効果
  136. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  137. {
  138. if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
  139. {
  140. if (cardEffect.CanUse(null))
  141. {
  142. int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
  143. if (count >= 1)
  144. {
  145. maxTamerDigivolutionCardsCountList.Add(count);
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. }
  152. #region カード自身の効果
  153. if (card.PermanentOfThisCard() == null)
  154. {
  155. foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.None))
  156. {
  157. if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
  158. {
  159. if (cardEffect.CanUse(null))
  160. {
  161. int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
  162. if (count >= 1)
  163. {
  164. maxTamerDigivolutionCardsCountList.Add(count);
  165. }
  166. }
  167. }
  168. }
  169. }
  170. #endregion
  171. #endregion
  172. if (maxTamerDigivolutionCardsCountList.Count >= 1)
  173. {
  174. maxTamerDigivolutionCardsCount = maxTamerDigivolutionCardsCountList.Max();
  175. }
  176. if (maxTamerDigivolutionCardsCount < 0)
  177. {
  178. maxTamerDigivolutionCardsCount = 0;
  179. }
  180. }
  181. return maxTamerDigivolutionCardsCount;
  182. }
  183. #endregion
  184. #region 手札のカードか
  185. bool isHandCard(CardSource cardSource)
  186. {
  187. if (cardSource != null)
  188. {
  189. if (cardSource.Owner.HandCards.Contains(cardSource))
  190. {
  191. if (cardSource.IsDigimon)
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. return false;
  198. }
  199. #endregion
  200. #region バトルエリアのカードか
  201. bool isBattleAreaCard(CardSource cardSource)
  202. {
  203. if (cardSource != null)
  204. {
  205. if (cardSource.PermanentOfThisCard() != null)
  206. {
  207. if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
  208. {
  209. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. #endregion
  219. #region トラッシュのカードか
  220. bool isTrashCard(CardSource cardSource)
  221. {
  222. if (cardSource != null)
  223. {
  224. if (CardEffectCommons.IsExistOnTrash(cardSource))
  225. {
  226. if (cardSource.IsDigimon)
  227. {
  228. return true;
  229. }
  230. }
  231. }
  232. return false;
  233. }
  234. #endregion
  235. #region テイマーの進化元か
  236. bool isTamerDigivolutionCard(CardSource cardSource)
  237. {
  238. if (cardSource != null)
  239. {
  240. if (cardSource.PermanentOfThisCard() != null)
  241. {
  242. if (cardSource.PermanentOfThisCard().IsTamer)
  243. {
  244. if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  245. {
  246. if (cardSource.IsDigimon)
  247. {
  248. return true;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. #endregion
  257. #region デジクロスの素材として選択できる
  258. bool CanSelectDigiXros(DigiXrosConditionElement element, CardSource targetCard, CardSource card)
  259. {
  260. if (card != targetCard)
  261. {
  262. if (card != null)
  263. {
  264. if (element != null)
  265. {
  266. if (element.CardCondition != null)
  267. {
  268. if (targetCard != null)
  269. {
  270. if (card.digiXrosCondition != null)
  271. {
  272. if (!targetCard.IsToken)
  273. {
  274. if (!selectedDigicrossCards.Contains(targetCard))
  275. {
  276. if (addDigivolutionCardInfos.Count((addDigivolutionCardInfo) => addDigivolutionCardInfo.cardSources.Contains(targetCard)) == 0)
  277. {
  278. if (card.digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null)
  279. {
  280. if (!card.digiXrosCondition.CanTargetCondition_ByPreSelecetedList(selectedDigicrossCards, targetCard))
  281. {
  282. return false;
  283. }
  284. }
  285. if (element.CardCondition(targetCard))
  286. {
  287. return true;
  288. }
  289. if (targetCard.PermanentOfThisCard() != null)
  290. {
  291. if (targetCard == targetCard.PermanentOfThisCard().TopCard)
  292. {
  293. if (targetCard.PermanentOfThisCard().CanSubstituteForDigiXrosCondition(card))
  294. {
  295. return true;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. return false;
  309. }
  310. #endregion
  311. #region デジクロス選択
  312. public IEnumerator Select(CardSource card)
  313. {
  314. GManager.instance.turnStateMachine.isSync = true;
  315. selectedDigicrossCards = new List<CardSource>();
  316. playCard = card;
  317. if (card != null)
  318. {
  319. if (card.HasDigiXros)
  320. {
  321. DigiXrosCondition digiXrosCondition = card.digiXrosCondition;
  322. foreach (DigiXrosConditionElement element in digiXrosCondition.elements)
  323. {
  324. yield return GManager.instance.photonWaitController.StartWait("SelectDigiXross");
  325. if (selectedDigicrossCards.Count >= 1)
  326. {
  327. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedDigicrossCards, "DigiXros Cards", false, true));
  328. }
  329. if (_endSelectDigiXros)
  330. {
  331. _endSelectDigiXros = false;
  332. break;
  333. }
  334. bool canSelectHand = false;
  335. if (card.Owner.HandCards.Count((cardSource) => CanSelectDigiXros(element, cardSource, card)) >= 1)
  336. {
  337. canSelectHand = true;
  338. }
  339. bool canSelectField = false;
  340. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && CanSelectDigiXros(element, permanent.TopCard, card)))
  341. {
  342. canSelectField = true;
  343. }
  344. bool canSelectTrash = false;
  345. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectDigiXros(element, cardSource, card)))
  346. {
  347. if (selectedDigicrossCards.Count(isTrashCard) < maxTrashCount(card))
  348. {
  349. canSelectTrash = true;
  350. }
  351. }
  352. bool canSelectTamer = false;
  353. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer && permanent.DigivolutionCards.Count((cardSource) => CanSelectDigiXros(element, cardSource, card)) >= 1))
  354. {
  355. if (selectedDigicrossCards.Count(isTamerDigivolutionCard) < maxTamerDigivolutionCardsCount(card))
  356. {
  357. canSelectTamer = true;
  358. }
  359. }
  360. Func<IEnumerator> _SelectHandCard = () => SelectHandCard(digiXrosCondition, element, card);
  361. Func<IEnumerator> _SelectBattleAreaDigimon = () => SelectBattleAreaDigimon(digiXrosCondition, element, card);
  362. Func<IEnumerator> _SelectTrashCard = () => SelectTrashCard(digiXrosCondition, element, card);
  363. Func<IEnumerator> _SelectTamerDigivolutionCard = () => SelectTamerDigivolutionCard(digiXrosCondition, element, card);
  364. Func<IEnumerator> _EndSelectDigiXros = () => EndSelectDigiXros();
  365. List<Func<IEnumerator>> actions = new List<Func<IEnumerator>>() { _SelectHandCard, _SelectBattleAreaDigimon, _SelectTrashCard, _SelectTamerDigivolutionCard, _EndSelectDigiXros };
  366. List<Func<IEnumerator>> canSelectActions = new List<Func<IEnumerator>>();
  367. if (canSelectHand)
  368. {
  369. canSelectActions.Add(_SelectHandCard);
  370. }
  371. if (canSelectField)
  372. {
  373. canSelectActions.Add(_SelectBattleAreaDigimon);
  374. }
  375. if (canSelectTrash)
  376. {
  377. canSelectActions.Add(_SelectTrashCard);
  378. }
  379. if (canSelectTamer)
  380. {
  381. canSelectActions.Add(_SelectTamerDigivolutionCard);
  382. }
  383. canSelectActions.Add(_EndSelectDigiXros);
  384. if (canSelectActions.Count == 1)
  385. {
  386. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  387. {
  388. break;
  389. }
  390. else
  391. {
  392. continue;
  393. }
  394. }
  395. else if (canSelectActions.Count == 2 && digiXrosCondition.CanTargetCondition_ByPreSelecetedList == null && !element.skipAllIfNoSelect)
  396. {
  397. SetTargetDigiXrossIndex(actions.IndexOf(canSelectActions[0]));
  398. }
  399. else
  400. {
  401. if (card.Owner.isYou)
  402. {
  403. GManager.instance.commandText.OpenCommandText($"From which area will you select {element.selectMessage}?", digiXros: true);
  404. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>();
  405. for (int i = 0; i < canSelectActions.Count; i++)
  406. {
  407. int k = actions.IndexOf(canSelectActions[i]);
  408. int spriteIndex = 0;
  409. string message = "";
  410. switch (k)
  411. {
  412. case 0:
  413. message = "Hand";
  414. break;
  415. case 1:
  416. message = "Field Digimon";
  417. break;
  418. case 2:
  419. message = "Trash";
  420. break;
  421. case 3:
  422. message = "Tamer digivolution cards";
  423. break;
  424. case 4:
  425. message = "End Selection";
  426. spriteIndex = 1;
  427. break;
  428. }
  429. command_SelectCommands.Add(new Command_SelectCommand(message, () => photonView.RPC("SetTargetDigiXrossIndex", RpcTarget.All, k), spriteIndex));
  430. }
  431. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  432. }
  433. else
  434. {
  435. GManager.instance.commandText.OpenCommandText($"The opponent is choosing from which area to select {element.selectMessage}.", digiXros: true);
  436. #region AIモード
  437. if (GManager.instance.IsAI)
  438. {
  439. List<int> indexes = new List<int>();
  440. for (int i = 0; i < canSelectActions.Count; i++)
  441. {
  442. int k = actions.IndexOf(canSelectActions[i]);
  443. indexes.Add(k);
  444. }
  445. SetTargetDigiXrossIndex(UnityEngine.Random.Range(0, indexes.Count));
  446. }
  447. #endregion
  448. }
  449. }
  450. yield return new WaitWhile(() => !_endSelect);
  451. _endSelect = false;
  452. GManager.instance.commandText.CloseCommandText();
  453. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  454. if (0 <= _targetIndex && _targetIndex <= actions.Count - 1)
  455. {
  456. yield return ContinuousController.instance.StartCoroutine(actions[_targetIndex]());
  457. if (!card.Owner.isYou && GManager.instance.IsAI)
  458. {
  459. yield return new WaitForSeconds(0.3f);
  460. }
  461. }
  462. }
  463. }
  464. }
  465. if (selectedDigicrossCards.Count >= 1)
  466. {
  467. yield return new WaitForSeconds(0.4f);
  468. }
  469. GManager.instance.GetComponent<Effects>().OffShowCard2();
  470. GManager.instance.turnStateMachine.isSync = false;
  471. }
  472. #endregion
  473. #region 手札のカードを選択する
  474. IEnumerator SelectHandCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
  475. {
  476. bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
  477. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  478. {
  479. int maxCount = 1;
  480. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  481. selectHandEffect.SetUp(
  482. selectPlayer: card.Owner,
  483. canTargetCondition: CanSelectCardCondition,
  484. canTargetCondition_ByPreSelecetedList: null,
  485. canEndSelectCondition: null,
  486. maxCount: maxCount,
  487. canNoSelect: true,
  488. canEndNotMax: false,
  489. isShowOpponent: true,
  490. selectCardCoroutine: SelectCardCoroutine,
  491. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  492. mode: SelectHandEffect.Mode.Custom,
  493. cardEffect: null);
  494. selectHandEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
  495. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Hand Card");
  496. selectHandEffect.SetDigiXros();
  497. yield return StartCoroutine(selectHandEffect.Activate());
  498. IEnumerator SelectCardCoroutine(CardSource cardSource)
  499. {
  500. selectedDigicrossCards.Add(cardSource);
  501. yield return null;
  502. }
  503. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  504. {
  505. if (cardSources.Count == 0)
  506. {
  507. if (digiXrosCondition != null)
  508. {
  509. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  510. {
  511. EndSelectDigiXros();
  512. }
  513. }
  514. }
  515. yield return null;
  516. }
  517. }
  518. }
  519. #endregion
  520. #region 場のデジモンのカードを選択する
  521. IEnumerator SelectBattleAreaDigimon(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
  522. {
  523. bool CanSelectPermanentCondition(Permanent permanent) => permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent) && CanSelectDigiXros(element, permanent.TopCard, card);
  524. ActivateClass activateClass = new ActivateClass();
  525. activateClass.SetUpICardEffect("", null, card);
  526. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  527. {
  528. int maxCount = 1;
  529. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  530. selectPermanentEffect.SetUp(
  531. selectPlayer: card.Owner,
  532. canTargetCondition: CanSelectPermanentCondition,
  533. canTargetCondition_ByPreSelecetedList: null,
  534. canEndSelectCondition: null,
  535. maxCount: maxCount,
  536. canNoSelect: true,
  537. canEndNotMax: false,
  538. selectPermanentCoroutine: SelectPermanentCoroutine,
  539. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  540. mode: SelectPermanentEffect.Mode.Custom,
  541. cardEffect: activateClass);
  542. selectPermanentEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
  543. selectPermanentEffect.SetDigiXros();
  544. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  545. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  546. {
  547. selectedDigicrossCards.Add(permanent.TopCard);
  548. yield return null;
  549. }
  550. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  551. {
  552. if (permanents.Count == 0)
  553. {
  554. if (digiXrosCondition != null)
  555. {
  556. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  557. {
  558. EndSelectDigiXros();
  559. }
  560. }
  561. }
  562. yield return null;
  563. }
  564. }
  565. }
  566. #endregion
  567. #region テイマーの進化元を選択する
  568. IEnumerator SelectTamerDigivolutionCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
  569. {
  570. bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
  571. bool CanSelectPermanentCondition(Permanent permanent) => permanent.TopCard.Owner == card.Owner && permanent.IsTamer && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  572. ActivateClass activateClass = new ActivateClass();
  573. activateClass.SetUpICardEffect("", null, card);
  574. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  575. {
  576. Permanent selectedPermanent = null;
  577. int maxCount = 1;
  578. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  579. selectPermanentEffect.SetUp(
  580. selectPlayer: card.Owner,
  581. canTargetCondition: CanSelectPermanentCondition,
  582. canTargetCondition_ByPreSelecetedList: null,
  583. canEndSelectCondition: null,
  584. maxCount: maxCount,
  585. canNoSelect: true,
  586. canEndNotMax: false,
  587. selectPermanentCoroutine: SelectPermanentCoroutine,
  588. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  589. mode: SelectPermanentEffect.Mode.Custom,
  590. cardEffect: activateClass);
  591. selectPermanentEffect.SetUpCustomMessage($"Select a Tamer that has {element.selectMessage} in digivolution cards.", $"The opponent is selecting a Tamer that has {element.selectMessage} in digivolution cards.");
  592. selectPermanentEffect.SetDigiXros();
  593. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  594. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  595. {
  596. selectedPermanent = permanent;
  597. yield return null;
  598. }
  599. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  600. {
  601. if (permanents.Count == 0)
  602. {
  603. if (digiXrosCondition != null)
  604. {
  605. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  606. {
  607. EndSelectDigiXros();
  608. }
  609. }
  610. }
  611. yield return null;
  612. }
  613. if (selectedPermanent != null)
  614. {
  615. if (selectedPermanent.DigivolutionCards.Count >= 1)
  616. {
  617. maxCount = 1;
  618. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  619. selectCardEffect.SetUp(
  620. canTargetCondition: CanSelectCardCondition,
  621. canTargetCondition_ByPreSelecetedList: null,
  622. canEndSelectCondition: null,
  623. canNoSelect: () => true,
  624. selectCardCoroutine: SelectCardCoroutine,
  625. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  626. message: $"<color=#FF633E>DigiXros</color>: Select {element.selectMessage}.",
  627. maxCount: maxCount,
  628. canEndNotMax: false,
  629. isShowOpponent: true,
  630. mode: SelectCardEffect.Mode.Custom,
  631. root: SelectCardEffect.Root.Custom,
  632. customRootCardList: selectedPermanent.DigivolutionCards,
  633. canLookReverseCard: true,
  634. selectPlayer: card.Owner,
  635. cardEffect: null);
  636. selectCardEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
  637. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digivolution Card");
  638. selectCardEffect.SetDigiXros();
  639. yield return StartCoroutine(selectCardEffect.Activate());
  640. IEnumerator SelectCardCoroutine(CardSource cardSource)
  641. {
  642. selectedDigicrossCards.Add(cardSource);
  643. yield return null;
  644. }
  645. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  646. {
  647. if (cardSources.Count == 0)
  648. {
  649. if (digiXrosCondition != null)
  650. {
  651. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  652. {
  653. EndSelectDigiXros();
  654. }
  655. }
  656. }
  657. yield return null;
  658. }
  659. }
  660. }
  661. }
  662. yield return null;
  663. }
  664. #endregion
  665. #region トラッシュのカードを選択する
  666. IEnumerator SelectTrashCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
  667. {
  668. bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
  669. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  670. {
  671. int maxCount = 1;
  672. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  673. selectCardEffect.SetUp(
  674. canTargetCondition: CanSelectCardCondition,
  675. canTargetCondition_ByPreSelecetedList: null,
  676. canEndSelectCondition: null,
  677. canNoSelect: () => true,
  678. selectCardCoroutine: SelectCardCoroutine,
  679. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  680. message: $"<color=#FF633E>DigiXros</color>: Select {element.selectMessage} from trash.",
  681. maxCount: maxCount,
  682. canEndNotMax: false,
  683. isShowOpponent: true,
  684. mode: SelectCardEffect.Mode.Custom,
  685. root: SelectCardEffect.Root.Trash,
  686. customRootCardList: null,
  687. canLookReverseCard: true,
  688. selectPlayer: card.Owner,
  689. cardEffect: null);
  690. selectCardEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
  691. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Trash Card");
  692. selectCardEffect.SetDigiXros();
  693. yield return StartCoroutine(selectCardEffect.Activate());
  694. IEnumerator SelectCardCoroutine(CardSource cardSource)
  695. {
  696. selectedDigicrossCards.Add(cardSource);
  697. yield return null;
  698. }
  699. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  700. {
  701. if (cardSources.Count == 0)
  702. {
  703. if (digiXrosCondition != null)
  704. {
  705. if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
  706. {
  707. EndSelectDigiXros();
  708. }
  709. }
  710. }
  711. yield return null;
  712. }
  713. }
  714. }
  715. #endregion
  716. #region 選択を終了する
  717. IEnumerator EndSelectDigiXros()
  718. {
  719. _endSelectDigiXros = true;
  720. yield return null;
  721. }
  722. #endregion
  723. #region 選択した進化元を付与
  724. public IEnumerator AddDigivolutiuonCards(CardSource card)
  725. {
  726. if (selectedDigicrossCards.Count >= 1)
  727. {
  728. if (card != null)
  729. {
  730. if (card == playCard)
  731. {
  732. if (card.PermanentOfThisCard() != null)
  733. {
  734. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(selectedDigicrossCards, "Digixros Cards", true, true));
  735. foreach (CardSource cardSource in selectedDigicrossCards)
  736. {
  737. if (isHandCard(cardSource))
  738. {
  739. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
  740. }
  741. else if (isBattleAreaCard(cardSource))
  742. {
  743. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDigiXrosSelectCardEffect(cardSource.PermanentOfThisCard()));
  744. IPlacePermanentToDigivolutionCards placePermanentToDigivolutionCards = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { cardSource.PermanentOfThisCard(), card.PermanentOfThisCard() } }, false, null);
  745. placePermanentToDigivolutionCards.SetNotShowCards();
  746. yield return ContinuousController.instance.StartCoroutine(placePermanentToDigivolutionCards.PlacePermanentToDigivolutionCards());
  747. }
  748. else if (isTrashCard(cardSource))
  749. {
  750. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDigiXrosSelectCardEffect(null, player: cardSource.Owner));
  751. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
  752. }
  753. else if (isTamerDigivolutionCard(cardSource))
  754. {
  755. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, cardSource.PermanentOfThisCard()));
  756. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
  757. }
  758. }
  759. }
  760. }
  761. }
  762. }
  763. ResetSelectDigiXrosClass();
  764. yield return null;
  765. }
  766. #endregion
  767. #region 効果によって進化元を付与(天野ユウ(BT10),シャウトモンX7スペリオルモード(BT12))
  768. public IEnumerator AddDigivolutiuonCardsByEffect(CardSource card)
  769. {
  770. if (addDigivolutionCardInfos.Count >= 1)
  771. {
  772. if (card != null)
  773. {
  774. if (card.PermanentOfThisCard() != null)
  775. {
  776. List<CardSource> addedCards = new List<CardSource>();
  777. foreach (AddDigivolutionCardsInfo info in addDigivolutionCardInfos)
  778. {
  779. List<CardSource> underTamerCards = new List<CardSource>();
  780. List<Permanent> digimonPermanents = new List<Permanent>();
  781. foreach (CardSource cardSource in info.cardSources)
  782. {
  783. if (isTamerDigivolutionCard(cardSource))
  784. {
  785. underTamerCards.Add(cardSource);
  786. addedCards.Add(cardSource);
  787. }
  788. else if (isBattleAreaCard(cardSource))
  789. {
  790. digimonPermanents.Add(cardSource.PermanentOfThisCard());
  791. addedCards.Add(cardSource);
  792. }
  793. }
  794. if (underTamerCards.Count >= 1)
  795. {
  796. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(underTamerCards, info.cardEffect));
  797. }
  798. if (digimonPermanents.Count >= 1)
  799. {
  800. foreach (Permanent digimonPermanent in digimonPermanents)
  801. {
  802. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { digimonPermanent, card.PermanentOfThisCard() } }, false, info.cardEffect).PlacePermanentToDigivolutionCards());
  803. }
  804. }
  805. }
  806. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(addedCards, "Digivolution Cards", true, true));
  807. }
  808. }
  809. }
  810. addDigivolutionCardInfos = new List<AddDigivolutionCardsInfo>();
  811. yield return null;
  812. }
  813. #endregion
  814. int _targetIndex = 0;
  815. bool _endSelect = false;
  816. bool _endSelectDigiXros = false;
  817. [PunRPC]
  818. public void SetTargetDigiXrossIndex(int targetIndex)
  819. {
  820. this._targetIndex = targetIndex;
  821. _endSelect = true;
  822. }
  823. }
  824. public class AddDigivolutionCardsInfo
  825. {
  826. public AddDigivolutionCardsInfo(ICardEffect cardEffect, List<CardSource> cardSources)
  827. {
  828. this.cardEffect = cardEffect;
  829. this.cardSources = new List<CardSource>();
  830. foreach (CardSource cardSource in cardSources)
  831. {
  832. this.cardSources.Add(cardSource);
  833. }
  834. }
  835. public ICardEffect cardEffect { get; private set; } = null;
  836. public List<CardSource> cardSources { get; private set; } = new List<CardSource>();
  837. }