コード例 #1
0
        /// <summary>
        /// The function called when the button is clicked
        /// </summary>
        private static void OnButtonClick()
        {
            //invoke input comeplet
            InputComplete.Invoke();

            //write the name to the file with the scores
            StreamWriter outFile = File.AppendText(SCORE_FILE_PATH);

            outFile.WriteLine($"{name},{score}");
            outFile.Close();

            //update the live list
            HighScores.SortStatFile();
        }
コード例 #2
0
        /// <summary>
        /// loads all the content of the game
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch        = new SpriteBatch(GraphicsDevice);
            Screen.spriteBatch = spriteBatch;

            //assigne helper variables
            Helper.Content     = Content;
            Helper.graphics    = graphics;
            Helper.SpriteBatch = spriteBatch;
            Helper.InputFont   = Content.Load <SpriteFont>("Fonts/InputFont");

            //load the game
            Game.LoadContent();
            Game.AllLevelsComplete += score =>
            {
                stage = Stage.NameEntry;
                NameEntryMenu.Start(score);
            };

            //load the name entry menu
            NameEntryMenu.LoadContent();
            NameEntryMenu.InputComplete += () => stage = Stage.Menu;

            //load the main menu and sign up to events
            MainMenu.playButtonPressed += () =>
            {
                stage = Stage.Game;
                Game.Reset();
            };
            MainMenu.instructionsButtonPressed += () => stage = Stage.Instructions;
            MainMenu.highScoresButtonPressed   += () => stage = Stage.HighScores;
            MainMenu.exitButtonPressed         += () => Exit();
            MainMenu.LoadContent();

            //load high scores
            HighScores.BackToMenu += () => stage = Stage.Menu;
            HighScores.LoadContent();

            //load high scores
            Instructions.BackToMenu += () => stage = Stage.Menu;
            Instructions.LoadContent();

            //sign up to games back to menu event
            Game.BackToMenu += () => stage = Stage.Menu;
        }
コード例 #3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Helper.UpdateKeyBoard();

            //update the correct stage
            switch (stage)
            {
            case Stage.Instructions:
                Instructions.Update();
                break;

            case Stage.Menu:
                MainMenu.Update();
                break;

            case Stage.Game:
                Game.Update();
                break;

            case Stage.NameEntry:
                NameEntryMenu.Update();
                break;

            case Stage.HighScores:
                HighScores.Update();
                break;
            }


            base.Update(gameTime);
        }