예제 #1
0
 public void Awake()
 {
     if (_clearOnAwake)
     {
         PlayerPrefs.DeleteAll();
     }
     OldScore = BestDistance();
     _label.Render(BestDistance());
 }
예제 #2
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();
        }