Example #1
0
        private System.Timers.Timer timer = new System.Timers.Timer(500); //Create a timer to delay game start


        public MainMenu(Game1 game) : base(game)
        {
            this.game    = game;
            graphics     = game.getGraphicsDeviceManager();
            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth  = graphics.PreferredBackBufferWidth;

            songPlaying = false;

            //Add each menu item to the list
            menuItems.Add("New Game");
            menuItems.Add("High Scores");
            menuItems.Add("Exit");

            //Initialize font color to white and flash timer to 0
            color           = Color.White;
            colorFlashTimer = 0;

            //Padding between menu items
            padding = 3;


            // Hook up event to timer
            timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
        }
        private System.Timers.Timer timer = new System.Timers.Timer(500); //Create a timer to delay game start


        public GameOverMenu(Game1 game)
            : base(game)
        {
            this.game    = game;
            graphics     = game.getGraphicsDeviceManager();
            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth  = graphics.PreferredBackBufferWidth;

            //Add each menu item to the list
            menuItems.Add("Restart");
            menuItems.Add("Main Menu");
            menuItems.Add("Exit");

            //Initialize font color to white and flash timer to 0
            color           = Color.White;
            colorFlashTimer = 0;

            //Padding between menu items
            padding = 3;

            // Hook up event to timer
            timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

            playerInitials = new char[3] {
                '_', '_', '_'
            };
            initialDisplay1 = "_";
            initialDisplay2 = "_";
            initialDisplay3 = "_";
            initialCtr      = 0;
            lockControls    = false;
            releaseControls = false;
        }
        //Constructor
        public ScoreSprite(Game1 game, BombFactory bomb, LaserFactory laser, AlienSquad alienSquad)
            : base(game)
        {
            this.game = game;
            this.bomb = bomb;
            graphics  = game.getGraphicsDeviceManager();

            //Events
            bomb.playerCollision      += removeLives;
            laser.AlienCollision      += setScore;
            laser.MothershipCollision += setScore;
            alienSquad.GameOver       += setGameOver;
            screenHeight = graphics.PreferredBackBufferHeight;
            screenWidth  = graphics.PreferredBackBufferWidth;

            lives = 1; //SET TO 1 FOR TESTING, SET TO 3 NORMALLY
            extraLifeAccumulator = 0;
            this.alienSquad      = alienSquad;
            highScoreObject      = new HighScore();
            highScore            = highScoreObject.ReadHighScore();
        }