예제 #1
0
 public override void ApplyModifiersToCard(SC_BaseCard c, bool add)
 {
     if (c.Is(SC_Global.CardType.Strike))
     {
         (c as SC_OffensiveMove).effectModifiers.health += add ? 1 : -1;
     }
 }
예제 #2
0
 public override void ApplyModifiersToCard(SC_BaseCard c, bool add)
 {
     if (c.Is(SC_Global.CardType.Strike))
     {
         c.unblockable = true;
     }
 }
예제 #3
0
        public virtual void BaseFinishedUsing(bool countered = false)
        {
            activeCard = originalCard = null;

            if (Is(CardType.Basic))
            {
                if (!Has(CommonEffectType.Break))
                {
                    NextTurn(true);
                }
                else if (activePlayer.Turn)
                {
                    activePlayer.BecomeActive();
                }
            }
            else if (Caller.IsLocalPlayer || Caller.AI)
            {
                if (!countered && Receiver.Stamina <= 2 && this as SC_OffensiveMove)
                {
                    StartPinfallChoice();
                }
                else if (IsSpecial)
                {
                    Caller.BecomeActive();
                }
                else
                {
                    NextTurn();
                }
            }
        }
예제 #4
0
        public void ResponseFinished()
        {
            if (respondedCards.Count > 0)
            {
                activeCard = respondedCards.Pop();

                activeCard.StartCoroutine(activeCard.Use(true));
            }
        }
예제 #5
0
        void TryInterceptFinish()
        {
            if (interceptNext)
            {
                interceptNext = false;

                interceptFinishCard = activeCard;
            }
        }
예제 #6
0
        protected IEnumerator ClickedEffect()
        {
            while (ApplyingEffects)
            {
                yield return(new WaitForEndOfFrame());
            }

            activeCard = null;

            activePlayer.BecomeActive();
        }
예제 #7
0
        public static SC_UI_Card Create(SC_BaseCard original, Transform parent)
        {
            SC_UI_Card c = Instantiate(Resources.Load <SC_UI_Card> ("Prefabs/Cards/P_UI_Card"), parent);

            c.name = original.Path;

            c.Card = Instantiate(Resources.Load <SC_BaseCard> (c.name), c.transform);

            c.Card.UpdateValuesUI(true);

            return(c);
        }
예제 #8
0
        public void BoostFinished()
        {
            if (respondedCards.Count > 0)
            {
                SC_BaseCard c = respondedCards.Pop();

                if (Caller.IsLocalPlayer || Caller.AI)
                {
                    c.StartCoroutine(c.StartPlaying(true));
                }
            }
            else
            {
                FinishedUsing();
            }
        }
예제 #9
0
        public virtual void Play(SC_Player c)
        {
            if (OnTheRing && RingPlay())
            {
                return;
            }

            UI.messagePanel.SetActive(false);

            TryInterceptFinish();

            activeCard = this;

            if (!originalCard)
            {
                originalCard = this;
            }

            Caller = c;

            Receiver = Caller.IsLocalPlayer ? otherPlayer : localPlayer;

            UICard.RecT.SetParent(UICard.RecT.parent.parent);

            if (!OnTheRing)
            {
                Caller.Hand.Remove(this);

                SC_Deck.OrganizeHand(Caller.IsLocalPlayer ? GM.localHand : GM.otherHand);

                UICard.RecT.pivot = Vector2.one * .5f;

                UICard.RecT.anchoredPosition3D = Vector3.up * (Caller.IsLocalPlayer ? UICard.RecT.sizeDelta.y / 2 : (GM.transform as RectTransform).sizeDelta.y - UICard.RecT.sizeDelta.y / 2);
            }
            else
            {
                (Caller.IsLocalPlayer ? UI.localRingSlots : UI.otherRingSlots)[RingSlot].occupied = false;

                RingSlot = -1;
            }

            UICard.RecT.DOLocalMove(Vector3.zero, 1);

            DOTween.Sequence().Append(UICard.RecT.DOSizeDelta(UICard.RecT.sizeDelta * GM.playedSizeMultiplicator, 1)).OnComplete(() => { StartCoroutine(Use()); });

            UICard.Flip(!UICard.FaceUp, 1);
        }
