Exemple #1
0
        /// <summary>
        /// Updates button
        /// </summary>
        public override void Update()
        {
            base.Update();

            //Check if mouse is pressed
            if (Input.MouseButtonReleased(MouseButton.Left))
            {
                // Check if button is pressed before
                if (!Program.pressed)
                {
                    // Check if cursor position is in button bounds
                    if (Util.InRect(Scene.MouseX, Scene.MouseY, X, Y, 80, 30))
                    {
                        Program.pressed = true;

                        // Get player input and adds it to leaderboard
                        var inputText = Scene.GetEntity <TextBox>().inputString;

                        Leaderboard.AddScore(inputText, Program.curScoreTxt);

                        ReadXML.WriteScores();

                        Scene scene = new HighScoresScene();

                        Program.game.SwitchScene(scene);
                    }
                }
            }
        }
        // Stuff in the HighScores Scene
        public HighScoresScene() : base()
        {
            OnBegin = delegate
            {
                HighScoresScene _scene = Program.game.GetScene <HighScoresScene>();
                //Highscore walls
                #region HighScoreWalls
                Image otherWall = Image.CreateRectangle(1, 350);
                otherWall.SetPosition(549, 150);
                otherWall.Color = Color.Blue;
                AddGraphic(otherWall);

                Image bottomWall = Image.CreateRectangle(300, 1);
                bottomWall.SetPosition(250, 500);
                bottomWall.Color = Color.Blue;
                AddGraphic(bottomWall);
                #endregion
                //Adds Textbox and button and highscore leaderboard (hslb)
                Program.game.MouseVisible = true;
                _scene.Add(new TextBox(250, 100));
                _scene.Add(new Button(420, 95));

                hslb = new HighScoreLeaderboard(250, 150);
                _scene.Add(hslb);

                ReadXML.WriteScores();
            };
            Program.game.AddScene(this);
        }