Ejemplo n.º 1
0
 public void StartAutoFit()
 {
     OnEndDrag(null);
     animationQueueController.SetAnimationStatus(AnimationStatus.inProgress);
     animationQueueController.AddMovingCard();
     OnAnimationFinishCB = animationQueueController.FinishCardMoving;
 }
Ejemplo n.º 2
0
    private IEnumerator DealCards()
    {
        LockBoard();
        animationQueueController.SetAnimationStatus(AnimationStatus.inProgress);
        yield return(new WaitForSeconds(0.1f));

        int index = 0;

        for (int i = 0; i < Constants.NUMBER_OF_TABLEAUS; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                SoundManager.instance.PlayPickCardSound();
                Card card = cardsPool[index].GetComponent <Card>();
                if (j == i)                 //If this card is on top card uncover it
                {
                    card.isReversed = false;
                    BoxCollider2D bc = card.gameObject.GetComponent <BoxCollider2D>();
                    Vector2       sz = bc.size;
                    sz.y = 180;
                    Vector2 offset = bc.offset;
                    offset.y  = 0;
                    bc.size   = sz;
                    bc.offset = offset;
                }

                card.transform.SetParent(stock.transform.parent);
                card.SetReturnPoint(tableaus[i].transform, -Vector3.up * j * BehaviourSettings.instance.CalculateCardsOffset(card.size.y) * BehaviourSettings.instance.GetScaleFactor());

                card.MoveCard(Constants.MOVE_ANIM_TIME / 3);
                index++;
                if (index == 28)
                {
                    card.RegisterOnAnimationFinishCB(CardDealt);
                }
                else
                {
                    yield return(new WaitForSeconds(0.05f));
                }
            }
        }
        dealCardsCoroutine = null;
    }
Ejemplo n.º 3
0
    public void GetCard()
    {
        int cards = MatchStatistics.instance.isDraw3 ? 3 : 1;

        waste.RegisterOnRefreshWasteAction(FinishReturnWasteAnimation);
        noOfAnimations = 1;
        SaveManager.instance.Save();
        MatchStatistics.instance.moves++;

        for (int i = 0; i < cards; i++)
        {
            if (transform.childCount > 0)
            {
                if (transform.childCount == 1)
                {
                    RefreshStockState(false);
                }

                animationQueueController.SetAnimationStatus(AnimationStatus.inProgress);
                SoundManager.instance.PlayPickCardSound();
                Card card = transform.GetChild(0).GetComponent <Card>();
                card.transform.SetParent(undoHolder);
                card.SetReturnPoint(waste.transform, Constants.vectorZero);
                card.RegisterOnReverseAnimationFinishCB(FinishReturnWasteAnimation);
                noOfAnimations++;
                card.RotateCard(Constants.STOCK_ANIM_TIME);
                card.RegisterOnAnimationFinishCB(FinishReturnWasteAnimation);
                noOfAnimations++;
                card.MoveCard(Constants.STOCK_ANIM_TIME * 2);
            }
            else
            {
                if (i == 0)                 //If first card return stock
                {
                    ReturnCardsFromWasteToStock();
                }
                break;
            }
        }
    }
Ejemplo n.º 4
0
    private void OnHint()
    {
        BoardManager.instance.LockBoard();
        SearchForPossibilitiesOfMove(false);
        if (hintMoves.Count == 0)
        {
            if (stock.transform.childCount > 0)
            {
                //If there is no hints try to highlight stock if any card available
                hintMoves.Enqueue(new HintMove()
                {
                    card       = stock.transform.GetChild(0).GetComponent <Card>(),
                    destParent = stock.transform,
                    offset     = Constants.vectorZero
                });
            }
            else if (waste.transform.childCount > 0)
            {
                //If there is no cards on stock but cards are on waste highlight stock too
                hintMoves.Enqueue(new HintMove()
                {
                    customHintElement = stock.stockGraphics
                });
            }
        }

        if (hintMoves.Count > 0)
        {
            dimScreen.MakeScreenDark(0.8f);
            animationQueueController.SetAnimationStatus(AnimationStatus.inProgress);
            isInHintMode = true;
            DelayedHint();
        }
        else
        {
            Debug.Log("No hints!");
            NoHints();
        }
    }
Ejemplo n.º 5
0
    private void Undo()
    {
        noOfAnimations = 0;
        waste.RegisterOnRefreshWasteAction(null);
        allMovesSet = false;

        animationQueueController.SetAnimationStatus(AnimationStatus.inProgress);
        if (saveList.Count > 0)
        {
            cardsToAnimate.Clear();
            cardsToRotate.Clear();
            SaveState lastSave = saveList[saveList.Count - 1];
            MatchStatistics.instance.score      = lastSave.score;
            MatchStatistics.instance.moves      = lastSave.moves;
            MatchStatistics.instance.vegasScore = lastSave.vegasScore;
            stock.stockLimit = lastSave.stockLimit;

            for (int i = 0; i < lastSave.cardsInfo.Count; i++)
            {
                Card     myCard     = gameCardsSet[i];
                CardInfo myCardInfo = lastSave.cardsInfo[myCard];
                myCard.gameObject.SetActive(true);

                CheckIfCardNeedRotateAnim(myCard, myCardInfo);

                //trasfrom local position to world pos
                Vector3 prevPos = myCardInfo.GetParent().TransformPoint(myCardInfo.GetPos());
                //if card change position play anim
                if (myCard.transform.parent != myCardInfo.GetParent())
                {
                    if (cardsToAnimate.ContainsKey(myCard))
                    {
                        Debug.LogError("Dictionary has already key " + myCard.name);
                    }
                    else
                    {
                        myCard.lastGoodParametres.lastCardAbove = myCardInfo.GetCardAbove();
                        myCard.SetReturnPoint(myCardInfo.GetParent(), prevPos - myCardInfo.GetParent().position);
                        cardsToAnimate.Add(myCard, myCardInfo);
                    }
                }
                else
                {
                    myCard.transform.SetParent(myCardInfo.GetParent(), true);
                    myCard.transform.position = new Vector3(myCard.transform.position.x, prevPos.y, myCard.transform.position.z);
                }

                myCard.transform.parent.SendMessage("RefreshZone", SendMessageOptions.DontRequireReceiver);
            }

            saveList.Remove(lastSave);
            AnimCards();
            stock.RefreshStockState(lastSave.stockState, false);
        }
        else
        {
            Debug.Log("No moves to undo");
            animationQueueController.CastNextAnimation();
        }
        allMovesSet = true;
    }