Beispiel #1
0
        /// <summary>
        /// Restart gameplay via a parent <see cref="PlayerLoader"/>.
        /// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
        /// </summary>
        public void Restart()
        {
            sampleRestart?.Play();
            RestartRequested?.Invoke();

            if (this.IsCurrentScreen())
            {
                performImmediateExit();
            }
            else
            {
                this.MakeCurrent();
            }
        }
        private void modButtonPressed(Mod selectedMod)
        {
            if (selectedMod != null)
            {
                if (State == Visibility.Visible) sampleOn?.Play();
                DeselectTypes(selectedMod.IncompatibleMods, true);
            }
            else
            {
                if (State == Visibility.Visible) sampleOff?.Play();
            }

            refreshSelectedMods();
        }
Beispiel #3
0
        public void Restart()
        {
            if (!this.IsCurrentScreen())
            {
                return;
            }

            sampleRestart?.Play();

            // if a restart has been requested, cancel any pending completion (user has shown intent to restart).
            onCompletionEvent = null;

            ValidForResume = false;
            RestartRequested?.Invoke();
            this.Exit();
        }
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Current.ValueChanged += newValue =>
            {
                if (newValue)
                {
                    sampleChecked?.Play();
                }
                else
                {
                    sampleUnchecked?.Play();
                }
            };
        }
Beispiel #5
0
        protected override bool OnClick(InputState state)
        {
            if (!interactive)
            {
                return(false);
            }

            if (Action?.Invoke() ?? true)
            {
                sampleClick.Play();
            }

            flashLayer.ClearTransforms();
            flashLayer.Alpha = 0.4f;
            flashLayer.FadeOut(1500, Easing.OutExpo);
            return(true);
        }
Beispiel #6
0
        protected override bool OnClick(Framework.Input.InputState state)
        {
            didClick = true;
            colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, EasingTypes.In);
            flash();
            SampleClick?.Play();
            Action?.Invoke();

            Delay(click_duration);
            Schedule(delegate {
                colourContainer.ResizeTo(new Vector2(0.8f, 1f), 0, EasingTypes.None);
                spriteText.Spacing = Vector2.Zero;
                glowContainer.FadeOut();
            });

            return(true);
        }
Beispiel #7
0
        protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
        {
            base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);

            lastBeatIndex = beatIndex;

            var beatLength = timingPoint.BeatLength;

            float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum);

            if (beatIndex < 0)
            {
                return;
            }

            if (IsHovered)
            {
                using (BeginDelayedSequence(early_activation))
                    Schedule(() => sampleBeat.Play());
            }

            logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, early_activation, EasingTypes.Out);
            using (logoBeatContainer.BeginDelayedSequence(early_activation))
                logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint);

            ripple.ClearTransforms();

            ripple.ScaleTo(logoAmplitudeContainer.Scale);
            ripple.Alpha = 0.15f * amplitudeAdjust;

            ripple.ScaleTo(logoAmplitudeContainer.Scale * (1 + 0.04f * amplitudeAdjust), beatLength, EasingTypes.OutQuint);
            ripple.FadeOut(beatLength, EasingTypes.OutQuint);

            if (effectPoint.KiaiMode && flashLayer.Alpha < 0.4f)
            {
                flashLayer.ClearTransforms();
                visualizer.ClearTransforms();

                flashLayer.FadeTo(0.2f * amplitudeAdjust, early_activation, EasingTypes.Out);
                visualizer.FadeTo(0.9f * amplitudeAdjust, early_activation, EasingTypes.Out);
                using (flashLayer.BeginDelayedSequence(early_activation))
                    flashLayer.FadeOut(beatLength);
                using (visualizer.BeginDelayedSequence(early_activation))
                    visualizer.FadeTo(0.5f, beatLength);
            }
        }
Beispiel #8
0
        private bool goBack()
        {
            switch (State)
            {
            case ButtonSystemState.TopLevel:
                State = ButtonSystemState.Initial;
                sampleBack?.Play();
                return(true);

            case ButtonSystemState.Play:
                backButton.TriggerOnClick();
                return(true);

            default:
                return(false);
            }
        }
