Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            //Initialize stage size
            graphics.PreferredBackBufferWidth  = SCREEN_WIDTH;
            graphics.PreferredBackBufferHeight = SCREEN_HEIGHT;
            graphics.ApplyChanges();
            Shared.stage = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            HighScoreComponent.LoadHighScore(out HighScoreComponent.nameItems, out HighScoreComponent.scoreItems);
            isPlayingTitleMusic = false;
            base.Initialize();
        }
Ejemplo n.º 2
0
        public HighScoreScene(Game game) : base(game)
        {
            Game1 g = (Game1)game;

            this.spriteBatch = g.spriteBatch;
            subTitleFont     = g.Content.Load <SpriteFont>("Fonts/SubTitleFont");
            headerFont       = g.Content.Load <SpriteFont>("Fonts/HighlightFont");
            scoreFont        = g.Content.Load <SpriteFont>("Fonts/RegularFont");
            sceneFont        = g.Content.Load <SpriteFont>("Fonts/SceneFont");
            //LoadHighScore(out nameItems, out scoreItems);
            HighScore = new HighScoreComponent(game, spriteBatch, headerFont, scoreFont, nameItems, scoreItems);

            background = g.Content.Load <Texture2D>("Images/Background");

            this.Components.Add(HighScore);
        }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState ks = Keyboard.GetState();

            if (ks.IsKeyDown(Keys.Left) && oldState.IsKeyUp(Keys.Left))
            {
                moveCursorSound.Play();
                cursorPosition--;
                if (cursorPosition == -1)
                {
                    cursorPosition = 2;
                }
            }
            if (ks.IsKeyDown(Keys.Right) && oldState.IsKeyUp(Keys.Right))
            {
                moveCursorSound.Play();
                cursorPosition++;
                if (cursorPosition == 3)
                {
                    cursorPosition = 0;
                }
            }

            if (ks.IsKeyDown(Keys.Up) && oldState.IsKeyUp(Keys.Up))
            {
                selectLetterSound.Play();
                if (cursorPosition == 0)
                {
                    letterIndex1--;
                }
                else if (cursorPosition == 1)
                {
                    letterIndex2--;
                }
                else if (cursorPosition == 2)
                {
                    letterIndex3--;
                }

                if (letterIndex1 == -1)
                {
                    letterIndex1 = letters.Length - 1;
                }
                if (letterIndex2 == -1)
                {
                    letterIndex2 = letters.Length - 1;
                }
                if (letterIndex3 == -1)
                {
                    letterIndex3 = letters.Length - 1;
                }

                userNameArray[0] = letters[letterIndex1];
                userNameArray[1] = letters[letterIndex2];
                userNameArray[2] = letters[letterIndex3];
            }
            if (ks.IsKeyDown(Keys.Down) && oldState.IsKeyUp(Keys.Down))
            {
                selectLetterSound.Play();
                if (cursorPosition == 0)
                {
                    letterIndex1++;
                }
                else if (cursorPosition == 1)
                {
                    letterIndex2++;
                }
                else if (cursorPosition == 2)
                {
                    letterIndex3++;
                }

                if (letterIndex1 == letters.Length)
                {
                    letterIndex1 = 0;
                }
                if (letterIndex2 == letters.Length)
                {
                    letterIndex2 = 0;
                }
                if (letterIndex3 == letters.Length)
                {
                    letterIndex3 = 0;
                }
                userNameArray[0] = letters[letterIndex1];
                userNameArray[1] = letters[letterIndex2];
                userNameArray[2] = letters[letterIndex3];
            }

            userName = userNameArray[0] + userNameArray[1] + userNameArray[2];

            if (this.Enabled == true)
            {
                if (ks.IsKeyDown(Keys.Enter) && oldState.IsKeyUp(Keys.Enter))
                {
                    HighScoreComponent.UpdateHighScore(userName, score.score);
                    //reset score
                    score.score = 0;
                    initializeHighscoreComponent();
                    this.Enabled = false;
                    this.Visible = false;
                }
                oldState = ks;
            }
            base.Update(gameTime);
        }