예제 #10
0
        IEnumerator Grabbing()
        {
            while (effectTarget.GetIntChoice("Grab") == -1)
            {
                yield return(new WaitForEndOfFrame());
            }

            SC_GrabCard.canGrab = null;

            for (int i = 0; i < Mathf.Max(CurrentEffect.effectValue, 1); i++)
            {
                SC_CardZone zone = effectTarget.GetIntChoice("Grab" + i) == 0 ? effectTarget.Deck : ((effectTarget.GetIntChoice("Grab" + i) == 1 ? effectTarget.Graveyard : (effectTarget == Caller ? Receiver : Caller).Graveyard) as SC_CardZone);

                SC_BaseCard grabbed = zone.GetCards().Find((c) => { return(c.Path == effectTarget.GetStringChoice("Grab" + i)); });

                yield return(StartCoroutine(zone.Grab(effectTarget.IsLocalPlayer, grabbed)));
            }

            ApplyingEffects = false;
        }
예제 #11
0
        protected override IEnumerator ApplyEffects()
        {
            int handSize = Caller.Hand.Count;

            yield return(StartCoroutine(base.ApplyEffects()));

            if (Caller.Hand.Count > handSize)
            {
                grabbed = Caller.Hand[Caller.Hand.Count - 1];

                grabbed.commonEffects.Add(new CommonEffect(CommonEffectType.Break));

                savedCost = (grabbed as SC_Submission).costModifiers;

                (grabbed as SC_Submission).costModifiers = (grabbed as SC_Submission).cost * -1;

                grabbed.UpdateValuesUI();

                SC_Player.OnNewTurn += RemoveEffect;
            }
        }
예제 #12
0
        public virtual void CounterFinished()
        {
            if (respondedCards.Count == 1)
            {
                if (respondedCards.Peek())
                {
                    respondedCards.Peek().FinishedUsing(true);
                }
                else if (originalCard)
                {
                    originalCard.FinishedUsing(true);
                }
                else if (Receiver.IsLocalPlayer || Receiver.AI)
                {
                    Receiver.NextTurnServerRpc();
                }

                respondedCards.Pop();
            }
            else if (respondedCards.Count > 1)
            {
                if (!respondedCards.Peek().Has(CommonEffectType.Boost))
                {
                    respondedCards.Pop();

                    activeCard = respondedCards.Pop();

                    activeCard.StartCoroutine(activeCard.Use(true));
                }
                else
                {
                    respondedCards.Pop().BoostFinished();
                }
            }
            else
            {
                FinishedUsing();
            }
        }
예제 #13
0
        IEnumerator Use(bool resumed = false)
        {
            if (!resumed)
            {
                if (originalCard == this || !Ephemeral || interceptFinishCard)
                {
                    UI.AddCardToHistory(UICard.image, Caller.IsLocalPlayer);
                }

                OnPlay?.Invoke();

                while (ApplyingEffects)
                {
                    yield return(new WaitForEndOfFrame());
                }

                (this as SC_AttackCard)?.PayCost();

                yield return(new WaitForSeconds(GM.playedDelay));

                if (!unblockable && Receiver.Unlocked && (!Is(CardType.Basic) || Has(CommonEffectType.Lock)))
                {
                    if (Receiver.IsLocalPlayer)
                    {
                        responding = true;

                        if (Receiver.HasOnePlayableCardInHand(false))
                        {
                            UI.ShowMessage("ResponseCan");

                            UpdateHighlightedCards(true);
                        }
                        else
                        {
                            UI.ShowMessage("ResponseCant");
                        }
                    }
                    else if (Receiver.AI && Receiver.HasOnePlayableCardInHand(false))
                    {
                        Receiver.BecomeActive(false);
                    }

                    yield return(new WaitForSeconds(GM.responseTime));

                    if (Receiver.IsLocalPlayer)
                    {
                        UpdateHighlightedCards(false);
                    }

                    responding = false;

                    UI.messagePanel.SetActive(false);
                }
            }

            yield return(StartCoroutine(ApplyEffects()));

            if (GM.Count == 3)
            {
                UI.ShowEndPanel(!Caller.IsLocalPlayer);
            }
            else if (this != lockingCard)
            {
                UICard.RecT.DOSizeDelta(UICard.RecT.sizeDelta / GM.playedSizeMultiplicator, 1);

                if (stayOnRing)
                {
                    UICard.ToRingSlot();
                }
                else
                {
                    UICard.ToGraveyard(1, () => { FinishedUsing(); }, false);
                }
            }
            else
            {
                activeCard = originalCard = null;

                NextTurn();
            }
        }