Beispiel #9
0
        private void onShoot()
        {
            shootSample.Play();

            var playerPosition = PlayerPosition;

            var newBullet = new DrawableBullet
            {
                Position = playerPosition
            };

            bulletsContainer.Add(newBullet);

            var distance = (rightwards ? BosuPlayfield.BASE_SIZE.X - playerPosition.X : playerPosition.X) - IWannaExtensions.TILE_SIZE;
            var duration = IWannaExtensions.BULLET_SPEED / 20f * distance;

            newBullet.MoveToX(rightwards ? BosuPlayfield.BASE_SIZE.X - IWannaExtensions.TILE_SIZE : IWannaExtensions.TILE_SIZE, duration).Expire(true);
        }
Beispiel #10
0
        /// <summary>
        /// Restart gameplay via a parent <see cref="PlayerLoader"/>.
        /// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
        /// </summary>
        public void Restart()
        {
            // at the point of restarting the track should either already be paused or the volume should be zero.
            // stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
            musicController.Stop();

            sampleRestart?.Play();
            RestartRequested?.Invoke();

            if (this.IsCurrentScreen())
            {
                performImmediateExit();
            }
            else
            {
                this.MakeCurrent();
            }
        }
Beispiel #11
0
        protected override bool OnHover(InputState state)
        {
            if (State != ButtonState.Expanded)
            {
                return(true);
            }

            sampleHover?.Play();

            box.ScaleTo(new Vector2(1.5f, 1), 500, Easing.OutElastic);

            double duration = TimeUntilNextBeat;

            icon.ClearTransforms();
            icon.RotateTo(rightward ? -10 : 10, duration, Easing.InOutSine);
            icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out);
            return(true);
        }
Beispiel #12
0
        protected override void OnResuming(Screen last)
        {
            if (!(last is MainMenu))
            {
                Content.FadeIn(300);
            }

            //we also handle the exit transition.
            seeya.Play();

            double fadeOutTime = 2000;

            Scheduler.AddDelayed(Exit, fadeOutTime);

            //don't want to fade out completely else we will stop running updates and shit will hit the fan.
            Game.FadeTo(0.01f, fadeOutTime);

            base.OnResuming(last);
        }
Beispiel #13
0
        /// <summary>
        /// selection has been changed as the result of interaction with the carousel.
        /// </summary>
        private void selectionChanged(BeatmapGroup group, BeatmapInfo beatmap)
        {
            bool beatmapSetChange = false;

            if (!beatmap.Equals(Beatmap?.BeatmapInfo))
            {
                if (beatmap.BeatmapSetInfoID == Beatmap?.BeatmapInfo.BeatmapSetInfoID)
                {
                    sampleChangeDifficulty.Play();
                }
                else
                {
                    sampleChangeBeatmap.Play();
                    beatmapSetChange = true;
                }
                Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
            }
            ensurePlayingSelected(beatmapSetChange);
        }
Beispiel #14
0
        protected override bool OnHover(HoverEvent e)
        {
            if (sampleHover == null)
            {
                return(false);
            }

            bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime;

            if (enoughTimePassedSinceLastPlayback)
            {
                sampleHover.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
                sampleHover.Play();

                lastPlaybackTime.Value = Time.Current;
            }

            return(false);
        }
Beispiel #15
0
        protected override bool OnClick(InputState state)
        {
            var flash = new Box
            {
                RelativeSizeAxes = Axes.Both,
                Shear            = new Vector2(shear, 0),
                Colour           = Color4.White.Opacity(0.5f),
            };

            Add(flash);

            flash.Alpha = 1;
            flash.FadeOut(500, EasingTypes.OutQuint);
            flash.Expire();

            ActivationSound.Play();

            return(base.OnClick(state));
        }
Beispiel #16
0
        public override bool OnPressed(GlobalAction action)
        {
            switch (action)
            {
            case GlobalAction.Back:
                if (Current.Value == null)
                {
                    Hide();
                }
                else
                {
                    Current.Value = null;
                    sampleBack?.Play();
                }

                return(true);
            }

            return(false);
        }
Beispiel #17
0
            protected override bool OnClick(InputState state)
            {
                if (!Enabled)
                {
                    return(false);
                }

                sampleConfirm.Play();

                box.FlashColour(Color4.White, 500, Easing.OutQuint);
                aspect.ScaleTo(1.2f, 2000, Easing.OutQuint);

                bool result = base.OnClick(state);

                // for now, let's disable the skip button after the first press.
                // this will likely need to be contextual in the future (bound from external components).
                Enabled.Value = false;

                return(result);
            }
