mbunch_kascope 2 жил өмнө
parent
commit
d1624bb48e

+ 49 - 52
Assets/CardEffect/LM/Blue/Cthyllamon_LM_006.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using UnityEngine;
 using System.Linq;
 
 namespace DCGO.CardEffects.LM
@@ -72,10 +73,10 @@ namespace DCGO.CardEffects.LM
                             canTargetCondition_ByPreSelecetedList: null,
                             canEndSelectCondition: null,
                             maxCount: maxCount,
-                            canNoSelect: true,
+                            canNoSelect: false,
                             canEndNotMax: false,
                             selectPermanentCoroutine: SelectPermanentCoroutine,
-                            afterSelectPermanentCoroutine: null,
+                            afterSelectPermanentCoroutine: AfterSelectTamer,
                             mode: SelectPermanentEffect.Mode.PutLibraryBottom,
                             cardEffect: activateClass);
 
@@ -86,79 +87,77 @@ namespace DCGO.CardEffects.LM
                         IEnumerator SelectPermanentCoroutine(Permanent permanent)
                         {
                             selectedPermanent = permanent;
-
+                            reduceCost = selectedPermanent.PlayCostJustAfterPlayed;
                             yield return null;
                         }
 
                         #region reduce play cost
-                        ChangeCostClass changeCostClass = new ChangeCostClass();
-                        changeCostClass.SetUpICardEffect($"Play Cost -{selectedPermanent.CostJustBeforeRemoveField}", CanUseCondition1, card);
-                        changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
-                        Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
-                        card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
-
-                        ICardEffect GetCardEffect(EffectTiming _timing)
+                        IEnumerator AfterSelectTamer(List<Permanent> permanent)
                         {
-                            if (_timing == EffectTiming.None)
-                            {
-                                return changeCostClass;
-                            }
+                            if (card.Owner.CanReduceCost(null, card))
+                                ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE); 
 
-                            return null;
-                        }
+                            ChangeCostClass changeCostClass = new ChangeCostClass();
+                            changeCostClass.SetUpICardEffect($"Play Cost -{reduceCost}", CanUseCondition1, card);
+                            changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
+                            card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
 
-                        bool CanUseCondition1(Hashtable hashtable)
-                        {
-                            return true;
-                        }
+                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
 
-                        int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
-                        {
-                            if (CardSourceCondition(cardSource))
+                            bool CanUseCondition1(Hashtable hashtable)
                             {
-                                if (RootCondition(root))
+                                return true;
+                            }
+
+                            int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
+                            {
+                                if (CardSourceCondition(cardSource))
                                 {
-                                    if (PermanentsCondition(targetPermanents))
+                                    if (RootCondition(root))
                                     {
-                                        Cost -= reduceCost;
+                                        if (PermanentsCondition(targetPermanents))
+                                        {
+                                            Cost -= reduceCost;
+                                        }
                                     }
                                 }
-                            }
-
-                            return Cost;
-                        }
 
-                        bool PermanentsCondition(List<Permanent> targetPermanents)
-                        {
-                            if (targetPermanents == null)
-                            {
-                                return true;
+                                return Cost;
                             }
 
-                            else
+                            bool PermanentsCondition(List<Permanent> targetPermanents)
                             {
-                                if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
+                                if (targetPermanents == null)
                                 {
                                     return true;
                                 }
+
+                                else
+                                {
+                                    if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
+                                    {
+                                        return true;
+                                    }
+                                }
+
+                                return false;
                             }
 
-                            return false;
-                        }
+                            bool CardSourceCondition(CardSource cardSource)
+                            {
+                                return true;
+                            }
 
-                        bool CardSourceCondition(CardSource cardSource)
-                        {
-                            return true;
-                        }
+                            bool RootCondition(SelectCardEffect.Root root)
+                            {
+                                return true;
+                            }
 
-                        bool RootCondition(SelectCardEffect.Root root)
-                        {
-                            return true;
-                        }
+                            bool isUpDown()
+                            {
+                                return true;
+                            }
 
-                        bool isUpDown()
-                        {
-                            return true;
                         }
                         #endregion
 
@@ -172,8 +171,6 @@ namespace DCGO.CardEffects.LM
                                                 root: SelectCardEffect.Root.Trash,
                                                 activateETB: true));
                         }
-
-                        card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
                     }
                 }
             }

+ 95 - 8
Assets/Scripts/CheckCardPanel.cs

@@ -7,6 +7,8 @@ using UnityEngine.EventSystems;
 using UnityEngine.Events;
 using DG.Tweening;
 using TMPro;