예제 #14
0
        public IEnumerator StartPlaying(bool resume = false)
        {
            UpdateHighlightedCards(false);

            if (responding || boosting)
            {
                UI.messagePanel.SetActive(false);

                respondedCards.Push(activeCard);

                if (responding)
                {
                    activePlayer.StartResponseServerRpc();
                }
                else
                {
                    respondedCards.Peek().StopAllCoroutines();

                    localPlayer.StartBoostServerRpc(activeCard.UICard.transform.GetSiblingIndex());
                }

                responding = boosting = false;
            }
            else if (IsSpecial)
            {
                localPlayer.SpecialUsed = true;
            }

            TryInterceptFinish();

            activeCard = this;

            boosting = true;

            if (localPlayer.Turn && !localPlayer.FirstAttackPlayed && !resume && !IsSpecial && !interceptFinishCard && localPlayer.HasOnePlayableCardInHand(false))
            {
                UI.ShowMessage("Boost");

                UpdateHighlightedCards(true);

                yield return(new WaitForSeconds(GM.responseTime));

                UpdateHighlightedCards(false);

                UI.messagePanel.SetActive(false);

                boosting = false;
            }
            else
            {
                boosting = false;
            }

            if (this as SC_AttackCard)
            {
                localPlayer.FirstAttackPlayed = true;
            }

            yield return(StartCoroutine(MakeChoices()));

            activePlayer.PlayCardServerRpc(UICard.transform.GetSiblingIndex(), OnTheRing);
        }
예제 #15
0
 public virtual void ApplyModifiersToCard(SC_BaseCard c, bool add)
 {
 }
예제 #16
0
        public void GrabPerform()
        {
            activeCard = this;

            ApplyingEffects = true;

            SC_CardGrabber grabber = GetComponent <SC_CardGrabber> ();

            bool[] where = new bool[] { grabber.deck, grabber.discard, grabber.otherDiscard };

            List <SC_BaseCard>[] lists = new List <SC_BaseCard>[] { effectTarget.Deck.cards, effectTarget.Graveyard.Cards, (effectTarget == Caller ? Receiver : Caller).Graveyard.Cards };

            Vector2 size = Resources.Load <RectTransform> ("Prefabs/Cards/P_Grab_Card").sizeDelta;

            foreach (Transform t in UI.grabUI.container)
            {
                Destroy(t.gameObject);
            }

            float margin = (UI.grabUI.container.rect.width - (size.x * 5)) / 6f;

            int x = 0;
            int y = 0;

            List <SC_GrabCard> grabbable = new List <SC_GrabCard> ();

            for (int i = 0; i < 3; i++)
            {
                if (where [i])
                {
                    foreach (SC_BaseCard c in lists[i])
                    {
                        if (grabber.Matching(c))
                        {
                            if (effectTarget.IsLocalPlayer)
                            {
                                SC_GrabCard g = Instantiate(Resources.Load <GameObject> ("Prefabs/Cards/P_Grab_Card"), UI.grabUI.container).GetComponentInChildren <SC_GrabCard> ();

                                g.Setup(c, i);

                                (g.transform.parent as RectTransform).anchoredPosition = new Vector2(x * size.x + (x + 1) * margin, -y * size.y - (y + 1) * margin);

                                if (effectTarget.AI)
                                {
                                    grabbable.Add(g);
                                }
                            }

                            x = x == 4 ? 0 : x + 1;

                            y = x == 0 ? y + 1 : y;
                        }
                    }
                }
            }

            effectTarget.IntChoices["Grab"] = -1;

            GrabsRemaining = Mathf.Min(Mathf.Max(CurrentEffect.effectValue, 1), y * 5 + x);

            if (GrabsRemaining == 0)
            {
                StartCoroutine(NoGrabbing());
            }
            else
            {
                May(() => {
                    StartCoroutine(Grabbing());

                    if (effectTarget.IsLocalPlayer)
                    {
                        y += (x == 0 ? -1 : 0) + 1;

                        UI.grabUI.container.sizeDelta = new Vector2(UI.grabUI.container.sizeDelta.x, Mathf.Max(960, size.y * y + margin * (y + 1)));

                        SC_GrabCard.selectedCards = new List <SC_BaseCard> ();

                        UI.ShowGrabPanel();
                    }
                    else if (effectTarget.AI)
                    {
                        List <int> indexes = new List <int> ();

                        while (GrabsRemaining > 0)
                        {
                            int r = UnityEngine.Random.Range(0, grabbable.Count);

                            if (!indexes.Contains(r) && SC_GrabCard.canGrab(grabbable[r].card))
                            {
                                effectTarget.IntChoices["Grab" + GrabsRemaining] = grabbable[r].origin;

                                effectTarget.StringChoices["Grab" + GrabsRemaining] = grabbable[r].name;

                                GrabsRemaining--;
                            }
                        }

                        effectTarget.IntChoices["Grab"] = 0;
                    }
                });
            }
        }