Beispiel #18
0
        private void playSample()
        {
            if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
            {
                return;
            }
            lastSampleTime         = Clock.CurrentTime;
            sample.Frequency.Value = 1 + NormalizedValue * 0.2f;

            if (NormalizedValue == 0)
            {
                sample.Frequency.Value -= 0.4f;
            }
            else if (NormalizedValue == 1)
            {
                sample.Frequency.Value += 0.4f;
            }

            sample.Play();
        }
Beispiel #19
0
        private void onStateChanged(Visibility visibility)
        {
            switch (visibility)
            {
            case Visibility.Visible:
                if (OverlayActivationMode != OverlayActivation.Disabled)
                {
                    samplePopIn?.Play();
                }
                else
                {
                    State = Visibility.Hidden;
                }
                break;

            case Visibility.Hidden:
                samplePopOut?.Play();
                break;
            }
        }
        private void onStateChanged(Visibility visibility)
        {
            if (allowOpeningOverlays)
            {
                switch (visibility)
                {
                case Visibility.Visible:
                    samplePopIn?.Play();
                    break;

                case Visibility.Hidden:
                    samplePopOut?.Play();
                    break;
                }
            }
            else
            {
                State = Visibility.Hidden;
            }
        }
        public void TestDoesNotRestart()
        {
            SampleChannel channel = null;

            AddStep("play channel 1 sample", () => channel = sample.Play());
            AddUntilStep("wait for channel 1 to end", () => !channel.Playing);
            AddStep("play channel 1 again", () => channel.Play());

            // Create another channel purely for tracking purposes in order to avoid timing issues.
            // When this channel is playing, the audio thread is guaranteed to have processed the above channel.
            SampleChannel channel2 = null;

            AddStep("play a silent channel 2", () =>
            {
                channel2 = sample.GetChannel();
                channel2.Volume.Value = 0;
                channel2.Play();
            });

            AddUntilStep("channel 2 playing", () => channel2.Playing);
            AddAssert("channel 1 not playing", () => !channel.Playing);
        }
        protected override void LogoArriving(OsuLogo logo, bool resuming)
        {
            base.LogoArriving(logo, resuming);

            if (!resuming)
            {
                welcome?.Play();

                Scheduler.AddDelayed(delegate
                {
                    StartTrack();

                    PrepareMenuLoad();

                    Scheduler.AddDelayed(LoadMenu, delay_step_one);
                }, delay_step_two);

                logo.ScaleTo(1);
                logo.FadeIn();
                logo.PlayIntro();
            }
        }
Beispiel #23
0
        protected override void LogoArriving(OsuLogo logo, bool resuming)
        {
            base.LogoArriving(logo, resuming);

            if (!resuming)
            {
                PrepareMenuLoad();

                LoadComponentAsync(new TrianglesIntroSequence(logo, background)
                {
                    RelativeSizeAxes = Axes.Both,
                    Clock            = new FramedClock(UsingThemedIntro ? Track : null),
                    LoadMenu         = LoadMenu
                }, t =>
                {
                    AddInternal(t);
                    welcome?.Play();

                    StartTrack();
                });
            }
        }
Beispiel #24
0
        public OsuCheckbox()
        {
            AutoSizeAxes     = Axes.Y;
            RelativeSizeAxes = Axes.X;

            Children = new Drawable[]
            {
                labelSpriteText = new OsuSpriteText(),
                Nub             = new Nub
                {
                    Anchor = Anchor.CentreRight,
                    Origin = Anchor.CentreRight,
                    Margin = new MarginPadding {
                        Right = 5
                    },
                },
                new HoverClickSounds()
            };

            Nub.Current.BindTo(Current);

            Current.ValueChanged += newValue =>
            {
                if (newValue)
                {
                    sampleChecked?.Play();
                }
                else
                {
                    sampleUnchecked?.Play();
                }
            };

            Current.DisabledChanged += disabled =>
            {
                Alpha = disabled ? 0.3f : 1;
            };
        }
        /// <summary>
        /// Start the fail animation playing.
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown if started more than once.</exception>
        public void Start()
        {
            if (started)
            {
                throw new InvalidOperationException("Animation cannot be started more than once.");
            }

            started = true;

            failSample.Play();

            this.TransformBindableTo(trackFreq, 0, duration).OnComplete(_ =>
            {
                OnComplete?.Invoke();
                Expire();
            });

            track.AddAdjustment(AdjustableProperty.Frequency, trackFreq);

            applyToPlayfield(drawableRuleset.Playfield);
            drawableRuleset.Playfield.HitObjectContainer.FlashColour(Color4.Red, 500);
            drawableRuleset.Playfield.HitObjectContainer.FadeOut(duration / 2);
        }
