IEnumerator DealSolitaireCoroutine() { GameObject[,] playGrid = new GameObject[7, 7]; GameObject lastAdded = null; for (int i = 0; i < bottomOrigin.Length; i++) { for (int j = bottomOrigin.Length - 1; j >= i; j--) { yield return(new WaitForSeconds(0.10f)); Vector3 newPosition = new Vector3(bottomOrigin[j].position.x, (bottomOrigin[j].position.y - (YOffset * i)), -(ZOffset * i)); PlayingCard cardData = Deck.DealTopCard(); lastAdded = CreateCardAtPosition(cardData, newPosition); lastAdded.GetComponent <StateController>().ChangeState(DealtFaceDownState); playGrid[i, j] = lastAdded; if (i == 0) { lastAdded.transform.SetParent(bottomOrigin[j]); } else { lastAdded.transform.SetParent(playGrid[i - 1, j].transform); } } CardGameObject lastAddedGameObject = lastAdded.GetComponent <CardGameObject>(); lastAddedGameObject.TurnFaceUp(); lastAddedGameObject.Activate(); } DealFinished(); }
private void CreateCardObjects(List <PlayingCard> tuple) { Transform parentObject = this.transform; CardGameObject newestCardObject = null; for (int i = 0; i < tuple.Count; i++) { //if (newestCardObject != null) // newestCardObject.enabled = false; Vector3 newPosition = this.transform.position + baseOffset + new Vector3(xOffset * i, 0, -(zOffset * i)); GameObject newCard = Solitaire.GameManager.CreateCardAtPosition(tuple[i], newPosition); newCard.transform.SetParent(parentObject); parentObject = newCard.transform; newestCardObject = newCard.GetComponent <CardGameObject>(); newestCardObject.TurnFaceUp(); dealtCards.Add(newCard); } newestCardObject.Activate(); }