public RunningSprite(Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, bool hasGravity, Game game, UserControlledSprite player) : base(textureImage, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, hasGravity, game) { Player = player; originalSpeed = speed; }
public void InitLevel(UserControlledSprite Player, List <Sprite> Platforms, List <Sprite> Ladders, List <Sprite> Enemies, List <Layer> Backgrounds, List <Sprite> Bullets, SoundEffect LevelMusic) { player = Player; platforms = Platforms; ladders = Ladders; enemies = Enemies; bullets = Bullets; backgrounds = Backgrounds; levelMusic = LevelMusic; }
public BossSprite(Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, bool hasGravity, Game game, UserControlledSprite player, List <Sprite> bullets, int blockSize, int startHealth, int bulletsPerRound, List <Sprite> enemies) : base(textureImage, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, hasGravity, game) { Player = player; originalSpeed = speed; Bullets = bullets; BlockSize = blockSize; health = startHealth; bulletsperRound = bulletsPerRound; bulletTexture = game.Content.Load <Texture2D>(@"Sprites/Bullets/BulletWhite"); Enemies = enemies; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(Game.GraphicsDevice); // Create a camera instance and limit its moving range camera = new Camera(GraphicsDevice.Viewport) { Limits = new Rectangle(0, 0, Game1.worldWidth, Game1.worldHeight) }; SetNumberOfLives(); // Initialize the background layers. If you add layers, then each layer can be parallaxed to give the impression of 3D depth to the background. backgrounds = new List <Layer> { //new Layer(_camera) { Parallax = new Vector2(0.0f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.1f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.2f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.3f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.4f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.5f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.6f, 1.0f) }, //new Layer(_camera) { Parallax = new Vector2(0.8f, 1.0f) }, new Layer(camera) { Parallax = new Vector2(1.0f, 1.0f) } }; //load the content for the common sprites font = Game.Content.Load <SpriteFont>(@"Fonts/Hud"); bulletSound = Game.Content.Load <SoundEffect>(@"Sound/Effects/bullet"); bulletSoundIns = bulletSound.CreateInstance(); switch (currentLevel) { case 1: bulletTexture = Game.Content.Load <Texture2D>(@"Sprites/Bullets/WaterBullet"); player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Sprites/Rex/RexBlue"), new Vector2(80, Game1.worldHeight - 200), new Point(140, 140), 50, new Point(0, 1), new Point(4, 1), new Vector2(5, 15), true, Game); Level1 level1 = new Level1(Game); if (!Game.Components.Contains(level1)) { level1.InitLevel(player, platforms, ladders, enemies, backgrounds, bullets, Game.Content.Load <SoundEffect>(@"Sound/Music/WaterMusic")); Game.Components.Add(level1); currentLevelGameComponent = level1; } break; case 2: bulletTexture = Game.Content.Load <Texture2D>(@"Sprites/Bullets/FireBullet"); // Create Rex Commando player player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Sprites/Rex/RexRed"), new Vector2(120, 1196), new Point(140, 140), 50, new Point(0, 1), new Point(4, 1), new Vector2(5, 15), true, Game); Level2 level2 = new Level2(Game); if (!Game.Components.Contains(level2)) { level2.InitLevel(player, platforms, ladders, enemies, backgrounds, bullets, Game.Content.Load <SoundEffect>(@"Sound/Music/LavaMusic")); Game.Components.Add(level2); currentLevelGameComponent = level2; } break; case 3: bulletTexture = Game.Content.Load <Texture2D>(@"Sprites/Bullets/GrassBullet"); // Create Rex Commando player player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Sprites/Rex/RexGreen"), new Vector2(120, 1196), new Point(140, 140), 50, new Point(0, 1), new Point(4, 1), new Vector2(5, 15), true, Game); Level3 level3 = new Level3(Game); if (!Game.Components.Contains(level3)) { level3.InitLevel(player, platforms, ladders, enemies, backgrounds, bullets, Game.Content.Load <SoundEffect>(@"Sound/Music/GrassMusic")); Game.Components.Add(level3); currentLevelGameComponent = level3; } break; case 4: bulletTexture = Game.Content.Load <Texture2D>(@"Sprites/Bullets/MetalBullet"); // Create Rex Commando player player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Sprites/Rex/RexYellow"), new Vector2(120, 1196), new Point(140, 140), 50, new Point(0, 1), new Point(4, 1), new Vector2(5, 15), true, Game); Level4 level4 = new Level4(Game); if (!Game.Components.Contains(level4)) { level4.InitLevel(player, platforms, ladders, enemies, backgrounds, bullets, Game.Content.Load <SoundEffect>(@"Sound/Music/MetalMusic")); Game.Components.Add(level4); currentLevelGameComponent = level4; } break; case Game1.BossLevel: bulletTexture = Game.Content.Load <Texture2D>(@"Sprites/Bullets/BulletWhite"); // Create Rex Commando player player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Sprites/Rex/ManWhite"), new Vector2(120, 1196), new Point(140, 140), 50, new Point(0, 1), new Point(4, 1), new Vector2(5, 15), true, Game); BossLevel bosslevel = new BossLevel(Game); if (!Game.Components.Contains(bosslevel)) { // Boss level takes on the theme of the level that has just been played bosslevel.Level = ((Game1)Game).PreviousLevel; bosslevel.InitLevel(player, platforms, ladders, enemies, backgrounds, bullets, Game.Content.Load <SoundEffect>(@"Sound/Music/BossMusic")); Game.Components.Add(bosslevel); currentLevelGameComponent = bosslevel; } //Reset the number of lives set by the level. Since this is the boss level set maximum lives in the Level class constructor //SetNumberOfLives(); break; } SetNumberOfLives(); // Turn on collision rectangle drawing for the player if (((Game1)Game).debugPlayerCollision == true) { player.drawCollisionRect = true; player.drawFrameRect = true; } base.LoadContent(); }