// Begins or continues playback of an animation. public void PlayAnimation(Animation animation) { // If this animation is already running, do not restart it. if (Animation == animation) return; // Start the new animation. this.animation = animation; this.frameIndex = 0; this.time = 0.0f; }
// Loads the player sprite sheet and sounds. public void LoadContent() { // Gets whether in space/water etc. UpdateLevelSpecificState(); if (carRaceMode) { idleAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "vehicle"), 0.1f, false); walkAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "vehicle"), 0.1f, true); jumpAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "jump"), 0.15f, false); rollAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "spin"), 0.1f, true); //celebrateAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Celebrate"), 0.1f, false); dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false); } else { // Load animated textures depending on level idleAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Idle"), 0.1f, true); walkAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Walk"), 0.1f, true); jumpAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Jump"), 0.1f, false); duckAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Duck"), 0.1f, false); sprintAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Sprint"), 0.1f, true); rollAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Roll"), 0.1f, true); vehicleAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "vehicle"), 0.1f, true); climbAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Climb"), 0.1f, true); climbIdleAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Climb"), 0.1f, false); if (inSudo3D) { walkUpAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "WalkUp"), 0.1f, true); walkDownAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "WalkDown"), 0.1f, true); } celebrateAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Celebrate"), 0.1f, false); if (level.LevelIndex == 4 || level.LevelIndex == 5 || level.LevelIndex == 10) dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die2"), 0.1f, false); else dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false); // If playing as square player if (level.LevelIndex == 10) { monkeyBarAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "MonkeyBar"), 0.1f, true); monkeyBarIdleAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "MonkeyBar"), 0.1f, false); } else { monkeyBarAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/MonkeyBar"), 0.1f, true); monkeyBarIdleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/MonkeyBar"), 0.1f, false); } swimAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Swim"), 0.1f, true); swimIdleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/SwimIdle"), 0.1f, true); // If playing as square player if (level.LevelIndex == 10) flyAnimation = new Animation(Level.Content.Load<Texture2D>(GetPlayerTheme() + "Fly"), 0.1f, true); else flyAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Fly"), 0.1f, true); swingPoleTex = level.Content.Load<Texture2D>("Sprites/Player/Swing"); swingOrigin.X = swingPoleTex.Width / 2; swingOrigin.Y = swingPoleTex.Height / 10; } // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.4); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); // Load sounds. killedSound = Level.Content.Load<SoundEffect>("Sounds/PlayerKilled"); jumpSound = Level.Content.Load<SoundEffect>("Sounds/PlayerJump"); boingSound = Level.Content.Load<SoundEffect>("Sounds/Boing"); fallSound = Level.Content.Load<SoundEffect>("Sounds/PlayerFall"); gunReloadSound = Level.Content.Load<SoundEffect>("Sounds/GunReload"); checkpointSound = Level.Content.Load<SoundEffect>("Sounds/Checkpoint"); // Fonts infoFont = Level.Content.Load<SpriteFont>("Fonts/Hud"); }
// Loads a particular enemy sprite sheet and sounds. public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; walkAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Walk"), 0.1f, true); idleAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Idle"), 0.15f, true); dieAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Die"), 0.15f, false); sprite.PlayAnimation(idleAnimation); if (monsterType == "MonsterD") deathSound = Level.Content.Load<SoundEffect>("Sounds/Explosion"); else deathSound = Level.Content.Load<SoundEffect>("Sounds/MonsterKilled"); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.35); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameHeight * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
private void LoadContent() { mouse = game.Content.Load<Texture2D>("Sprites/mouse"); titleBanner = game.Content.Load<Texture2D>("Sprites/titleBanner"); changeSelectionSound = game.Content.Load<SoundEffect>("Sounds/menuChangeSelection"); walkAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Player/Walk"), 0.1f, true); // Load scrolling background images String ext = "Backgrounds/MainMenu/Background0"; bg1 = game.Content.Load<Texture2D>(ext + "1"); bg2 = game.Content.Load<Texture2D>(ext + "2"); bg3 = game.Content.Load<Texture2D>(ext + "3"); bg4 = game.Content.Load<Texture2D>(ext + "4"); bg5 = game.Content.Load<Texture2D>(ext + "5"); // Initalize inital image positions p[0] = new Vector2(0, 0); p[1] = new Vector2(p[0].X + bg1.Width, 0); p[2] = new Vector2(p[1].X + bg2.Width, 0); p[3] = new Vector2(p[2].X + bg3.Width, 0); p[4] = new Vector2(p[3].X + bg4.Width, 0); }
public void LoadContent() { string bulletFolder = "Tiles/Bullets/"; // Load different bullet texture depending on gun if (powerBullet) bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "powerBullet"); else if (PlayerBullet) { if (level.Player.inVehicle) bulletTex = Level.Content.Load<Texture2D>(bulletFolder + level.GetTileSet() + "vehicleBullet"); else { switch (level.Player.currGun) { case Gun.Pistol: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "pistolBullet"); break; case Gun.Uzi: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "uziBullet"); break; case Gun.Sniper: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "sniperBullet"); break; case Gun.Harpoon: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "harpoonBullet"); break; case Gun.SpaceBlaster: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "spaceBlasterBullet"); break; case Gun.Multidirectional: bulletTex = Level.Content.Load<Texture2D>(bulletFolder + "multiDirectionalBullet"); break; // default: // bulletTex = Level.Content.Load<Texture2D>("Sprites/pistolBullet"); break; } } } // If fired from turret load turret bullet else { //if ((turret.enemy != null && turret.enemy.fireVertical) || (enemy != null && enemy.fireVertical)) bulletRotation = MathHelper.ToRadians(270); bulletTex = Level.Content.Load<Texture2D>(bulletFolder + level.GetTileSet() + "turretBullet"); } // Load different bullet sound depending on gun if (powerBullet) shootSound = Level.Content.Load<SoundEffect>("Sounds/Explosion"); else if (PlayerBullet) { switch (level.Player.currGun) { case Gun.Pistol: shootSound = Level.Content.Load<SoundEffect>("Sounds/Pistol"); break; case Gun.Uzi: shootSound = Level.Content.Load<SoundEffect>("Sounds/Uzi"); break; case Gun.Sniper: shootSound = Level.Content.Load<SoundEffect>("Sounds/Sniper"); break; case Gun.Harpoon: if (level.Player.inVehicle) shootSound = Level.Content.Load<SoundEffect>("Sounds" + level.GetTileSet() + "/VehicleGun"); else shootSound = Level.Content.Load<SoundEffect>("Sounds/Harpoon"); break; case Gun.SpaceBlaster: shootSound = Level.Content.Load<SoundEffect>("Sounds/SpaceBlaster"); break; case Gun.Multidirectional: if (level.Player.sniperMode) shootSound = Level.Content.Load<SoundEffect>("Sounds/Sniper"); else shootSound = Level.Content.Load<SoundEffect>("Sounds/Uzi"); break; // deafult: // bulletTex = Level.Content.Load<Texture2D>("Sprites/pistolBullet"); break; } } sniperShotAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/sniperShotAnimation"), 0.1f, false); blankAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/blankAnimation"), 0.3f, false); explosionTex = Level.Content.Load<Texture2D>("Tiles/explosion"); reloadSound = Level.Content.Load<SoundEffect>("Sounds/GunReload"); hitTarget = Level.Content.Load<SoundEffect>("Sounds/HitTarget"); }