예제 #1
0
    private IEnumerator FillScore(int score, int highScore)
    {
        _highScoreLabel.Render(highScore);
        _highScoreAnimator.SetBool("Visible", highScore > 0);
        yield return(new WaitForSeconds(2f));

        _scoreAnimator.SetBool("Filling", true);
        float current            = 0;
        float stepSize           = score / 2f;
        bool  triggeredHighScore = false;

        while (current < score)
        {
            current = Mathf.MoveTowards(current, score, stepSize * _fillCurve.Evaluate(current / score) * _fillSpeed * Time.deltaTime);
            _label.Render(Mathf.FloorToInt(current));
            if (current > highScore && !triggeredHighScore)
            {
                triggeredHighScore = true;
                _scoreAnimator.SetTrigger("HighScore");
                _highScoreAnimator.SetBool("Visible", false);
                _highScoreSource.Play();
                SetPostGameText("WONDERFUL");
            }
            yield return(null);
        }
        _scoreAnimator.SetBool("Filling", false);

        if (!triggeredHighScore)
        {
            SetPostGameText("GAME OVER");
        }
    }
예제 #2
0
    public void Awake()
    {
        var bestScore = PlayerPrefs.GetInt(_key, 0);

        if (bestScore <= 0)
        {
            Destroy(gameObject);
        }
        _scoreLabel.Render(bestScore);
    }
예제 #3
0
        protected override void OnRenderFrame(FrameEventArgs E)
        {
            base.OnRenderFrame(E);

            var Modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref Modelview);

            RenderBackground();

            var PipeMarginY = (ProjectionHeight - MapHeight * SolidSize) / 2f;
            var PipeMarginX = (NominalHeight - MapHeight * SolidSize) / 2f;

            var Overwidth = ProjectionWidth - ProjectionHeight * (float)NominalWidth / NominalHeight;

            if (Overwidth > 0)
            {
                GL.Translate(Math.Min(Overwidth, (ProjectionWidth - MapWidth * SolidSize) / 2f), PipeMarginY, 0);
            }
            else
            {
                GL.Translate(PipeMarginX, PipeMarginY, 0);
            }

            RenderPipe();

            for (var X = 0; X < MapWidth; X++)
            {
                for (var Y = 0; Y < MapHeight; Y++)
                {
                    if (Map[X, Y] >= 0)
                    {
                        RenderSolid(X, Y + ImpactFallOffset[X, Y], Map[X, Y]);
                    }
                }
            }

            if (GameStateEnum.Fall == GameState)
            {
                for (var i = 0; i < StickLength; i++)
                {
                    if (StickColors[i] >= 0)
                    {
                        RenderSolid(StickPosition.X + i, StickPosition.Y, StickColors[i]);
                    }
                }
            }

            GL.Translate(MapWidth * SolidSize + PipeMarginX, 0, 0);

            NextStickLabel.Render();
            GL.Translate(0, NextStickLabel.Height, 0);
            RenderNextStick();
            GL.Translate(0, -NextStickLabel.Height, 0);

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            if (GameStateEnum.GameOver == GameState)
            {
                GameOverLabel.Render();
                GL.Translate(0, GameOverLabel.Height, 0);
                GameOverHint.Render();
                GL.Translate(0, -GameOverLabel.Height, 0);
            }
            else if (Paused)
            {
                PauseLabel.Render();
                GL.Translate(0, PauseLabel.Height, 0);
                UnpauseHint.Render();
                GL.Translate(0, -PauseLabel.Height, 0);
            }
            else
            {
                PlayingGameLabel.Render();
                GL.Translate(0, PlayingGameLabel.Height, 0);
                PauseHint.Render();
                GL.Translate(0, -PlayingGameLabel.Height, 0);
            }

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            ScoreLabel.Render();
            GL.Translate(0, ScoreLabel.Height, 0);
            ScoreRenderer.Label = Score.ToString();
            ScoreRenderer.Render();
            GL.Translate(0, -ScoreLabel.Height, 0);

            GL.Translate(0, MapHeight * SolidSize / 4f, 0);
            HighScoreLabel.Render();
            GL.Translate(0, HighScoreLabel.Height, 0);
            HighScoreRenderer.Label = HighScore.ToString();
            HighScoreRenderer.Render();

            SwapBuffers();
        }