Exemplo n.º 1
0
        //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();
        }
Exemplo n.º 2
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()
        {
            setWindowPosition();

            //Creates the main menu
            mainMenu = new MainMenu(this);

            //Creates the game over menu
            gameOverMenu = new GameOverMenu(this);

            hsDisplay = new HighScoreDisplay(this, screenHeight, screenWidth);

            //Generates the starfield
            starfield = new Starfield(this, screenHeight);

            laser            = new LaserFactory(this, graphics.PreferredBackBufferHeight);
            playerSprite     = new PlayerSprite(this, laser);
            bomb             = new BombFactory(this, graphics.PreferredBackBufferHeight, playerSprite);
            mothershipSprite = new MothershipSprite(this, laser);
            alienSquad       = new AlienSquad(this, screenWidth, screenHeight, bomb, laser, mothershipSprite, playerSprite);
            score            = new ScoreSprite(this, bomb, laser, alienSquad);
            laser.SetAlienSquad(alienSquad);
            laser.SetMothership(mothershipSprite);

            Components.Add(new GamerServicesComponent(this));
            Components.Add(starfield);
            Components.Add(mainMenu);
            Components.Add(gameOverMenu);
            Components.Add(hsDisplay);


            Components.Add(laser);
            Components.Add(bomb);
            Components.Add(playerSprite);
            Components.Add(mothershipSprite);
            Components.Add(alienSquad);
            Components.Add(score);

            base.Initialize();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the AlienSquad instance variable to the object sent in as a parameter.
 /// </summary>
 /// <param name="alienSquad">An instance of an AlienSquad.</param>
 public void SetAlienSquad(AlienSquad alienSquad)
 {
     this.alienSquad = alienSquad;
 }