| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052 |
- 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 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;
- }
- }
- Func<IEnumerator> _SelectHandCard = () => SelectHandCard(digiXrosCondition, element, card);
- Func<IEnumerator> _SelectBattleAreaDigimon = () => SelectBattleAreaPermanent(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 && !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 new WaitForSeconds(0.3f);
- }
- }
- }
- }
- }
- if (selectedDigicrossCards.Count >= 1)
- {
- yield return new WaitForSeconds(0.4f);
- }
- 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)
- {
- 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)
- {
- 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)
- {
- 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 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)
- {
- 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>();
- }
|