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

Added OnReturnCardsToHandFromTrash timing

mbunch_kascope 2 лет назад
Родитель
Сommit
314aeb0286

+ 2 - 108
Assets/CardEffect/BT15/Red/Sora_Takenouchi_BT15_082.cs

@@ -17,117 +17,11 @@ public class Sora_Takenouchi_BT15_082 : CEntity_Effect
             cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
             cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
         }
         }
 
 
-        if(timing == EffectTiming.WhenReturntoHandAnyone)
+        if(timing == EffectTiming.OnReturnCardsToHandFromTrash)
         {
         {
-            ActivateClass activateClass = new ActivateClass();
-            activateClass.SetUpICardEffect("Return this Tamer to your hand to play a Digimon from your hand.", CanUseCondition, card);
-            activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
-            cardEffects.Add(activateClass);
-
-            string EffectDiscription()
-            {
-                return "[All Turns] When a red Digimon card returns from your trash to the hand, by returning this Tamer to the hand, you may play 1 13000 DP or less red Digimon card with [Avian], [Bird], [Beast], [Animal] or [Sovereign], other than [Sea Animal] in one of its traits from your hand without paying the cost. For each of your opponent's security cards, remove 2000 from this effect's playable card's DP maximum.";
-            }
-
-            bool CanSelectPermanentCondition(Permanent permanent)
-            {
-                return permanent.TopCard == card;
-            }
-
-            bool CanUseCondition(Hashtable hashtable)
-            {
-                if (CardEffectCommons.IsExistOnBattleArea(card))
-                {
-                    if (hashtable.ContainsKey("Permanents"))
-                    {
-                        List<Permanent> Permanents = (List<Permanent>)hashtable["Permanents"];
-
-                        if (Permanents != null)
-                        {
-                            if (Permanents.Count((permanent) => permanent.TopCard.CardColors.Contains(CardColor.Red)) >= 1)
-                            {
-                                return true;
-                            }
-                        }
-                    }
-                }
-
-                return false;
-            }
-
-            bool CanActivateCondition(Hashtable hashtable)
-            {
-                if (CardEffectCommons.IsExistOnBattleArea(card))
-                {
-                        return true;
-                }
-
-                return false;
-            }
-
-            IEnumerator ActivateCoroutine(Hashtable _hashtable)
-            {
-                Permanent bounceTargetPermanent = null;
-
-                SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
-
-                selectPermanentEffect.SetUp(
-                    selectPlayer: card.Owner,
-                    canTargetCondition: CanSelectPermanentCondition,
-                    canTargetCondition_ByPreSelecetedList: null,
-                    canEndSelectCondition: null,
-                    maxCount: 1,
-                    canNoSelect: true,
-                    canEndNotMax: false,
-                    selectPermanentCoroutine: SelectPermanentCoroutine,
-                    afterSelectPermanentCoroutine: null,
-                    mode: SelectPermanentEffect.Mode.Custom,
-                    cardEffect: activateClass);
-
-                selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to return to hand.", "The opponent is selecting 1 tamer to return to hand.");
-
-                yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                IEnumerator SelectPermanentCoroutine(Permanent permanent)
-                {
-                    bounceTargetPermanent = permanent;
-
-                    yield return null;
-                }
-
-                if (bounceTargetPermanent != null)
-                {
-                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
-                        targetPermanents: new List<Permanent>() { bounceTargetPermanent },
-                        activateClass: activateClass,
-                        successProcess: SuccessProcess(),
-                        failureProcess: null));
-
-                    IEnumerator SuccessProcess()
-                    {
-                        Debug.Log("Successful Return: Select and Play out digimon");
-                        yield return null;
-                    }
-                }
-            }
+            Debug.Log("CARD WAS ADDED TO HAND");
         }
         }
 
 
-        /*
-        if(timing == EffectTiming.None)
-        {
-            ActivateClass activateClass = new ActivateClass();
-            activateClass.SetUpICardEffect("Return this Tamer to your hand to play a Digimon from your hand.", CanUseCondition, card);
-            activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
-            cardEffects.Add(activateClass);
-
-            string EffectDiscription()
-            {
-                return "[All Turns] When a red Digimon card returns from your trash to the hand, by returning this Tamer to the hand, you may play 1 13000 DP or lower red Digimon card with [Avian], [Bird], [Beast], [Animal], [Sovereign] in one of its traits, other than [Sea Animal] from your hand without paying the cost. For each of your opponent's security cards, remove 2000 from this effect's playable card's DP maximum.";
-            }
-
-
-        }
-        */
         return cardEffects;    
         return cardEffects;    
     }
     }
 }
 }

