Remove shortcomings, remove InputState.Data usage, make everything amazing

No more casting!
This commit is contained in:
Dean Herbert
2017-08-10 19:28:24 +09:00
parent 1fe273cbc0
commit 798fff00b2
8 changed files with 164 additions and 143 deletions

View File

@ -8,8 +8,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Input;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable;
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Catch.UI
catcher.Size = new Vector2(DrawSize.Y);
}
private class Catcher : Container
private class Catcher : Container, IHandleActions<CatchAction>
{
private Texture texture;
@ -104,48 +104,40 @@ namespace osu.Game.Rulesets.Catch.UI
OriginPosition = new Vector2(DrawWidth / 2, 10) //temporary until the sprite is aligned correctly.
};
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
public bool OnPressed(CatchAction action)
{
if (args.Repeat) return true;
if (state.Data is CatchAction)
switch (action)
{
switch ((CatchAction)state.Data)
{
case CatchAction.MoveLeft:
currentDirection--;
return true;
case CatchAction.MoveRight:
currentDirection++;
return true;
case CatchAction.Dash:
Dashing = true;
return true;
}
case CatchAction.MoveLeft:
currentDirection--;
return true;
case CatchAction.MoveRight:
currentDirection++;
return true;
case CatchAction.Dash:
Dashing = true;
return true;
}
return base.OnKeyDown(state, args);
return false;
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
public bool OnReleased(CatchAction action)
{
if (state.Data is CatchAction)
switch (action)
{
switch ((CatchAction)state.Data)
{
case CatchAction.MoveLeft:
currentDirection++;
return true;
case CatchAction.MoveRight:
currentDirection--;
return true;
case CatchAction.Dash:
Dashing = false;
return true;
}
case CatchAction.MoveLeft:
currentDirection++;
return true;
case CatchAction.MoveRight:
currentDirection--;
return true;
case CatchAction.Dash:
Dashing = false;
return true;
}
return base.OnKeyUp(state, args);
return false;
}
protected override void Update()