Beispiel #1
0
        private async void Load(int time)
        {
            GameplayScreenLoader.StartRotating();
            await Task.Delay(time);

            GameplayScreenLoader.StopRotating();
            Schedule(() => GameplayScreenLoader.FadeOut(time, Easing.In).Delay(time).Finally((action) =>
            {
                GameplayScreenLoader.Expire();
                RemoveInternal(GameplayScreenLoader);

                GameplayScreenLoader = null;
            }));

            await Task.Delay(time);

            GameStarted.Value = true;

            rhythmBoxClockContainer.Start();
            track?.Start();

            rhythmBoxClockContainer.Seek(_map.StartTime);
            track?.Seek(_map.StartTime);

            if (!hpbar.Enabled.Value)
            {
                return;
            }
            hpbar.Drain(false);
        }
        private void Load()
        {
            Child = gameplayScreenLoader = new GameplayScreenLoader
            {
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(1f),
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
            };

            AddStep("Start loading", () => gameplayScreenLoader.StartRotating());
            AddWaitStep("Wait", 20);

            AddStep("Stop loading", () => gameplayScreenLoader.StopRotating());
        }
Beispiel #3
0
        private void Load(GameHost gameHost, CachedMap cachedMap)
        {
            IResourceStore <byte[]> store      = new StorageBackedResourceStore(gameHost.Storage);
            ITrackStore             trackStore = audio.GetTrackStore(store);

            var audioFile = $"{Path.GetDirectoryName(_map.Path)}{Path.DirectorySeparatorChar}{_map.AFileName}";

            track = trackStore.Get(audioFile);

            if (track != null)
            {
                track.Volume.Value = Gameini.Get <double>(SettingsConfig.Volume);
            }

            InternalChildren = new Drawable[]
            {
                GameplayScreenLoader = new GameplayScreenLoader
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                },
                rhythmBoxClockContainer = new RhythmBoxClockContainer(0)
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f)
                },
                BreakOverlay = new BreakOverlay(new Action[] { () => BreakOverlay.State.Value = Visibility.Hidden, () => ReturntoSongSelectionAfterFail.Value = true })
                {
                    RelativePositionAxes = Axes.Both,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(1f),
                    Alpha            = 0f,
                },
                KeyPress[0] = GetSprite("Skin/K1", 0.3f),
                KeyPress[1] = GetSprite("Skin/K2", 0.4f),
                KeyPress[2] = GetSprite("Skin/K3", 0.5f),
                KeyPress[3] = GetSprite("Skin/K4", 0.6f),
                volume      = new Volume(new Bindable <Track>(track))
                {
                    Anchor               = Anchor.Centre,
                    Origin               = Anchor.Centre,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size  = new Vector2(1f, 0.3f),
                    X     = 0.4f,
                    Y     = 0.2f,
                    Alpha = 0f,
                },
            };

            BreakOverlay.State.Value         = Visibility.Hidden;
            BreakOverlay.State.ValueChanged += async(e) =>
            {
                if (e.NewValue == Visibility.Hidden)
                {
                    BreakOverlay.AnimationOut();
                    await Task.Delay(1500);

                    Resuming.Value = true;
                    rhythmBoxClockContainer.Start();
                    track.Start();
                    _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock;
                }
            };

            rhythmBoxClockContainer.Children = new Drawable[]
            {
                _RbPlayfield = new Playfield.Playfield(ToApplyMods)
                {
                    Anchor               = Anchor.Centre,
                    Origin               = Anchor.Centre,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size = new Vector2(0.6f, 0.9f),
                    Map  = _map,
                    Y    = 0.02f
                },
                hpbar = new HPBar(ToApplyMods)
                {
                    Anchor           = Anchor.TopLeft,
                    Origin           = Anchor.TopLeft,
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.8f, 1f),
                    Colour           = Color4.AliceBlue
                },
                DispayCombo = new TextFlowContainer
                {
                    Anchor               = Anchor.BottomLeft,
                    Origin               = Anchor.BottomLeft,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size       = new Vector2(0.1f),
                    TextAnchor = Anchor.BottomLeft,
                },
                DispayScore = new TextFlowContainer
                {
                    Anchor               = Anchor.TopRight,
                    Origin               = Anchor.TopRight,
                    RelativeSizeAxes     = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size       = new Vector2(0.1f),
                    TextAnchor = Anchor.TopRight,
                    X          = -0.01f
                },
            };

            rhythmBoxClockContainer.IsPaused.BindTo(IsPaused);
            rhythmBoxClockContainer.UserPlaybackRate.BindTo(UserPlaybackRate);

            _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock;
            DispayScore.Clock  = rhythmBoxClockContainer.RhythmBoxClock;
            DispayCombo.Clock  = rhythmBoxClockContainer.RhythmBoxClock;
            hpbar.Clock        = rhythmBoxClockContainer.RhythmBoxClock;

            _RbPlayfield.Resuming.BindTo(Resuming);

            DispayCombo.AddText("0x", x => x.Font     = new FontUsage("Roboto", 40));
            DispayScore.AddText("000000", x => x.Font = new FontUsage("Roboto", 40));

            Score.Combo.PrivateComboBindable.ValueChanged += (e) => hpbar.CurrentValue.Value += hpbar.CalcValue(Score.Combo.currentHit);
            _RbPlayfield.HasFinished.ValueChanged         += (e) =>
            {
                if (!e.NewValue)
                {
                    return;
                }

                rhythmBoxClockContainer.Stop();

                var currentTime = track?.CurrentTime;
                track?.Stop();

                _RbPlayfield.HasFinished.UnbindEvents();

                cachedMap.Map = _map;
                cachedMap.LoadTrackFile();
                cachedMap.Seek(currentTime.GetValueOrDefault());

                Scheduler.AddDelayed(() => this.Expire(), 1000);
                LoadComponentAsync(new ResultScreen(), this.Push);
            };

            ReturntoSongSelectionAfterFail.ValueChanged += (e) =>
            {
                cachedMap.Map = _map;
                cachedMap.LoadTrackFile();
                cachedMap.Seek(track.CurrentTime);

                Selection songSelction;
                LoadComponent(songSelction = new Selection());
                Schedule(() => this.Push(songSelction));
            };

            _RbPlayfield.CanStart.ValueChanged += (e) =>
            {
                if (e.NewValue)
                {
                    Load(1000);
                }
            };
        }