Exemple #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()
        {
            // TODO: Add your initialization logic here
            player = new PlayerSprite(this);
            bombFactory = new BombFactory(this);
            laserFactory = new LaserFactory(this);
            squad = new AlienSquad(this, numAlians, bombFactory);
            score = new ScoreSprite(this);

            bombFactory.addPlayer(player);
            laserFactory.addSquad(squad);
            player.addLaserFactory(laserFactory);
            squad.addLaserFactory(laserFactory);
            score.addFactory(laserFactory);
            score.addPlayer(player);
            score.addSquad(squad);
            squad.addScoreSprite(score);
            laserFactory.addScoreScrprite(score);
            bombFactory.addScoreScrprite(score);

            Components.Add(laserFactory);
            Components.Add(bombFactory);
            Components.Add(player);
            Components.Add(squad);
            Components.Add(score);
            base.Initialize();
        }