| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using Photon.Pun;
- using System;
- public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
- {
- private static WaitForSeconds _waitForSeconds0_4 = new WaitForSeconds(0.4f);
- private static WaitForSeconds _waitForSeconds0_3 = new WaitForSeconds(0.3f);
- public List<CardSource> selectedDigicrossCards { get; private set; } = new List<CardSource>();
- public List<AddDigivolutionCardsInfo> addDigivolutionCardInfos { get; private set; } = new List<AddDigivolutionCardsInfo>();
- public List<CardSource> excludedCards { get; private set; } = new List<CardSource>();
- 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);
- }
- public void SetExcludedCards(List<CardSource> excluded)
- {
- excludedCards = excluded;
- }
- #region Max Trash Count
- 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 Max Tamer Digivolution Cards Count
- 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 Is Hand Card
- bool isHandCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.Owner.HandCards.Contains(cardSource))
- {
- return true;
- }
- }
- return false;
- }
- #endregion
- #region Is Battle Area Card
- bool isBattleAreaCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.PermanentOfThisCard() != null)
- {
- if (cardSource.Owner.GetBattleAreaPermanents().Contains(cardSource.PermanentOfThisCard()))
- {
- if (cardSource == cardSource.PermanentOfThisCard().TopCard)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region Is Trash Card
- bool isTrashCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (CardEffectCommons.IsExistOnTrash(cardSource))
- {
- return true;
- }
- }
- return false;
- }
- #endregion
- #region Is Security Card
- bool isSecurityCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (CardEffectCommons.IsExistInSecurity(cardSource, false))
- {
- return true;
- }
- }
- return false;
- }
- #endregion
- #region is Tamer Digivolution Card
- bool isTamerDigivolutionCard(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.PermanentOfThisCard() != null)
- {
- if (cardSource.PermanentOfThisCard().IsTamer)
- {
- if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region Can Select DigiXros
- bool CanSelectDigiXros(DigiXrosConditionElement element, CardSource targetCard, CardSource card)
- {
- if (excludedCards.Contains(targetCard))
- return false;
-
- 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 Select
- public IEnumerator Select(CardSource card)
- {
- selectedDigicrossCards = new List<CardSource>();
- playCard = card;
- if (card != null)
- {
- if (card.HasDigiXros)
- {
- DigiXrosCondition digiXrosCondition = card.digiXrosCondition;
- foreach (DigiXrosConditionElement element in digiXrosCondition.elements)
- {
- if (selectedDigicrossCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedDigicrossCards, "DigiXros Cards", false, true));
- }
- if (_endSelectDigiXros)
- {
- _endSelectDigiXros = false;//Reset here in case of leftover from previous digixros
- }
- bool canSelectHand = false;
- if (card.Owner.HandCards.Count((cardSource) => CanSelectDigiXros(element, cardSource, card)) >= 1)
- {
- canSelectHand = true;
- }
- bool canSelectField = false;
- if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => 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;
- }
- }
- IEnumerator _SelectHandCard() => SelectHandCard(digiXrosCondition, element, card);
- IEnumerator _SelectBattleAreaDigimon() => SelectBattleAreaPermanent(digiXrosCondition, element, card);
- IEnumerator _SelectTrashCard() => SelectTrashCard(digiXrosCondition, element, card);
- IEnumerator _SelectTamerDigivolutionCard() => SelectTamerDigivolutionCard(digiXrosCondition, element, card);
- 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 && !element.skipAllIfNoSelect)
- {
- SetTargetDigiXrossIndex(card.Owner.PlayerID, 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, card.Owner.PlayerID, 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(card.Owner.PlayerID, UnityEngine.Random.Range(0, indexes.Count));
- }
- #endregion
- }
- }
- yield return new WaitUntil(() => card.Owner.HasPlayerSelection());
- ValueSelection seletion = card.Owner.DequeuePlayerSelection<ValueSelection>();
- _targetIndex = seletion != null ? seletion.ValueAsInt() : 0;
- 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 (_endSelectDigiXros)
- {
- break;//Perform here where the value will only just have been set by the above routine
- }
- if (!card.Owner.isYou && GManager.instance.IsAI)
- {
- yield return _waitForSeconds0_3;
- }
- }
- }
- }
- }
- if (selectedDigicrossCards.Count >= 1)
- {
- yield return _waitForSeconds0_4;
- }
- GManager.instance.GetComponent<Effects>().OffShowCard2();
- }
- #endregion
- #region Select Hand Card
- 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)
- {
- StartCoroutine(EndSelectDigiXros());
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region Select Battle Area Permanent
- IEnumerator SelectBattleAreaPermanent(DigiXrosCondition digiXrosCondition, DigiXrosConditionElement element, CardSource card)
- {
- bool CanSelectPermanentCondition(Permanent permanent) => permanent.TopCard.Owner.GetBattleAreaPermanents().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)
- {
- StartCoroutine(EndSelectDigiXros());
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region Select Tamer Digivolution Card
- 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)
- {
- StartCoroutine(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)
- {
- StartCoroutine(EndSelectDigiXros());
- }
- }
- }
- yield return null;
- }
- }
- }
- }
- yield return null;
- }
- #endregion
- #region Select Trash Card
- 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)
- {
- StartCoroutine(EndSelectDigiXros());
- }
- }
- }
- yield return null;
- }
- }
- }
- #endregion
- #region End Select DigiXros
- IEnumerator EndSelectDigiXros()
- {
- _endSelectDigiXros = true;
- yield return null;
- }
- #endregion
- #region Add Digivolution Cards
- 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, isDigixros: true);
- 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));
- }
- cardSource.cEntity_EffectController.InitUseCountThisTurn();
- }
- }
- }
- }
- }
- 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>();
- List<CardSource> trashCards = new List<CardSource>();
- List<CardSource> secuirtyCards = new List<CardSource>();
- 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);
- }
- else if (isTrashCard(cardSource))
- {
- trashCards.Add(cardSource);
- addedCards.Add(cardSource);
- }
- else if (isSecurityCard(cardSource))
- {
- secuirtyCards.Add(cardSource);
- 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, isDigixros: true).PlacePermanentToDigivolutionCards());
- }
- }
- if (trashCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(trashCards, info.cardEffect));
- }
- if (secuirtyCards.Count >= 1)
- {
- yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(secuirtyCards, info.cardEffect));
- }
- }
- 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 _endSelectDigiXros = false;
- [PunRPC]
- public void SetTargetDigiXrossIndex(int playerID, int targetIndex)
- {
- Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
- if (selectionPlayer == null)
- {
- return;
- }
- selectionPlayer.QueuePlayerSelection(new ValueSelection(targetIndex));
- }
- }
- 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>();
- }
|