Ejemplo n.º 1
0
 /// <summary>
 /// Protected method that fires the collision event.
 /// </summary>
 /// <param name="killedMothership">Mothership that was hit by the laser</param>
 /// <param name="points">Points received when mothership is killed</param>
 protected void onMothershipCollision(MothershipSprite killedMothership, int points)
 {
     if (MothershipCollision != null)
     {
         MothershipCollision(killedMothership, points);
     }
 }
Ejemplo 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();
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the Mothership instance variable to the object sent in as a parameter.
 /// </summary>
 /// <param name="mothership">An instance of a Mothership</param>
 public void SetMothership(MothershipSprite mothership)
 {
     this.mothership = mothership;
 }