public void Dispose()
 {
     if (CachedMap != null)
     {
         CachedMap.Dispose();
         CachedMap = null;
     }
 }
Exemple #2
0
        private void Load()
        {
            Resources.AddStore(new DllResourceStore("RhythmBox.Window.Resources.dll"));

            Dependencies.Cache(new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))));
            Dependencies.Cache(new Gameini(Host.Storage));

            Dependencies.Cache(cachedMap = new CachedMap(Host.Storage));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Roboto-Medium"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Roboto"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Roboto-Thin"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Roboto-Bold"));

            if (!Directory.Exists("Songs"))
            {
                Directory.CreateDirectory("Songs");
            }

            Add(cachedMap);
        }
Exemple #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);
                }
            };
        }