mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Restart branch
This commit is contained in:
@ -7,6 +7,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Taiko.UI;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
@ -32,9 +33,16 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
return new LegacyInputDrum();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return source.GetDrawableComponent(component);
|
||||
case TaikoSkinComponents.TaikoDon:
|
||||
if (GetTexture("pippidonclear0") != null)
|
||||
return new DrawableTaikoCharacter();
|
||||
|
||||
return null;
|
||||
|
||||
default:
|
||||
return source.GetDrawableComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
@ -6,5 +6,6 @@ namespace osu.Game.Rulesets.Taiko
|
||||
public enum TaikoSkinComponents
|
||||
{
|
||||
InputDrum,
|
||||
TaikoDon
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Animations;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public sealed class DefaultTaikoDonTextureAnimation : TextureAnimation
|
||||
{
|
||||
private readonly TaikoDonAnimationState _state;
|
||||
private int currentFrame;
|
||||
|
||||
public DefaultTaikoDonTextureAnimation(TaikoDonAnimationState state) : base(false)
|
||||
{
|
||||
_state = state;
|
||||
this.Stop();
|
||||
|
||||
Origin = Anchor.BottomLeft;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin)
|
||||
{
|
||||
for (int i = 0;; i++)
|
||||
{
|
||||
var textureName = $"pippidon{_getStateString(_state)}{i}";
|
||||
Texture texture = skin.GetTexture(textureName);
|
||||
|
||||
if (texture == null)
|
||||
break;
|
||||
|
||||
AddFrame(texture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the current frame by one.
|
||||
/// </summary>
|
||||
public void Move()
|
||||
{
|
||||
if (FrameCount <= currentFrame)
|
||||
currentFrame = 0;
|
||||
|
||||
GotoFrame(currentFrame);
|
||||
|
||||
currentFrame++;
|
||||
}
|
||||
|
||||
private string _getStateString(TaikoDonAnimationState state) => state switch
|
||||
{
|
||||
TaikoDonAnimationState.Clear => "clear",
|
||||
TaikoDonAnimationState.Fail => "fail",
|
||||
TaikoDonAnimationState.Idle => "idle",
|
||||
TaikoDonAnimationState.Kiai => "kiai",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
}
|
80
osu.Game.Rulesets.Taiko/UI/DrawableTaikoCharacter.cs
Normal file
80
osu.Game.Rulesets.Taiko/UI/DrawableTaikoCharacter.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public sealed class DrawableTaikoCharacter : BeatSyncedContainer
|
||||
{
|
||||
private static DefaultTaikoDonTextureAnimation idleDrawable, clearDrawable, kiaiDrawable, failDrawable;
|
||||
|
||||
private TaikoDonAnimationState state;
|
||||
|
||||
public DrawableTaikoCharacter()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
//Size = new Vector2(1f, 2.5f);
|
||||
//Origin = Anchor.BottomLeft;
|
||||
var xd = new Vector2(1);
|
||||
}
|
||||
|
||||
private DefaultTaikoDonTextureAnimation getStateDrawable() => State switch
|
||||
{
|
||||
TaikoDonAnimationState.Idle => idleDrawable,
|
||||
TaikoDonAnimationState.Clear => clearDrawable,
|
||||
TaikoDonAnimationState.Kiai => kiaiDrawable,
|
||||
TaikoDonAnimationState.Fail => failDrawable,
|
||||
_ => null
|
||||
};
|
||||
|
||||
public TaikoDonAnimationState State
|
||||
{
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
|
||||
foreach (var child in InternalChildren)
|
||||
child.Hide();
|
||||
|
||||
getStateDrawable().Show();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
InternalChildren = new[]
|
||||
{
|
||||
idleDrawable = new DefaultTaikoDonTextureAnimation(TaikoDonAnimationState.Idle),
|
||||
clearDrawable = new DefaultTaikoDonTextureAnimation(TaikoDonAnimationState.Clear),
|
||||
kiaiDrawable = new DefaultTaikoDonTextureAnimation(TaikoDonAnimationState.Kiai),
|
||||
failDrawable = new DefaultTaikoDonTextureAnimation(TaikoDonAnimationState.Fail),
|
||||
};
|
||||
|
||||
// sets the state, to make sure we have the correct sprite loaded and set.
|
||||
State = TaikoDonAnimationState.Idle;
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
getStateDrawable().Move();
|
||||
|
||||
//var signature = timingPoint.TimeSignature == TimeSignatures.SimpleQuadruple ? 4 : 3;
|
||||
//var length = timingPoint.BeatLength;
|
||||
//var rate = 1000d / length;
|
||||
//adjustableClock.Rate = rate;
|
||||
//
|
||||
//// Start animating on the first beat.
|
||||
//if (beatIndex < 1)
|
||||
// adjustableClock.Start();
|
||||
// Logger.GetLogger(LoggingTarget.Information).Add($"Length = {length}ms | Rate = {rate}x | BPM = {timingPoint.BPM} / {signature}");
|
||||
}
|
||||
}
|
||||
}
|
13
osu.Game.Rulesets.Taiko/UI/TaikoDonAnimationState.cs
Normal file
13
osu.Game.Rulesets.Taiko/UI/TaikoDonAnimationState.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public enum TaikoDonAnimationState
|
||||
{
|
||||
Idle,
|
||||
Clear,
|
||||
Kiai,
|
||||
Fail
|
||||
}
|
||||
}
|
@ -19,6 +19,9 @@ using osu.Game.Rulesets.Taiko.Judgements;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
@ -53,6 +56,10 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private readonly Box overlayBackground;
|
||||
private readonly Box background;
|
||||
|
||||
private readonly SkinnableDrawable characterDrawable;
|
||||
|
||||
private Bindable<double> frameTime = new Bindable<double>(100);
|
||||
|
||||
public TaikoPlayfield(ControlPointInfo controlPoints)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
@ -186,6 +193,12 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
Name = "Top level hit objects",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
characterDrawable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoDon), _ => new Container(), confineMode: ConfineMode.ScaleToFit)
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
RelativePositionAxes = Axes.None
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -254,16 +267,28 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class ProxyContainer : LifetimeManagementContainer
|
||||
{
|
||||
public new MarginPadding Padding
|
||||
if (characterDrawable.Drawable is DrawableTaikoCharacter character)
|
||||
{
|
||||
set => base.Padding = value;
|
||||
if (result.Type == HitResult.Miss && result.Judgement.AffectsCombo)
|
||||
{
|
||||
character.State = TaikoDonAnimationState.Fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
character.State = judgedObject.HitObject.Kiai ? TaikoDonAnimationState.Kiai : TaikoDonAnimationState.Idle;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Drawable proxy) => AddInternal(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
class ProxyContainer : LifetimeManagementContainer
|
||||
{
|
||||
public new MarginPadding Padding
|
||||
{
|
||||
set => base.Padding = value;
|
||||
}
|
||||
|
||||
public void Add(Drawable proxy) => AddInternal(proxy);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user