예제 #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();
        }
예제 #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();
        }
예제 #3
0
        // Constructor
        public AlienSquad(Game1 game, int screenWidth, int screenHeight, BombFactory bomb, LaserFactory laser, MothershipSprite mothershipSprite, PlayerSprite playerSprite)
            : base(game)
        {
            this.game             = game;
            this.screenWidth      = screenWidth;
            this.screenHeight     = screenHeight;
            this.bomb             = bomb;
            this.mothershipSprite = mothershipSprite;
            this.playerSprite     = playerSprite;
            dir = Direction.RIGHT;

            alienSquad = new AlienSprite[3, 8];

            currentListPos = 0;
            motionCtr      = 0;

            setAlienMotionPictures();

            laser.AlienCollision += killAlien;
            killedCount           = 0;
            level      = 1;
            alienLevel = 1;
            aLaser     = laser;
        }