/// <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); TitleScreen = new SingleScreen(Content.Load<Texture2D>("Title"), graphics.GraphicsDevice); EndScreen = new SingleScreen(Content.Load<Texture2D>("End"), graphics.GraphicsDevice); #region Game Play Load RainSound = Content.Load<Song>("rain"); Ow = Content.Load<SoundEffect>("Ow"); frontRain = new ParticleGeneratorC(Content.Load<Texture2D>("raindrop"), graphics.GraphicsDevice.Viewport.Width, 25); backRain = new ParticleGeneratorC(Content.Load<Texture2D>("raindrop"), graphics.GraphicsDevice.Viewport.Width, 66, .7f, 2f); Health = new HealthBar(Content.Load<Texture2D>("HealthBar"), new Vector2(30)); Vector2 Location = new Vector2(0.0f, 0.0f); ScrollA = new Scrolling (Content.Load<Texture2D>("Background/ScrollTest"), Location); Vector2 Location2 = new Vector2 (ScrollA.texture.Width, 0.0f); ScrollB = new Scrolling(Content.Load<Texture2D>("Background/ScrollTest2"), Location); // TODO: use this.Content to load your game content here Character = new Animation(Content.Load<Texture2D>("Background/Spritesheet"), new Vector2(50, 450), 47, 44); Turret = new Sentry(Content.Load<Texture2D>("Enemys/Sentry"), Content.Load<Texture2D>("Enemys/Bullets"), Character.Position, new Vector2(400, 100), Content.Load<SoundEffect>("shot")); #endregion }
public void GotShot() { foreach (Bullets bullet in Turret.bullets) { bool GS = false; if (!bullet.Hit) { Rectangle BRect = new Rectangle((int)bullet.position.X, (int)bullet.position.Y, Turret.BulletTexture.Width, Turret.BulletTexture.Height); Rectangle PRect = new Rectangle((int)Character.Position.X - Character.frameWidth / 2, (int)Character.Position.Y - Character.frameHeight / 2, Character.frameWidth, Character.frameHeight); GS = PerPixIntersectoion.IntersectPixel(BRect, Bullets.bulletTextureData, PRect, Animation.spriteTextureDataL[Character.CurrentFrame]); if (GS) { bullet.Hit = true; Health -= 10; Ow.Play(); } } } }