Exemplo n.º 1
0
        private ScrollViewer FindScrollViewer()
        {
            if (ScrollTarget != null)
            {
                return(ScrollTarget.GetChild <ScrollViewer>());
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// updates
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here
            PlayButton.Update(gameTime);
            SettingsButton.Update(gameTime);
            StoryButton.Update(gameTime);
            if (SettingsButton.Clicked())
            {
                if (offset.Y >= -0.01)
                {
                    sc = ScrollDirection.Down;
                    st = ScrollTarget.Down;
                }
                else
                {
                    sc = ScrollDirection.Up;
                    st = ScrollTarget.Middle;
                }
            }
            if (StoryButton.Clicked())
            {
                if (offset.Y <= 0.01)
                {
                    sc = ScrollDirection.Up;
                    st = ScrollTarget.Up;
                }
                else
                {
                    sc = ScrollDirection.Down;
                    st = ScrollTarget.Middle;
                }
            }
            if (sc == ScrollDirection.Down)
            {
                offset.Y -= (float)gameTime.ElapsedGameTime.TotalSeconds * 400 * (Screen.SIZE / 800f);
            }
            else if (sc == ScrollDirection.Up)
            {
                offset.Y += (float)gameTime.ElapsedGameTime.TotalSeconds * 400 * (Screen.SIZE / 800f);
            }
            if (offset.Y > 800 * (Screen.SIZE / 800f) || offset.Y < -800 * (Screen.SIZE / 800f) ||
                (st == ScrollTarget.Middle &&
                 offset.Y <= (float)gameTime.ElapsedGameTime.TotalSeconds * 400 * (Screen.SIZE / 800f) &&
                 offset.Y >= -(float)gameTime.ElapsedGameTime.TotalSeconds * 400 * (Screen.SIZE / 800f)))
            {
                sc = ScrollDirection.Still;

                MathHelper.Clamp(offset.Y, -800 * (Screen.SIZE / 800f), 800 * (Screen.SIZE / 800f));
                if (st == ScrollTarget.Middle)
                {
                    offset.Y = 0;
                }
            }
            PlayButton.MoveButtonBoundary(new Vector2(PlayButton.Position.X, PlayButton.Position.Y) + offset);
            for (int i = 0; i < volumeButtons.Length; i++)
            {
                volumeButtons[i].Update(gameTime);
                volumeButtons[i].MoveButtonBoundary(new Vector2(volumeButtons[i].Position.X, volumeButtons[i].Position.Y) + offset);
            }
            if (volumeButtons[2].Clicked() && SoundVolume >= 1)
            {
                SoundVolume--;

                SoundEffect.MasterVolume = SoundVolume / 10.0f;
                coinPickup.Play(volume: 0.25f, pitch: -0.4f, pan: 0.0f);
            }
            else if (volumeButtons[3].Clicked() && SoundVolume <= 9)
            {
                SoundVolume++;
                SoundEffect.MasterVolume = SoundVolume / 10.0f;
                coinPickup.Play(volume: 0.25f, pitch: -0.4f, pan: 0.0f);
            }
            else if (volumeButtons[0].Clicked() && SongVolume >= 1)
            {
                SongVolume--;
                MediaPlayer.Volume = SongVolume / 10f;
            }
            else if (volumeButtons[1].Clicked() && SongVolume <= 9)
            {
                SongVolume++;
                MediaPlayer.Volume = SongVolume / 10f;
            }
        }