| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using Photon;
- using Photon.Pun;
- using System;
- using UnityEngine.Events;
- public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
- {
- public List<CardSource> selectedDigicrossCards { get; private set; } = new List<CardSource>();
- public List<AddDigivolutionCardsInfo> addDigivolutionCardInfos { get; private set; } = new List<AddDigivolutionCardsInfo>();
- public CardSource playCard { get; private set; } = null;
- public void ResetSelectDigiXrosClass()
- {
- selectedDigicrossCards = new List<CardSource>();
- addDigivolutionCardInfos = new List<AddDigivolutionCardsInfo>();
- playCard = null;
- }
- public void AddDigivolutionCardInfos(AddDigivolutionCardsInfo digivolutionCardsInfo)
- {
- addDigivolutionCardInfos.Add(digivolutionCardsInfo);
- }
- #region トラッシュのカードをデジクロスに選択できる最大枚数
- int maxTrashCount(CardSource card)
- {
- int maxTrashCount = 0;
- if (card != null)
- {
- List<int> maxTrashCountList = new List<int>();
- #region 選択可能トラッシュ枚数を変更する効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- #region 場のパーマネントの効果
- foreach (Permanent permanent in player.GetBattleAreaPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
- if (count >= 1)
- {
- maxTrashCountList.Add(count);
- }
- }
- }
- }
- }
- #endregion
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
- if (count >= 1)
- {
- maxTrashCountList.Add(count);
- }
- }
- }
- }
- #endregion
- }
- #region カード自身の効果
- if (card.PermanentOfThisCard() == null)
- {
- foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxTrashCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxTrashCountDigiXrosEffect)cardEffect).GetMaxTrashCount(card);
- if (count >= 1)
- {
- maxTrashCountList.Add(count);
- }
- }
- }
- }
- }
- #endregion
- #endregion
- if (maxTrashCountList.Count >= 1)
- {
- maxTrashCount = maxTrashCountList.Max();
- }
- if (maxTrashCount > card.Owner.TrashCards.Count)
- {
- maxTrashCount = card.Owner.TrashCards.Count;
- }
- if (maxTrashCount < 0)
- {
- maxTrashCount = 0;
- }
- }
- return maxTrashCount;
- }
- #endregion
- #region テイマーの進化元のカードをデジクロスに選択できる最大枚数
- int maxTamerDigivolutionCardsCount(CardSource card)
- {
- int maxTamerDigivolutionCardsCount = 0;
- if (card != null)
- {
- List<int> maxTamerDigivolutionCardsCountList = new List<int>();
- #region 選択可能テイマー進化元枚数を変更する効果
- foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
- {
- #region 場のパーマネントの効果
- foreach (Permanent permanent in player.GetBattleAreaPermanents())
- {
- foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
- if (count >= 1)
- {
- maxTamerDigivolutionCardsCountList.Add(count);
- }
- }
- }
- }
- }
- #endregion
- #region プレイヤーの効果
- foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
- if (count >= 1)
- {
- maxTamerDigivolutionCardsCountList.Add(count);
- }
- }
- }
- }
- #endregion
- }
- #region カード自身の効果
- if (card.PermanentOfThisCard() == null)
- {
- foreach (ICardEffect cardEffect in card.EffectList(EffectTiming.None))
- {
- if (cardEffect is IAddMaxUnderTamerCountDigiXrosEffect)
- {
- if (cardEffect.CanUse(null))
- {
- int count = ((IAddMaxUnderTamerCountDigiXrosEffect)cardEffect).getMaxUnderTamerCount(card);
- if (count >= 1)
- {
- maxTamerDigivolutionCardsCountList.Add(count);
- }
- }
- }
- }
- }
- #endregion
- #endregion
- if (maxTamerDigivolutionCardsCountList.Count >= 1)
- {
- maxTamerDigivolutionCardsCount = maxTamerDigivolutionCardsCountList.Max();
- }
- if (maxTamerDigivolutionCardsCount < 0)
- {
- maxTamerDigivolutionCardsCount = 0;
- }
- }
- return maxTamerDigivolutionCardsCount;
- }
- #endregion
- #region 手札のカードか
- bool isHandCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.Owner.HandCards.Contains(cardSource))
- {
- if (cardSource.IsDigimon)
- {
- return true;
- }
- }
- }
- return false;
- }
- #endregion
- #region バトルエリアのカードか
- bool isBattleAreaCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.PermanentOfThisCard() != null)
- {
- if (cardSource.Owner.GetBattleAreaDigimons().Contains(cardSource.PermanentOfThisCard()))
- {
- if (cardSource == cardSource.PermanentOfThisCard().TopCard)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region トラッシュのカードか
- bool isTrashCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (CardEffectCommons.IsExistOnTrash(cardSource))
- {
- if (cardSource.IsDigimon)
- {
- return true;
- }
- }
- }
- return false;
- }
- #endregion
- #region テイマーの進化元か
- bool isTamerDigivolutionCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.PermanentOfThisCard() != null)
- {
- if (cardSource.PermanentOfThisCard().IsTamer)
- {
- if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
- {
- if (cardSource.IsDigimon)
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region デジクロスの素材として選択できる
- bool CanSelectDigiXros(DigiXrosConditionElement element, CardSource targetCard, CardSource card)
- {
- if (card != targetCard)
- {
- if (card != null)
- {
- if (element != null)
- {
- if (element.CardCondition != null)
- {
- if (targetCard != null)
- {
- if (card.digiXrosCondition != null)
- {
- if (!targetCard.IsToken)
- {
- if (!selectedDigicrossCards.Contains(targetCard))
- {
- if (addDigivolutionCardInfos.Count((addDigivolutionCardInfo) => addDigivolutionCardInfo.cardSources.Contains(targetCard)) == 0)
- {
- if (card.digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null)
- {
- if (!card.digiXrosCondition.CanTargetCondition_ByPreSelecetedList(selectedDigicrossCards, targetCard))
- {
- return false;
- }
- }
- if (element.CardCondition(targetCard))
- {
- return true;
- }
- if (targetCard.PermanentOfThisCard() != null)
- {
- if (targetCard == targetCard.PermanentOfThisCard().TopCard)
- {
- if (targetCard.PermanentOfThisCard().CanSubstituteForDigiXrosCondition(card))
- {
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region デジクロス選択
- public IEnumerator Select(CardSource card)
- {
- GManager.instance.turnStateMachine.isSync = true;
- selectedDigicrossCards = new List<CardSource>();
- playCard = card;
- if (card != null)
- {
- if (card.HasDigiXros)
- {
- DigiXrosCondition digiXrosCondition = card.digiXrosCondition;
- foreach (DigiXrosConditionElement element in digiXrosCondition.elements)
- {
- yield return GManager.instance.photonWaitController.StartWait("SelectDigiXross");
- if (selectedDigicrossCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedDigicrossCards, "DigiXros Cards", false, true));
- }
- if (_endSelectDigiXros)
- {
- _endSelectDigiXros = false;
- break;
- }
- bool canSelectHand = false;
- if (card.Owner.HandCards.Count((cardSource) => CanSelectDigiXros(element, cardSource, card)) >= 1)
- {
- canSelectHand = true;
- }
- bool canSelectField = false;
- if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && CanSelectDigiXros(element, permanent.TopCard, card)))
- {
- canSelectField = true;
- }
- bool canSelectTrash = false;
- if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectDigiXros(element, cardSource, card)))
- {
- if (selectedDigicrossCards.Count(isTrashCard) < maxTrashCount(card))
- {
- canSelectTrash = true;
- }
- }
- bool canSelectTamer = false;
- if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer && permanent.DigivolutionCards.Count((cardSource) => CanSelectDigiXros(element, cardSource, card)) >= 1))
- {
- if (selectedDigicrossCards.Count(isTamerDigivolutionCard) < maxTamerDigivolutionCardsCount(card))
- {
- canSelectTamer = true;
- }
- }
- Func<IEnumerator> _SelectHandCard = () => SelectHandCard(digiXrosCondition, element, card);
- Func<IEnumerator> _SelectBattleAreaDigimon = () => SelectBattleAreaDigimon(digiXrosCondition, element, card);
- Func<IEnumerator> _SelectTrashCard = () => SelectTrashCard(digiXrosCondition, element, card);
- Func<IEnumerator> _SelectTamerDigivolutionCard = () => SelectTamerDigivolutionCard(digiXrosCondition, element, card);
- Func<IEnumerator> _EndSelectDigiXros = () => EndSelectDigiXros();
- List<Func<IEnumerator>> actions = new List<Func<IEnumerator>>() { _SelectHandCard, _SelectBattleAreaDigimon, _SelectTrashCard, _SelectTamerDigivolutionCard, _EndSelectDigiXros };
- List<Func<IEnumerator>> canSelectActions = new List<Func<IEnumerator>>();
- if (canSelectHand)
- {
- canSelectActions.Add(_SelectHandCard);
- }
- if (canSelectField)
- {
- canSelectActions.Add(_SelectBattleAreaDigimon);
- }
- if (canSelectTrash)
- {
- canSelectActions.Add(_SelectTrashCard);
- }
- if (canSelectTamer)
- {
- canSelectActions.Add(_SelectTamerDigivolutionCard);
- }
- canSelectActions.Add(_EndSelectDigiXros);
- if (canSelectActions.Count == 1)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- break;
- }
- else
- {
- continue;
- }
- }
- else if (canSelectActions.Count == 2 && digiXrosCondition.CanTargetCondition_ByPreSelecetedList == null && !element.skipAllIfNoSelect)
- {
- SetTargetDigiXrossIndex(actions.IndexOf(canSelectActions[0]));
- }
- else
- {
- if (card.Owner.isYou)
- {
- GManager.instance.commandText.OpenCommandText($"From which area will you select {element.selectMessage}?", digiXros: true);
- List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>();
- for (int i = 0; i < canSelectActions.Count; i++)
- {
- int k = actions.IndexOf(canSelectActions[i]);
- int spriteIndex = 0;
- string message = "";
- switch (k)
- {
- case 0:
- message = "Hand";
- break;
- case 1:
- message = "Field Digimon";
- break;
- case 2:
- message = "Trash";
- break;
- case 3:
- message = "Tamer digivolution cards";
- break;
- case 4:
- message = "End Selection";
- spriteIndex = 1;
- break;
- }
- command_SelectCommands.Add(new Command_SelectCommand(message, () => photonView.RPC("SetTargetDigiXrossIndex", RpcTarget.All, k), spriteIndex));
- }
- GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
- }
- else
- {
- GManager.instance.commandText.OpenCommandText($"The opponent is choosing from which area to select {element.selectMessage}.", digiXros: true);
- #region AIモード
- if (GManager.instance.IsAI)
- {
- List<int> indexes = new List<int>();
- for (int i = 0; i < canSelectActions.Count; i++)
- {
- int k = actions.IndexOf(canSelectActions[i]);
- indexes.Add(k);
- }
- SetTargetDigiXrossIndex(UnityEngine.Random.Range(0, indexes.Count));
- }
- #endregion
- }
- }
- yield return new WaitWhile(() => !_endSelect);
- _endSelect = false;
- GManager.instance.commandText.CloseCommandText();
- yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
- if (0 <= _targetIndex && _targetIndex <= actions.Count - 1)
- {
- yield return ContinuousController.instance.StartCoroutine(actions[_targetIndex]());
- if (!card.Owner.isYou && GManager.instance.IsAI)
- {
- yield return new WaitForSeconds(0.3f);
- }
- }
- }
- }
- }
- if (selectedDigicrossCards.Count >= 1)
- {
- yield return new WaitForSeconds(0.4f);
- }
- GManager.instance.GetComponent<Effects>().OffShowCard2();
- GManager.instance.turnStateMachine.isSync = false;
- }
- #endregion
- #region 手札のカードを選択する
- IEnumerator SelectHandCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
- {
- bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
- if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
- {
- int maxCount = 1;
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: true,
- canEndNotMax: false,
- isShowOpponent: true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- mode: SelectHandEffect.Mode.Custom,
- cardEffect: null);
- selectHandEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
- selectHandEffect.SetUpCustomMessage_ShowCard("Selected Hand Card");
- selectHandEffect.SetDigiXros();
- yield return StartCoroutine(selectHandEffect.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedDigicrossCards.Add(cardSource);
- yield return null;
- }
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- if (cardSources.Count == 0)
- {
- if (digiXrosCondition != null)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- EndSelectDigiXros();
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region 場のデジモンのカードを選択する
- IEnumerator SelectBattleAreaDigimon(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
- {
- bool CanSelectPermanentCondition(Permanent permanent) => permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent) && CanSelectDigiXros(element, permanent.TopCard, card);
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("", null, card);
- if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
- {
- int maxCount = 1;
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermanentCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectPermanentEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
- selectPermanentEffect.SetDigiXros();
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- selectedDigicrossCards.Add(permanent.TopCard);
- yield return null;
- }
- IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
- {
- if (permanents.Count == 0)
- {
- if (digiXrosCondition != null)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- EndSelectDigiXros();
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region テイマーの進化元を選択する
- IEnumerator SelectTamerDigivolutionCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
- {
- bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
- bool CanSelectPermanentCondition(Permanent permanent) => permanent.TopCard.Owner == card.Owner && permanent.IsTamer && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("", null, card);
- if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
- {
- Permanent selectedPermanent = null;
- int maxCount = 1;
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermanentCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- 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.");
- selectPermanentEffect.SetDigiXros();
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- selectedPermanent = permanent;
- yield return null;
- }
- IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
- {
- if (permanents.Count == 0)
- {
- if (digiXrosCondition != null)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- EndSelectDigiXros();
- }
- }
- }
- yield return null;
- }
- if (selectedPermanent != null)
- {
- if (selectedPermanent.DigivolutionCards.Count >= 1)
- {
- maxCount = 1;
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- message: $"<color=#FF633E>DigiXros</color>: Select {element.selectMessage}.",
- maxCount: maxCount,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: selectedPermanent.DigivolutionCards,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: null);
- selectCardEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digivolution Card");
- selectCardEffect.SetDigiXros();
- yield return StartCoroutine(selectCardEffect.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedDigicrossCards.Add(cardSource);
- yield return null;
- }
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- if (cardSources.Count == 0)
- {
- if (digiXrosCondition != null)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- EndSelectDigiXros();
- }
- }
- }
- yield return null;
- }
- }
- }
- }
- yield return null;
- }
- #endregion
- #region トラッシュのカードを選択する
- IEnumerator SelectTrashCard(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
- {
- bool CanSelectCardCondition(CardSource cardSource) => CanSelectDigiXros(element, cardSource, card);
- if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
- {
- int maxCount = 1;
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- message: $"<color=#FF633E>DigiXros</color>: Select {element.selectMessage} from trash.",
- maxCount: maxCount,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Trash,
- customRootCardList: null,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: null);
- selectCardEffect.SetUpCustomMessage($"Select {element.selectMessage}.", $"The opponent is selecting {element.selectMessage}.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Selected Trash Card");
- selectCardEffect.SetDigiXros();
- yield return StartCoroutine(selectCardEffect.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedDigicrossCards.Add(cardSource);
- yield return null;
- }
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- if (cardSources.Count == 0)
- {
- if (digiXrosCondition != null)
- {
- if (digiXrosCondition.CanTargetCondition_ByPreSelecetedList != null || element.skipAllIfNoSelect)
- {
- EndSelectDigiXros();
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region 選択を終了する
- IEnumerator EndSelectDigiXros()
- {
- _endSelectDigiXros = true;
- yield return null;
- }
- #endregion
- #region 選択した進化元を付与
- public IEnumerator AddDigivolutiuonCards(CardSource card)
- {
- if (selectedDigicrossCards.Count >= 1)
- {
- if (card != null)
- {
- if (card == playCard)
- {
- if (card.PermanentOfThisCard() != null)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(selectedDigicrossCards, "Digixros Cards", true, true));
- foreach (CardSource cardSource in selectedDigicrossCards)
- {
- if (isHandCard(cardSource))
- {
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
- }
- else if (isBattleAreaCard(cardSource))
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDigiXrosSelectCardEffect(cardSource.PermanentOfThisCard()));
- IPlacePermanentToDigivolutionCards placePermanentToDigivolutionCards = new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { cardSource.PermanentOfThisCard(), card.PermanentOfThisCard() } }, false, null);
- placePermanentToDigivolutionCards.SetNotShowCards();
- yield return ContinuousController.instance.StartCoroutine(placePermanentToDigivolutionCards.PlacePermanentToDigivolutionCards());
- }
- else if (isTrashCard(cardSource))
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDigiXrosSelectCardEffect(null, player: cardSource.Owner));
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
- }
- else if (isTamerDigivolutionCard(cardSource))
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, cardSource.PermanentOfThisCard()));
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, null));
- }
- }
- }
- }
- }
- }
- ResetSelectDigiXrosClass();
- yield return null;
- }
- #endregion
- #region 効果によって進化元を付与(天野ユウ(BT10),シャウトモンX7スペリオルモード(BT12))
- public IEnumerator AddDigivolutiuonCardsByEffect(CardSource card)
- {
- if (addDigivolutionCardInfos.Count >= 1)
- {
- if (card != null)
- {
- if (card.PermanentOfThisCard() != null)
- {
- List<CardSource> addedCards = new List<CardSource>();
- foreach (AddDigivolutionCardsInfo info in addDigivolutionCardInfos)
- {
- List<CardSource> underTamerCards = new List<CardSource>();
- List<Permanent> digimonPermanents = new List<Permanent>();
- foreach (CardSource cardSource in info.cardSources)
- {
- if (isTamerDigivolutionCard(cardSource))
- {
- underTamerCards.Add(cardSource);
- addedCards.Add(cardSource);
- }
- else if (isBattleAreaCard(cardSource))
- {
- digimonPermanents.Add(cardSource.PermanentOfThisCard());
- addedCards.Add(cardSource);
- }
- }
- if (underTamerCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(underTamerCards, info.cardEffect));
- }
- if (digimonPermanents.Count >= 1)
- {
- foreach (Permanent digimonPermanent in digimonPermanents)
- {
- yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { digimonPermanent, card.PermanentOfThisCard() } }, false, info.cardEffect).PlacePermanentToDigivolutionCards());
- }
- }
- }
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(addedCards, "Digivolution Cards", true, true));
- }
- }
- }
- addDigivolutionCardInfos = new List<AddDigivolutionCardsInfo>();
- yield return null;
- }
- #endregion
- int _targetIndex = 0;
- bool _endSelect = false;
- bool _endSelectDigiXros = false;
- [PunRPC]
- public void SetTargetDigiXrossIndex(int targetIndex)
- {
- this._targetIndex = targetIndex;
- _endSelect = true;
- }
- }
- public class AddDigivolutionCardsInfo
- {
- public AddDigivolutionCardsInfo(ICardEffect cardEffect, List<CardSource> cardSources)
- {
- this.cardEffect = cardEffect;
- this.cardSources = new List<CardSource>();
- foreach (CardSource cardSource in cardSources)
- {
- this.cardSources.Add(cardSource);
- }
- }
- public ICardEffect cardEffect { get; private set; } = null;
- public List<CardSource> cardSources { get; private set; } = new List<CardSource>();
- }
|