Просмотр исходного кода

Prevent selecting cards played simultaneously as valid digixros/assembly targets

hooperk 3 месяцев назад
Родитель
Сommit
9ad2bf65e4

+ 4 - 0
Assets/Scripts/Script/CardController.cs

@@ -745,6 +745,7 @@ public class PlayCardClass
 
                 if (card.HasDigiXros && !isEvolution)
                 {
+                    GManager.instance.GetComponent<SelectDigiXrosClass>().SetExcludedCards(CardSources);
                     yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<SelectDigiXrosClass>().Select(card));
                 }
 
@@ -754,6 +755,7 @@ public class PlayCardClass
 
                 if (card.HasAssembly && !isEvolution)
                 {
+                    GManager.instance.GetComponent<SelectAssemblyClass>().SetExcludedCards(CardSources);
                     yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<SelectAssemblyClass>().Select(card));
                 }
 
@@ -1233,6 +1235,7 @@ public class PlayPermanentClass
 
                 if (card.HasDigiXros && !isEvolution)
                 {
+                    GManager.instance.GetComponent<SelectDigiXrosClass>().SetExcludedCards(_cardSources);
                     yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<SelectDigiXrosClass>().Select(card));
                 }
 
@@ -1242,6 +1245,7 @@ public class PlayPermanentClass
 
                 if (card.HasAssembly && !isEvolution)
                 {
+                    GManager.instance.GetComponent<SelectAssemblyClass>().SetExcludedCards(_cardSources);
                     yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<SelectAssemblyClass>().Select(card));
                 }
 

+ 9 - 0
Assets/Scripts/Script/SelectAssemblyClass.cs

@@ -11,6 +11,7 @@ public class SelectAssemblyClass : MonoBehaviourPunCallbacks
 {
     public List<CardSource> selectedAssemblyCards { 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 ResetSelectAssemblyClass()
@@ -25,6 +26,11 @@ public class SelectAssemblyClass : MonoBehaviourPunCallbacks
         addDigivolutionCardInfos.Add(digivolutionCardsInfo);
     }
 
+    public void SetExcludedCards(List<CardSource> excluded)
+    {
+        excludedCards = excluded;
+    }
+
     #region Is Trash Card
     bool isTrashCard(CardSource cardSource)
     {
@@ -43,6 +49,9 @@ public class SelectAssemblyClass : MonoBehaviourPunCallbacks
     #region Can Select Assembly
     bool CanSelectAssembly(AssemblyConditionElement element, CardSource targetCard, CardSource card)
     {
+        if (excludedCards.Contains(targetCard))
+            return false;
+
         if (card != targetCard)
         {
             if (card != null)

+ 9 - 0
Assets/Scripts/Script/SelectDigiXrosClass.cs

@@ -11,6 +11,7 @@ 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()
@@ -25,6 +26,11 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
         addDigivolutionCardInfos.Add(digivolutionCardsInfo);
     }
 
+    public void SetExcludedCards(List<CardSource> excluded)
+    {
+        excludedCards = excluded;
+    }
+
     #region Max Trash Count
     int maxTrashCount(CardSource card)
     {
@@ -300,6 +306,9 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
     #region Can Select DigiXros
     bool CanSelectDigiXros(DigiXrosConditionElement element, CardSource targetCard, CardSource card)
     {
+        if (excludedCards.Contains(targetCard))
+            return false;
+            
         if (card != targetCard)
         {
             if (card != null)