Beispiel #26
0
        public override void OnResuming(IScreen last)
        {
            this.FadeIn(300);

            double fadeOutTime = EXIT_DELAY;

            //we also handle the exit transition.
            if (menuVoice.Value)
            {
                seeya.Play();
            }
            else
            {
                fadeOutTime = 500;
            }

            Scheduler.AddDelayed(this.Exit, fadeOutTime);

            //don't want to fade out completely else we will stop running updates.
            Game.FadeTo(0.01f, fadeOutTime);

            base.OnResuming(last);
        }
        public override void OnResuming(IScreen last)
        {
            this.FadeIn(300);

            double fadeOutTime = exit_delay;

            var track = musicController.CurrentTrack;

            // ensure the track doesn't change or loop as we are exiting.
            track.Looping    = false;
            Beatmap.Disabled = true;

            // we also handle the exit transition.
            if (MenuVoice.Value)
            {
                seeya.Play();

                // if playing the outro voice, we have more time to have fun with the background track.
                // initially fade to almost silent then ramp out over the remaining time.
                const double initial_fade = 200;
                track
                .VolumeTo(0.03f, initial_fade).Then()
                .VolumeTo(0, fadeOutTime - initial_fade, Easing.In);
            }
            else
            {
                fadeOutTime = 500;

                // if outro voice is turned off, just do a simple fade out.
                track.VolumeTo(0, fadeOutTime, Easing.Out);
            }

            //don't want to fade out completely else we will stop running updates.
            Game.FadeTo(0.01f, fadeOutTime).OnComplete(_ => this.Exit());

            base.OnResuming(last);
        }
Beispiel #28
0
        protected override void UpdateState(ValueChangedEvent <Visibility> state)
        {
            switch (state.NewValue)
            {
            case Visibility.Visible:
                if (OverlayActivationMode.Value == OverlayActivation.Disabled)
                {
                    // todo: visual/audible feedback that this operation could not complete.
                    State.Value = Visibility.Hidden;
                    return;
                }

                samplePopIn?.Play();
                playedPopInSound = true;

                if (BlockScreenWideMouse && DimMainContent)
                {
                    game?.AddBlockingOverlay(this);
                }
                break;

            case Visibility.Hidden:
                if (playedPopInSound)
                {
                    samplePopOut?.Play();
                    playedPopInSound = false;
                }

                if (BlockScreenWideMouse)
                {
                    game?.RemoveBlockingOverlay(this);
                }
                break;
            }

            base.UpdateState(state);
        }
Beispiel #29
0
        protected override bool OnSelectionFinalised()
        {
            if (player != null)
            {
                return(false);
            }

            // Ctrl+Enter should start map with autoplay enabled.
            if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
            {
                var auto     = Ruleset.Value.CreateInstance().GetAutoplayMod();
                var autoType = auto.GetType();

                var mods = modSelect.SelectedMods.Value;
                if (mods.All(m => m.GetType() != autoType))
                {
                    modSelect.SelectedMods.Value = mods.Concat(new[] { auto });
                    removeAutoModOnResume        = true;
                }
            }

            Beatmap.Value.Track.Looping = false;
            Beatmap.Disabled            = true;

            sampleConfirm?.Play();

            LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
            {
                if (IsCurrentScreen)
                {
                    Push(player);
                }
            });

            return(true);
        }
Beispiel #30
0
        public override void OnResuming(IScreen last)
        {
            this.FadeIn(300);

            double fadeOutTime = exit_delay;

            // we also handle the exit transition.
            if (MenuVoice.Value)
            {
                seeya.Play();
            }
            else
            {
                fadeOutTime = 500;
            }

            audio.AddAdjustment(AdjustableProperty.Volume, exitingVolumeFade);
            this.TransformBindableTo(exitingVolumeFade, 0, fadeOutTime).OnComplete(_ => this.Exit());

            //don't want to fade out completely else we will stop running updates.
            Game.FadeTo(0.01f, fadeOutTime);

            base.OnResuming(last);
        }