Пример #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

            _isPaused = false;

            _screenHeight = GraphicsDevice.Viewport.Height;
            _screenWidth = GraphicsDevice.Viewport.Width;

            input = InputFactory.GetInput();

            player = new Player();

            gameBackground = new GameBackground();

            fogForeground = new ParallaxingBackground();
            
            TouchPanel.EnabledGestures = GestureType.FreeDrag;

            enemyManager = new EnemyManager();
            _projectileManager = new ProjectileManager();
            laserCannon = new LaserCannon();

            base.Initialize();
        }
Пример #2
0
 public void Initialize(Texture2D staticBackground, ParallaxingBackground[] parallaxBackgrounds, 
     int backgroundWidth, int backgroundHeight)
 {
     _staticBackground = staticBackground;
     _parallaxBackgrounds = parallaxBackgrounds;
     _staticRectangle = new Rectangle(0, 0, backgroundWidth, backgroundHeight);
 }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            _hitboxTexture = Content.Load<Texture2D>("Graphics/HitboxDim");

            SoundEffect explosionSound = Content.Load<SoundEffect>("Sounds/explosion");
            Texture2D explosionStrip = Content.Load<Texture2D>("Graphics/explosion");
            ExplosionFactory explosionFactory = new ExplosionFactory(explosionStrip, explosionSound);

            //Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X,
            //    GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            Vector2 playerPosition = new Vector2(0, _screenHeight / 2);

            Animation playerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("Graphics/shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 35, Color.White, .75f, true);

            Death playerDeath = new PlayerDeath();
            playerDeath.Initialize(explosionFactory);

            //player.Initialize(playerAnimation, playerPosition, input, _projectileManager, _screenHeight, _screenWidth, _hitboxTexture);
            player.Initialize(playerAnimation, playerDeath, playerPosition, input, _projectileManager, _screenHeight, _screenWidth);

            Texture2D enemyTexture = Content.Load<Texture2D>("Graphics/mineAnimation");

            _projectileManager.Initialize(_screenWidth, _screenHeight);

            //enemyManager.Initialize(enemyTexture, explosionStrip, explosionSound, _screenWidth, _screenHeight, _hitboxTexture);
            enemyManager.Initialize(enemyTexture, explosionFactory, _screenWidth, _screenHeight);

            ParallaxingBackground bgLayer1 = new ParallaxingBackground(); 
            ParallaxingBackground bgLayer2 = new ParallaxingBackground();

            bgLayer1.Initialize(Content.Load<Texture2D>("Graphics/bgLayer1"), _screenWidth, _screenHeight, -1);
            bgLayer2.Initialize(Content.Load<Texture2D>("Graphics/bgLayer2"), _screenWidth, _screenHeight, -2);

            Texture2D mainBackground;
            mainBackground = Content.Load<Texture2D>("Graphics/mainbackground");

            gameBackground.Initialize(mainBackground, new ParallaxingBackground[] { bgLayer1, bgLayer2 }, _screenWidth, _screenHeight);

            fogForeground.Initialize(Content.Load<Texture2D>("Graphics/WispyClouds2"), _screenWidth, _screenHeight, -2);

            SoundEffect laserSound = Content.Load<SoundEffect>("Sounds/LaserFire");
            Texture2D laserTexture = Content.Load<Texture2D>("Graphics/laser");
            laserCannon.Initialize(laserTexture, laserSound);
            
            player.Weapon = laserCannon;

            gameMusic = Content.Load<Song>("Music/gameMusic");

            _pauseBackground = Content.Load<Texture2D>("Graphics/Pause");

            MediaPlayer.Volume = .75f;
            MediaPlayer.Play(gameMusic);
        }