Example #1
0
        private IEnumerator DoScoring()
        {
            WaitForSeconds betweenScoringDelay = new WaitForSeconds(kBetweenScoringDelay);

            while (PlayerScores.HasPendingScores)
            {
                AudioConstants.Instance.ScoreAdded.PlaySFX();
                PlayerScores.StepConvertPendingScoresToScores();

                if (!PlayerScores.HasPendingScores || PlayerScores.HasWinner)
                {
                    break;
                }

                yield return(betweenScoringDelay);
            }

            if (PlayerScores.HasWinner)
            {
                GameNotifications.OnGameWon.Invoke();
                AudioConstants.Instance.Win.PlaySFX(randomPitchRange: 0.0f);
            }

            yield return(new WaitForSeconds(kEndScoringDelay));

            transition_.AnimateOut(() => {
                Finish();
            });
        }
Example #2
0
        private void RefreshAttributeText(bool animate)
        {
            string attribute   = null;
            int    playerScore = PlayerScores.GetScoreFor(player_);

            if (playerScore > 0)
            {
                if (PlayerScores.Winner == player_)
                {
                    attribute = "WINNER!";
                }
                else if (PlayerScores.GetRankFor(player_) == 1)
                {
                    attribute = "LEADER!";
                }
            }

            attributeTextOutlet_.Text  = attribute;
            attributeTextOutlet_.Color = player_.Skin.UIColor;

            bool  showing      = !string.IsNullOrEmpty(attribute);
            float endScale     = showing ? 1.0f : 0.0f;
            float currentScale = attributeContainer_.transform.localScale.x;

            if (endScale == currentScale)
            {
                return;
            }

            if (animate)
            {
                this.StopAllCoroutines();

                this.DoSpringFor(kDuration, kDampingRatio, (float p) => {
                    float scale = Mathf.LerpUnclamped(currentScale, endScale, p);
                    attributeContainer_.transform.localScale = Vector3.one * scale;
                });
            }
            else
            {
                attributeContainer_.transform.localScale = Vector3.one * endScale;
            }
        }
Example #3
0
        private void RefreshScoreBar(bool animate)
        {
            int playerScore = PlayerScores.GetScoreFor(player_);

            startScoreBar_.SetScoreCount(playerScore, player_.Skin.UIColor, animate);
        }