+using Photon.Pun;
+
 public class CheckCardPanel : MonoBehaviour
 {
     [Header("Message Text")]
@@ -194,7 +196,6 @@ public class CheckCardPanel : MonoBehaviour
         foreach (CardSource cardSource in root)
         {
             HandCard handCard = Instantiate(GManager.instance.handCardPrefab, scrollRect.content);
-
             handCard.gameObject.name = $"checkCardPanel_{cardSource.Owner.PlayerName}";
 
             handCard.GetComponent<Draggable_HandCard>().startScale = new Vector3(2.7f, 2.7f, 1);
@@ -244,10 +245,7 @@ public class CheckCardPanel : MonoBehaviour
                 #region left click
                 else if (Input.GetMouseButtonUp(0))
                 {
-                    if (OnClickAction != null)
-                    {
-                        OnClickAction()?.Invoke(handCard);
-                    }
+                    handCard.OnClickAction?.Invoke(handCard);
                 }
                 #endregion
             }
@@ -284,16 +282,105 @@ public class CheckCardPanel : MonoBehaviour
 
         yield return new WaitForSeconds(Time.deltaTime * 0.2f);
 
-        //GManager.instance.turnStateMachine.OpenTrashCardPanelAction?.Invoke();
+        foreach(HandCard handCard in handCards)
+        {
+            if (handCard.cardSource.CanDeclareSkill)
+            {
+                handCard.SetOrangeOutline();
+
+                handCard.AddClickTarget(OnClickHandCard);
+            }
+        }
+    }
+
+    public void OnClickHandCard(HandCard handCard)
+    {
+        if (handCard != null)
+        {
+            if (handCard.cardSource != null)
+            {
+                List<CardCommand> FieldUnitCommands = new List<CardCommand>();
+
+                #region Card Effects
+                List<ICardEffect> cardEffects = new List<ICardEffect>();
+                List<ICardEffect> cardEffects1 = new List<ICardEffect>();
+
+                foreach (ICardEffect cardEffect in handCard.cardSource.EffectList(EffectTiming.OnDeclaration))
+                {
+                    cardEffects1.Add(cardEffect);
+                    cardEffects.Add(cardEffect);
+                }
+
+                cardEffects.Reverse();
+
+                foreach (ICardEffect cardEffect in cardEffects)
+                {
+                    if (cardEffect is ActivateICardEffect)
+                    {
+                        CardCommand SkillCommand = new CardCommand(cardEffect.EffectName, OnClick_SetUseSkillUnit_RPC, cardEffect.CanUse(null), DataBase.CommandColor_Skill);
+                        FieldUnitCommands.Add(SkillCommand);
+
+                        void OnClick_SetUseSkillUnit_RPC()
+                        {
+                            #region Reset the card on the field
+                            foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
+                            {
+                                foreach (FieldPermanentCard fieldPermanentCard in player.FieldPermanentObjects)
+                                {
+                                    fieldPermanentCard.RemoveSelectEffect();
+                                    fieldPermanentCard.RemoveClickTarget();
+                                    fieldPermanentCard.RemoveDragTarget();
+                                    fieldPermanentCard.Outline_Select.gameObject.SetActive(false);
+                                    fieldPermanentCard.CloseCommandPanel();
+                                }
+                            }
+                            #endregion
+
+                            #region Reset the card in hand
+                            foreach (HandCard handCard1 in GManager.instance.turnStateMachine.gameContext.TurnPlayer.HandCardObjects)
+                            {
+                                handCard.Outline_Select.gameObject.SetActive(false);
+                                handCard1.RemoveSelectEffect();
+                                handCard1.RemoveClickTarget();
+                                handCard1.RemoveDragTarget();
+                            }
+                            #endregion
+
+                            #region Reset the card in trash
+                            foreach (HandCard trashCard in handCards)
+                            {
+                                trashCard.Outline_Select.gameObject.SetActive(false);
+                                trashCard.RemoveSelectEffect();
+                                trashCard.RemoveClickTarget();
+                                trashCard.RemoveDragTarget();
+                            }
+                            #endregion
+
+                            handCard.GetComponent<Draggable_HandCard>().CanPointerEnterExitAction = true;
+
+                            GManager.instance.turnStateMachine.photonView.RPC("SetActCardSkill", RpcTarget.All, handCard.cardSource.CardIndex, cardEffects1.IndexOf(cardEffect));
+
+                            CloseSelectCardPanel();
+                        }
+                    }
+                }
+                #endregion
+
+                handCard.handCardCommandPanel.SetUpCommandPanel(FieldUnitCommands, null, handCard);
+
+                handCard.AddClickTarget((_fieldUnitCard) => StartCoroutine(GManager.instance.turnStateMachine.SetMainPhase()));
+
+                handCard.Outline_Select.gameObject.SetActive(true);
+                handCard.SetOrangeOutline();
+            }
+        }
     }
 
     bool CanClose = true;
     public void CloseSelectCardPanel()
     {
         if (!CanClose)
-        {
             return;
-        }
 
         CanClose = false;
         ContinuousController.instance.StartCoroutine(CloseSelectCardPanelCoroutine());

+ 7 - 1
Assets/Scripts/CommandPanel.cs

@@ -106,7 +106,13 @@ public class CommandPanel : MonoBehaviour
         {
             if (handCard.cardSource != null)
             {
-                CommandPanelObject.transform.localPosition = new Vector2(0f, 31f);
+                if(!CardEffectCommons.IsExistOnTrash(handCard.cardSource))
+                    CommandPanelObject.transform.localPosition = new Vector2(0f, 31f);
+                else
+                {
+                    CommandPanelObject.transform.localPosition = new Vector2(0f, -125f);
+                    CommandPanelObject.transform.localScale = new Vector3(4f, 4f, 1f);
+                }
             }
         }