Exemplo n.º 1
0
    private void TurnCleanup()
    {
        ScoreTurn();

        colorOffset += 0.07f + Random.value / 6f;

        selectedPositions.Clear();
        possiblePositions.Clear();

        for (int i = 0; i < cardSelector.VisibleCards(); i++)
        {
            targetCard  = cardSelector.SelectCard(i);
            targetShape = targetCard.shape;

            possibleToPlace.Value = true;
            hasSelection.Value    = true;
            UpdatePossibleTiles();
            if (possiblePositions.Count > 0)
            {
                break;
            }
            else
            {
                selectedPositions.Clear();
                possiblePositions.Clear();
            }
        }
        if (possiblePositions.Count == 0)
        {
            gameOverEvent.Raise();
        }
    }
Exemplo n.º 2
0
 public void SelectCard(ShapeCard card)
 {
     foreach (ShapeCard c in cards)
     {
         c.ShowSelected(false);
     }
     if (card != cards[0])
     {
         cards[0].ShowDestroy();
     }
     card.ShowSelected(true);
 }
Exemplo n.º 3
0
    public IEnumerator PlaceCard(ShapeCard targetCard, Vector3 worldPos, float rotation)
    {
        RectTransform rect = targetCard.GetComponent <RectTransform>();
        PathCurve     path = PathCurve.CreateWithRandomMiddle(rect.position, worldToUISpace(worldPos, rect));

        yield return(targetCard.Animate(path, curve, rotation, animationLength));

        Vector3 outsidePos = new Vector3(1500, path.startPos.y, 0);

        rect.position = outsidePos;
        targetCard.ShowSelected(false);

        bool drawCard = true;

        if (deckOffset < shapes.Count)
        {
            ReplaceCard(targetCard, shapes[deckOffset]);
            deckOffset++;
        }
        else
        {
            targetCard.gameObject.SetActive(false);
            visibleCards--;
            drawCard = false;
        }


        int index = cards.IndexOf(targetCard);

        if (index > 0)
        {
            ShapeCard first = cards[0];
            first.GetComponent <RectTransform>().position = outsidePos;
            cards.RemoveAt(index);
            cards.RemoveAt(0);
            cards.Add(targetCard);
            cards.Add(first);
            if (index == 1)
            {
                StartCoroutine(cards[0].Animate(PathCurve.CreateStraight(cardPositions[2], cardPositions[0]), curve, 0, animationLength));
            }
            else
            {
                StartCoroutine(cards[0].Animate(PathCurve.CreateStraight(cardPositions[1], cardPositions[0]), curve, 0, animationLength));
            }
            if (drawCard)
            {
                StartCoroutine(WithDelay(targetCard.Animate(PathCurve.CreateStraight(outsidePos, cardPositions[1]), curve, 0, animationLength), 0.2f));
            }

            if (deckOffset < shapes.Count)
            {
                StartCoroutine(WithDelay(first.Animate(PathCurve.CreateWithRandomMiddle(outsidePos, cardPositions[2]), curve, 0, animationLength), 0.6f));
                ReplaceCard(first, shapes[deckOffset]);
                deckOffset++;
            }
            else
            {
                first.gameObject.SetActive(false);
                visibleCards--;
            }
        }
        else
        {
            cards.RemoveAt(index);
            for (int i = index; i < 2; i++)
            {
                StartCoroutine(cards[i].Animate(PathCurve.CreateStraight(cardPositions[i + 1], cardPositions[i]), curve, 0, animationLength));
            }
            cards.Add(targetCard);
            if (drawCard)
            {
                StartCoroutine(WithDelay(targetCard.Animate(PathCurve.CreateWithRandomMiddle(outsidePos, cardPositions[2]), curve, 0, animationLength), 0.2f));
            }
        }
        if (!drawCard && visibleCards > 0)
        {
            audioSource.PlayOneShot(slideCardSound);
        }
    }
Exemplo n.º 4
0
 private void ReplaceCard(ShapeCard targetCard, Shape shape)
 {
     targetCard.ShowShape(shape);
 }
Exemplo n.º 5
0
 public void SetTargetShape(ShapeCard card)
 {
     targetCard  = card;
     targetShape = card.shape;
     ClearSelection();
 }