Example #1
0
    void NewPlayingField(bool logAction = true)
    {
        if (deck.Count == 0)
        {
            Debug.Log("Trying to make a new playing field, but the deck is empty");
            return;
        }

        if (ActivePlayField != null)
        {
            // For now, we're going to just... jettison the PlayedCards to space.
            // Need to figure out something more, ah, elegant than that
            Debug.Log("Moving the existing playing field far out of the way");
            ActivePlayField.transform.position = (Vector3.right * 1000 + Vector3.up * 500);
            CameraManagerInstance.ResetCamera();
        }

        CardData seedCard = DrawCard();

        if (logAction && ActivePlayField != null)
        {
            GameActions.Push(GameAction.FromNewPlayingField(seedCard, ActivePlayField));
            previousPlayfieldIncompleteCards    += ActivePlayField.GetIncompleteCards().Count;
            previousPlayfieldTotalFaceValue     += ActivePlayField.GetIncompleteCards().Sum(card => card.RepresentingCard.FaceValue);
            previousPlayfieldSatisfiedCount     += ActivePlayField.GetHappyCards().Count;
            previousPlayfieldSatisfiedFaceValue += ActivePlayField.GetHappyCards().Sum(card => card.RepresentingCard.FaceValue);
        }

        ActivePlayField = ObjectPooler.GetObject <PlayFieldRuntime>(PlayFieldRuntimePF, transform);
        ActivePlayField.SeedInitialCard(seedCard);

        ActivePlayField.UpdateCardVisuals();
        ActivePlayField.SetPlayableSpaces();
        UpdateScoreLabels();
    }