示例#1
0
        public virtual void LoadContent(ContentManager theContentManager, Profile activeProfile)
        {
            AssetName = "Levels\\" + AssetName;
            base.LoadContent(theContentManager, AssetName);
            mBackground.LoadContent(theContentManager, AssetName + "b");

            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<Song>("Sounds\\ExitReached");
            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");
        }
示例#2
0
        private bool MakeValid()
        {
            bool madeChanges = false;

            int maxLevels = Level.INIT_LID_FOR_WORLD.Last();
            this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, maxLevels);

            if (LevelStatistics == null)
            {
                this.LevelStatistics = new Statistics[maxLevels];
                madeChanges = true;
            }

            if (LevelStatistics.Length < maxLevels)
            {
                var stats = LevelStatistics.ToList();
                stats.AddRange(new Statistics[maxLevels - LevelStatistics.Length]);
                LevelStatistics = stats.ToArray();

                madeChanges = true;
            }
            else if (LevelStatistics.Length > maxLevels)
            {
                this.LevelStatistics = LevelStatistics.Take(maxLevels).ToArray();
                madeChanges = true;
            }

            if (Name == null || this.Name.Length <= 0)
            {
                this.Name = "No Namer";
                madeChanges = true;
            }

            if (this.Audio == null)
            {
                this.Audio = new AudioSettings();
                madeChanges = true;
            }

            if (this.Graphics == null)
            {
                this.Graphics = new GraphicsSettings();
                madeChanges = true;
            }

            if (this.KeyBindings == null)
            {
                this.KeyBindings = new Keybindings();
                madeChanges = true;
            }

            return !madeChanges;
        }
示例#3
0
        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;
        }
示例#4
0
        private bool MakeValid()
        {
            bool madeChanges = false;

            this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, Level.MAX_LEVELS - 1);

            if (LevelStatistics == null)
            {
                this.LevelStatistics = new Statistics[Level.MAX_LEVELS];
                madeChanges = true;
            }

            if (LevelStatistics.Length < Level.MAX_LEVELS)
            {
                this.LevelStatistics = LevelStatistics.Union(new Statistics[Level.MAX_LEVELS - LevelStatistics.Length]).ToArray();
                madeChanges = true;
            }
            else if (LevelStatistics.Length > Level.MAX_LEVELS)
            {
                this.LevelStatistics = LevelStatistics.Take(Level.MAX_LEVELS).ToArray();
                madeChanges = true;
            }

            if (Name == null || this.Name.Length <= 0)
            {
                this.Name = " ";
                madeChanges = true;
            }

            if (this.Audio == null)
            {
                this.Audio = new AudioSettings();
                madeChanges = true;
            }

            if (this.Graphics == null)
            {
                this.Graphics = new GraphicsSettings();
                madeChanges = true;
            }

            if (this.KeyBindings == null)
            {
                this.KeyBindings = new Keybindings();
                madeChanges = true;
            }

            return !madeChanges;
        }