Inheritance: Microsoft.Xna.Framework.GameComponent
Example #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()
        {
            asteroidKillList = new List<Asteroid>();
            asteroid = new List<Asteroid>();
            newAsteroidList = new List<Asteroid>();
            killListWep = new List<Weapon>();
            mainMenu = new MainMenu(Content, graphics.GraphicsDevice, ch);
            gameOverMenu = new GameOverMenu(graphics, Content);
            scores.LoadHighScores();
            scores.SortHighScores();

            for (int i = 0; i < numOfAsteroids; i++)
            {
                rndNum = r.Next(1, 3);

                switch (rndNum)
                {
                    case 1:
                        rnd2 = r.Next(0, screenHeight);
                        rnd1 = r.Next(-100, 0);
                        break;
                    case 2:
                        rnd2 = r.Next(screenHeight, screenHeight + 100);
                        rnd1 = r.Next(0, screenWidth);
                        break;
                    default:
                        System.Windows.Forms.MessageBox.Show("oeps");
                        rnd1 = 0;
                        rnd2 = 0;
                        break;
                }
                double speed = r.NextDouble() * 3 * Math.PI;
                System.Threading.Thread.Sleep(1);
                double angle = r.NextDouble() * 2 * Math.PI;
                asteroid.Add(new Asteroid(new Vector2(rnd1, rnd2), r.Next(1, 4), (float)speed, dir = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)), Content));
            }

            loader = new Loader(this.Content);
            kbm = new KeyBindingsMenu(graphics, Content, this);
            base.Initialize();
        }