示例#1
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
示例#2
0
        public HalfCakedGame()
        {
            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);
        }
示例#3
0
        /// <summary>
        /// Activates the loading screen.
        /// </summary>
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params GameScreen[] screensToLoad)
        {
            // Tell all the current screens to transition off.
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            // Create and activate the loading screen.
            LoadingScreen loadingScreen = new LoadingScreen(screenManager,
                                                            loadingIsSlow,
                                                            screensToLoad);

            screenManager.AddScreen(loadingScreen, controllingPlayer);
        }
示例#4
0
        public void Update(GameTime theGameTime, ScreenManager manager, InputState inputState)
        {
            if (MediaPlayer.State == MediaState.Stopped && mCanPlayerMusic)
                try
                {
                    MediaPlayer.Play(mBackgroundMusic);
                }
                catch { mCanPlayerMusic = false;  }

            KeyboardState aCurrentKeyboardState = Keyboard.GetState();
            MouseState aCurrentMouseState = Mouse.GetState();
            LevelStatistics.TimeElapsed += theGameTime.ElapsedGameTime.TotalSeconds;

            Portals.ClearSprites();

            Player.Update(theGameTime, this, inputState);

            foreach (Obstacle spr in Obstacles)
                spr.Update(theGameTime);

            foreach (Actor spr in Actors)
            {
                spr.Update(theGameTime, this);
            }

            mTextEffects = mTextEffects.Where(x => !x.Done).ToList();
            foreach (TextEffect effect in mTextEffects)
            {
                effect.Update(theGameTime);
            }

            Portals.Update(theGameTime);

            if(Player.IsGrounded())
                while (Checkpoints[mCheckpointIndex].InBounds(Player.Position))
                {
                    if (++mCheckpointIndex >= Checkpoints.Count)
                    {
                        GameOver();
                    }
                    else
                    {
                        mTextEffects.Add(new CheckpointNotification(Player.Position+Position));
                        if (Checkpoints[mCheckpointIndex - 1].NarrationText != null && Checkpoints[mCheckpointIndex - 1].NarrationText.Length > 0)
                            mTextEffects.Add(new NarrationEffect(Checkpoints[mCheckpointIndex - 1].NarrationText, manager));

                        PlaySoundEffect(mCheckpointSound);
                    }
                }
        }
示例#5
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;
        }
示例#6
0
        public NarrationEffect(string text, ScreenManager manager)
        {
            mNarrator = manager.GetScreens().OfType<GameplayScreen>().First().Narrator;
            mNarrator.Volume = (manager.Game as HalfCakedGame).CurrentProfile.Audio.NarrationVolume * (manager.Game as HalfCakedGame).CurrentProfile.Audio.MasterVolume / 100;
            mNarrator.Rate = 1;

            mWords = text.Split(' ').Select( x => x + " " ).ToArray();
            mFont = manager.Font;

            mBackground = manager.Game.Content.Load<Texture2D>(@"UI\NarrationBackground");
            mNarrationImage = manager.Game.Content.Load<Texture2D>(@"UI\Narrator");

            var size = manager.GraphicsDevice.Viewport.Bounds;
            mRectOut = new Rectangle(size.Width/8, 10, size.Width * 3 / 4, mNarrationImage.Height + 20);

            mTextXStart = mRectOut.X + mNarrationImage.Width + 30;
        }