Esempio n. 1
0
 public void MoveCardToStack(CardMoveToStackEventArgs e)
 {
     if (cardModels.Contains(e.cardModel) && CardMoveToStackEvent != null)
     {
         CardMoveToStackEvent(this, e);
     }
 }
Esempio n. 2
0
 public void finishedMovingToStack(CardMoveToStackEventArgs e)
 {
     if (cardModels.Contains(e.cardModel))
     {
         e.cardStack.Insert(Pop(e.indexFrom), e.indexTo);
     }
 }
Esempio n. 3
0
    void CardClicker_CardClicked(object sender, CardEventArgs e)
    {
        switch (playerClickState)
        {
        case GameState.None:
            return;

        case GameState.Ready:
            if (deck.HasCard(e.cardModel))
            {
                stagedCard = e.cardModel;
                deck.StageCard(e.cardModel, turnMarker.transform.position, true);
                playerClickState = GameState.Staged;
                // if (!playersCardsHidden) {
                //   playersCardsHidden = true;
                //   player.flipCards(new RangeInt(0, 2), false);
                // }
            }
            return;

        case GameState.Staged:
            if (stagedCard != null && e.cardModel != stagedCard)
            {
                Vector3 discardPosition = discard.GetComponent <CardStackView>().start;

                if (deck.HasCard(e.cardModel)) // discard
                {
                    deck.MoveCardToStack(
                        new CardMoveToStackEventArgs(e.cardModel, discard, discardPosition, false, -1, -1)
                        );
                    stagedCard       = null;
                    playerClickState = GameState.None;
                }
                else if (player.HasCard(e.cardModel)) // card swap
                {
                    int           indexOfCardClicked  = player.IndexOf(e.cardModel);
                    CardStackView stackView           = player.GetComponent <CardStackView>();
                    Vector3       cardClickedPosition = stackView.CardPositionForIndex(indexOfCardClicked);

                    CardMoveToStackEventArgs playerArgs = new CardMoveToStackEventArgs(
                        e.cardModel, discard, discardPosition, false, indexOfCardClicked, -1
                        );

                    CardMoveToStackEventArgs deckArgs = new CardMoveToStackEventArgs(
                        stagedCard, player, cardClickedPosition, false, -1, indexOfCardClicked
                        );

                    //player.MoveCardToStack(playerArgs); // discard clicked card and flip
                    deck.MoveCardToStack(deckArgs); // add staged card to user stack

                    stagedCard       = null;
                    playerClickState = GameState.None;
                }
            }
            return;
        }
    }
Esempio n. 4
0
    void CardMover_MovedCardToStack(object sender, CardMoveToStackEventArgs e)
    {
        cardStack.finishedMovingToStack(e);
        CardMover cardMover = sender as CardMover;

        if (cardMover != null)
        {
            cardMover.CardMoveToStackEvent -= CardMover_MovedCardToStack;
        }
    }
Esempio n. 5
0
    void CardStack_MoveCardToStack(object sender, CardMoveToStackEventArgs e)
    {
        if (cards.ContainsKey(e.cardModel.cardIndex))
        {
            CardMover cardMover = cards[e.cardModel.cardIndex].GetComponent <CardMover>();
            cardMover.CardMoveToStackEvent += CardMover_MovedCardToStack;
            cardMover.MoveCardToStack(e);

            if (e.flip)
            {
                CardFlipper cardFlipper = cards[e.cardModel.cardIndex].GetComponent <CardFlipper>();
                cardFlipper.FlipCard(e.cardModel);
            }
        }
    }
Esempio n. 6
0
    IEnumerator Move(Vector3 moveToPosition)
    {
        float   time          = 0f;
        Vector3 startPosition = transform.position;
        float   journeyLength = Vector3.Distance(startPosition, moveToPosition);

        while (time <= duration)
        {
            time = time + Time.deltaTime / duration;
            float distCovered = journeyLength * time;
            transform.position = Vector3.Lerp(startPosition, moveToPosition, distCovered);
            yield return(new WaitForFixedUpdate());
        }

        if (e != null && CardMoveToStackEvent != null)
        {
            CardMoveToStackEvent(this, e);
            e = null;
        }
    }
Esempio n. 7
0
 public void MoveCardToStack(CardMoveToStackEventArgs e)
 {
     this.e = e;
     StartCoroutine(Move(e.position));
 }