+ 38 - 0
Assets/Scripts/CardEffectCommons/CanUseEffects/OnCardsReturnToHandFromTrash.cs

@@ -0,0 +1,38 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Can trigger "When your cards return to Hand from tash" effects
+
+    public static bool CanTriggerWhenOwnerCardsReturnToHandFromTrash(Hashtable hashtable, Func<CardSource, bool> cardCondition, CardSource card)
+    {
+        bool CardCondition(CardSource cardSource) => cardSource.Owner == card.Owner && (cardCondition == null || cardCondition(cardSource));
+
+        return CanTriggerWhenCardsReturnToHandFromTrash(hashtable, CardCondition, card);
+    }
+    #endregion
+
+    #region Can trigger "When cards return to hand from tash" effects
+
+    public static bool CanTriggerWhenCardsReturnToHandFromTrash(Hashtable hashtable, Func<CardSource, bool> cardCondition, CardSource card)
+    {
+        List<CardSource> CardSources = GetCardSourcesFromHashtable(hashtable);
+
+        if (CardSources != null)
+        {
+            CardSources = CardSources.Filter(cardSource => !cardSource.IsDigiEgg && (cardCondition == null || cardCondition(cardSource)));
+
+            if (CardSources.Count >= 1)
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/CanUseEffects/OnCardsReturnToHandFromTrash.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 031a7c9303623e546b03be5bef9a6fc2
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 32 - 15
Assets/Scripts/CardObjectController.cs

@@ -12,7 +12,7 @@ using DG.Tweening;
 //Card-related operations
 //Card-related operations
 public class CardObjectController : MonoBehaviour
 public class CardObjectController : MonoBehaviour
 {
 {
-    #region お互いのプレイヤーのデッキのカードを生成する
+    #region Generate cards for each player's deck
     public static IEnumerator CreatePlayerDecks(CardSource CardPrefab, GameContext gameContext)
     public static IEnumerator CreatePlayerDecks(CardSource CardPrefab, GameContext gameContext)
     {
     {
 
 
@@ -343,7 +343,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードを生成
+    #region generate card
     public static CardSource CreateCardSource(int _PlayerID, CEntity_Base cEntity_Base, bool isToken)
     public static CardSource CreateCardSource(int _PlayerID, CEntity_Base cEntity_Base, bool isToken)
     {
     {
         Player player = GManager.instance.turnStateMachine.gameContext.PlayerFromID(_PlayerID);
         Player player = GManager.instance.turnStateMachine.gameContext.PlayerFromID(_PlayerID);
@@ -366,7 +366,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードをすべての領域から取り除く
+    #region Remove cards from all areas
     public static IEnumerator RemoveFromAllArea(CardSource cardSource)
     public static IEnumerator RemoveFromAllArea(CardSource cardSource)
     {
     {
         cardSource.SetFace();
         cardSource.SetFace();
@@ -500,7 +500,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region 場を離れさせる
+    #region leave the place
     public static IEnumerator RemoveField(Permanent permanent, bool ignoreOverflow = false)
     public static IEnumerator RemoveField(Permanent permanent, bool ignoreOverflow = false)
     {
     {
         if (permanent == null) yield break;
         if (permanent == null) yield break;
@@ -538,13 +538,30 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードを手札に加える
+    #region add card to hand
     public static IEnumerator AddHandCards(List<CardSource> cardSources, bool isDraw, ICardEffect cardEffect)
     public static IEnumerator AddHandCards(List<CardSource> cardSources, bool isDraw, ICardEffect cardEffect)
     {
     {
         if (cardSources.Count == 0) yield break;
         if (cardSources.Count == 0) yield break;
 
 
+        bool isFromTrash = cardSources.Some(cardSource => CardEffectCommons.IsExistOnTrash(cardSource));
+
         cardSources = cardSources.Filter(cardSource => cardSource != null && !cardSource.Owner.HandCards.Contains(cardSource));
         cardSources = cardSources.Filter(cardSource => cardSource != null && !cardSource.Owner.HandCards.Contains(cardSource));
 
 
+        if (isFromTrash)
+        {
+            #region "Effect of "When a card is returned from the trash to the hand"
+
+            #region Hashtable Setting
+            System.Collections.Hashtable hashtable = new System.Collections.Hashtable()
+            {
+                {"CardSources", cardSources}
+            };
+            #endregion
+
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnReturnCardsToHandFromTrash));
+            #endregion
+        }
+
         foreach (CardSource cardSource in cardSources)
         foreach (CardSource cardSource in cardSources)
         {
         {
             if (cardSource.IsToken)
             if (cardSource.IsToken)
@@ -675,7 +692,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードをトラッシュに置く
+    #region put the card in the trash
     public static IEnumerator AddTrashCard(CardSource cardSource)
     public static IEnumerator AddTrashCard(CardSource cardSource)
     {
     {
         if (!CardEffectCommons.IsExistOnTrash(cardSource))
         if (!CardEffectCommons.IsExistOnTrash(cardSource))
@@ -697,7 +714,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードをまとめてトラッシュに置く
+    #region Put the cards together in the trash
     public static IEnumerator AddTrashCards(List<CardSource> cardSources)
     public static IEnumerator AddTrashCards(List<CardSource> cardSources)
     {
     {
         List<CardSource> handCards = new List<CardSource>();
         List<CardSource> handCards = new List<CardSource>();
@@ -739,7 +756,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードを山札の上に置く
+    #region place a card on top of the deck
     public static IEnumerator AddLibraryTopCards(List<CardSource> cardSources, bool notAddLog = false)
     public static IEnumerator AddLibraryTopCards(List<CardSource> cardSources, bool notAddLog = false)
     {
     {
         if (cardSources.Count <= 0) yield break;
         if (cardSources.Count <= 0) yield break;
@@ -750,7 +767,7 @@ public class CardObjectController : MonoBehaviour
 
 
         if (isFromTrash)
         if (isFromTrash)
         {
         {
-            #region "カードがトラッシュから山札に戻った時"の効果
+            #region "Effect of "When a card is returned from the trash to the deck"
 
 
             #region Hashtable Setting
             #region Hashtable Setting
             System.Collections.Hashtable hashtable = new System.Collections.Hashtable()
             System.Collections.Hashtable hashtable = new System.Collections.Hashtable()
@@ -821,7 +838,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードを山札の下に置く
+    #region put a card at the bottom of the deck
     public static IEnumerator AddLibraryBottomCards(List<CardSource> cardSources, bool notAddLog = false)
     public static IEnumerator AddLibraryBottomCards(List<CardSource> cardSources, bool notAddLog = false)
     {
     {
         if (cardSources.Count <= 0) yield break;
         if (cardSources.Count <= 0) yield break;
@@ -915,7 +932,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードを処理領域に置く
+    #region Place the card in the processing area
     public static IEnumerator AddExecutingCard(CardSource cardSource)
     public static IEnumerator AddExecutingCard(CardSource cardSource)
     {
     {
         if (!cardSource.Owner.ExecutingCards.Contains(cardSource))
         if (!cardSource.Owner.ExecutingCards.Contains(cardSource))
@@ -934,7 +951,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region カードをセキュリティに追加する
+    #region Add card to security
     public static IEnumerator AddSecurityCard(CardSource cardSource, bool toTop = true)
     public static IEnumerator AddSecurityCard(CardSource cardSource, bool toTop = true)
     {
     {
         if (!cardSource.Owner.SecurityCards.Contains(cardSource))
         if (!cardSource.Owner.SecurityCards.Contains(cardSource))
@@ -957,7 +974,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region デッキをシャッフル
+    #region Shuffle
     public static IEnumerator Shuffle(Player player)
     public static IEnumerator Shuffle(Player player)
     {
     {
         ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
         ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
@@ -968,7 +985,7 @@ public class CardObjectController : MonoBehaviour
     }
     }
     #endregion
     #endregion
 
 
-    #region パーマネントを移動
+    #region move permanent
     public static IEnumerator MovePermanent(FieldCardFrame movingPermanentFrame)
     public static IEnumerator MovePermanent(FieldCardFrame movingPermanentFrame)
     {
     {
         if (movingPermanentFrame != null)
         if (movingPermanentFrame != null)
@@ -995,7 +1012,7 @@ public class CardObjectController : MonoBehaviour
                         player.FieldPermanents[newFrameID] = movingPermanent;
                         player.FieldPermanents[newFrameID] = movingPermanent;
                         player.fieldCardFrames[newFrameID].SetFramePermanent(movingPermanent);
                         player.fieldCardFrames[newFrameID].SetFramePermanent(movingPermanent);
 
 
-                        #region アニメーション
+                        #region animation
                         bool end = false;
                         bool end = false;
                         var sequence = DOTween.Sequence();
                         var sequence = DOTween.Sequence();
 
 

+ 1 - 0
Assets/Scripts/ICardEffect.cs

@@ -766,6 +766,7 @@ public enum EffectTiming
     OnDigivolutionCardReturnToDeckBottom,
     OnDigivolutionCardReturnToDeckBottom,
     OnReturnCardsToLibraryFromTrash,
     OnReturnCardsToLibraryFromTrash,
     OnPermamemtReturnedToHand,
     OnPermamemtReturnedToHand,
+    OnReturnCardsToHandFromTrash,
 }
 }
 #endregion
 #endregion