public void LoadContent(ContentManager theContentManager) { mContentManager = theContentManager; base.LoadContent(theContentManager, ASSETNAME); mGunhand = new Gunarm(); mGunhand.LoadContent(this.mContentManager); mOrbs[0] = new PortalGunBullet(); mOrbs[0].LoadContent(this.mContentManager, 0); mOrbs[1] = new PortalGunBullet(); mOrbs[1].LoadContent(this.mContentManager, 1); //Load animations -- must include frame count for constant frameTime constructor float[] jumpTiming = { 0.1f, 0.1f, 0.1f, 0.2f, 0.1f }; idleAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Player\\Idle"), 0.1f, 1, true); runAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Player\\Run"), 0.05f, 5, true); jumpAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Player\\Jump"), jumpTiming, false); victoryAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Player\\Victory"), 0.15f, 5, false); deathAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Player\\Death"), 0.15f, 5, false); int width = (int)(idleAnimation.FrameWidth);// * 0.9f); int left = 0;// (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameHeight);//* 0.8f); int top = idleAnimation.FrameHeight - height; Source = new Rectangle(left, top, width, height); animator.PlayAnimation(idleAnimation); mJumpEffect = theContentManager.Load<SoundEffect>("Sounds\\PlayerJump"); mDeathEffect = theContentManager.Load<SoundEffect>("Sounds\\PlayerKilled"); mLandingEffect = theContentManager.Load<SoundEffect>("Sounds\\PlayerLanding"); antiportalEffect = theContentManager.Load<SoundEffect>("Sounds\\antiportal"); Center = new Vector2(Size.Width / 2, Size.Height / 2); }
public void LoadContent(ScreenManager screenManager, Profile activeProfile) { if (mLoaded) return; var theContentManager = screenManager.Game.Content; string backgroundMusicName = "Sounds\\" + AssetName; if (LevelIdentifier == -1) { string filepath = "Content\\Levels\\Custom\\" + AssetName; base.LoadContent(screenManager.GraphicsDevice, filepath + ".png"); try { mBackground.LoadContent(screenManager.GraphicsDevice, filepath + "b.png"); mBackground.Position = Position; } catch { mBackground = null; } } else { string filepath = "Levels\\" + AssetName; base.LoadContent(theContentManager, filepath); try { mBackground.LoadContent(theContentManager, filepath + "b"); mBackground.Position = Position; } catch { mBackground = null; } } mCakeSprite.LoadContent(theContentManager, "Sprites\\Cake\\Cake"); mCakeSprite.Scale = 1f; mCakeSprite.Position = Checkpoints[Checkpoints.Count - 1].Location - Vector2.UnitY * mCakeSprite.Size.Height; poofAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Poof"), 0.1f, 7, false); idleCake = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Cake"), 0.1f, 1, true); mCakeAnimator.PlayAnimation(idleCake); mDimensions = activeProfile.Graphics.Resolution; mCenterVector = new Vector2(mDimensions.X / 2 - 100, mDimensions.Y * 3 / 4 - 100); mAudio = activeProfile.Audio; SoundEffect.MasterVolume = mAudio.MasterVolume / 100f; MediaPlayer.Volume = mAudio.MasterVolume * mAudio.MusicVolume / 10000f; mExitReached = theContentManager.Load<SoundEffect>("Sounds\\ExitReached"); try { mBackgroundMusic = theContentManager.Load<Song>(backgroundMusicName); } catch { mBackgroundMusic = theContentManager.Load<Song>("Sounds\\Level"); } mCheckpointSound = theContentManager.Load<SoundEffect>("Sounds\\Checkpoint"); Portals.LoadContent(theContentManager); Player = new Character(); Player.LoadContent(theContentManager); Player.Position = Player.InitialPosition = Checkpoints[0].Location; foreach (Obstacle spr in Obstacles) spr.LoadContent(theContentManager, spr.AssetName); foreach (Actor spr in Actors) spr.LoadContent(theContentManager, spr.AssetName); mGameFont = theContentManager.Load<SpriteFont>("Fonts\\gamefont"); mLoaded = true; }
/// <summary> /// Begins or continues playback of an animation. /// </summary> 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; }