mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add very basic hitsound support.
This commit is contained in:
Submodule osu-resources updated: 73ddad1f01...e24414a277
@ -18,13 +18,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
private List<ISliderProgress> components = new List<ISliderProgress>();
|
private List<ISliderProgress> components = new List<ISliderProgress>();
|
||||||
|
|
||||||
SliderBody body;
|
SliderBody body;
|
||||||
|
SliderBall ball;
|
||||||
|
|
||||||
SliderBouncer bouncer1, bouncer2;
|
SliderBouncer bouncer1, bouncer2;
|
||||||
|
|
||||||
public DrawableSlider(Slider s) : base(s)
|
public DrawableSlider(Slider s) : base(s)
|
||||||
{
|
{
|
||||||
SliderBall ball;
|
|
||||||
|
|
||||||
slider = s;
|
slider = s;
|
||||||
|
|
||||||
Origin = Anchor.TopLeft;
|
Origin = Anchor.TopLeft;
|
||||||
@ -46,6 +45,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
StartTime = s.StartTime,
|
StartTime = s.StartTime,
|
||||||
Position = s.Position,
|
Position = s.Position,
|
||||||
Colour = s.Colour,
|
Colour = s.Colour,
|
||||||
|
Sample = s.Sample,
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
Depth = -1 //override time-based depth.
|
Depth = -1 //override time-based depth.
|
||||||
@ -58,6 +58,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
components.Add(bouncer2);
|
components.Add(bouncer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int currentRepeat;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -67,6 +69,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
int repeat = (int)(progress * slider.RepeatCount);
|
int repeat = (int)(progress * slider.RepeatCount);
|
||||||
progress = (progress * slider.RepeatCount) % 1;
|
progress = (progress * slider.RepeatCount) % 1;
|
||||||
|
|
||||||
|
if (repeat > currentRepeat)
|
||||||
|
{
|
||||||
|
if (ball.Tracking)
|
||||||
|
PlaySample();
|
||||||
|
currentRepeat = repeat;
|
||||||
|
}
|
||||||
|
|
||||||
if (repeat % 2 == 1)
|
if (repeat % 2 == 1)
|
||||||
progress = 1 - progress;
|
progress = 1 - progress;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool tracking;
|
bool tracking;
|
||||||
protected bool Tracking
|
public bool Tracking
|
||||||
{
|
{
|
||||||
get { return tracking; }
|
get { return tracking; }
|
||||||
set
|
set
|
||||||
|
@ -101,7 +101,10 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
}
|
}
|
||||||
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
||||||
result.StartTime = double.Parse(split[2]);
|
result.StartTime = double.Parse(split[2]);
|
||||||
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[4]) };
|
result.Sample = new HitSampleInfo {
|
||||||
|
Type = (SampleType)Math.Max(1, int.Parse(split[4])),
|
||||||
|
Set = SampleSet.Soft,
|
||||||
|
};
|
||||||
result.NewCombo = combo;
|
result.NewCombo = combo;
|
||||||
// TODO: "addition" field
|
// TODO: "addition" field
|
||||||
return result;
|
return result;
|
||||||
|
@ -5,7 +5,11 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps.Samples;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using Container = osu.Framework.Graphics.Containers.Container;
|
using Container = osu.Framework.Graphics.Containers.Container;
|
||||||
|
|
||||||
@ -40,9 +44,25 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
state = value;
|
state = value;
|
||||||
|
|
||||||
UpdateState(state);
|
UpdateState(state);
|
||||||
|
|
||||||
|
if (State == ArmedState.Hit)
|
||||||
|
PlaySample();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioSample sample;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
sample = audio.Sample.Get($@"Gameplay/{(HitObject.Sample.Set).ToString().ToLower()}-hit{HitObject.Sample.Type.ToString().ToLower()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void PlaySample()
|
||||||
|
{
|
||||||
|
sample?.Play();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
Reference in New Issue
Block a user