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(); } }
public void SelectCard(ShapeCard card) { foreach (ShapeCard c in cards) { c.ShowSelected(false); } if (card != cards[0]) { cards[0].ShowDestroy(); } card.ShowSelected(true); }
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); } }
private void ReplaceCard(ShapeCard targetCard, Shape shape) { targetCard.ShowShape(shape); }
public void SetTargetShape(ShapeCard card) { targetCard = card; targetShape = card.shape; ClearSelection(); }