update rhythm rally to use PlayerActionEvent
This commit is contained in:
parent
a90abaa7c8
commit
2a872ec671
|
@ -27,38 +27,10 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
|
|||
{
|
||||
if (!game.served || game.missed || !game.started) return;
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
float stateBeat = cond.GetPositionFromMargin(game.targetBeat, 1f);
|
||||
StateCheck(stateBeat);
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
else if (state.notPerfect())
|
||||
{
|
||||
Miss();
|
||||
Jukebox.PlayOneShot("miss");
|
||||
playerAnim.Play("Swing", 0, 0);
|
||||
|
||||
game.missCurve.KeyPoints[0].Position = game.ball.transform.position;
|
||||
game.missCurve.transform.localScale = new Vector3(state.early ? 1f : -1f, 1f, 1f);
|
||||
game.missBeat = cond.songPositionInBeats;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Play "whoosh" sound here
|
||||
playerAnim.Play("Swing", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (stateBeat > Minigame.EndTime())
|
||||
{
|
||||
Miss();
|
||||
game.ball.SetActive(false);
|
||||
// Play "whoosh" sound here
|
||||
playerAnim.Play("Swing", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,36 +40,49 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
|
|||
|
||||
var hitBeat = cond.songPositionInBeats;
|
||||
|
||||
var bounceBeat = game.targetBeat + 1f;
|
||||
var bounceBeat = game.serveBeat + game.targetBeat + 1f;
|
||||
|
||||
if (game.rallySpeed == RhythmRally.RallySpeed.Slow)
|
||||
{
|
||||
bounceBeat = game.targetBeat + 2f;
|
||||
bounceBeat = game.serveBeat + game.targetBeat + 2f;
|
||||
}
|
||||
else if (game.rallySpeed == RhythmRally.RallySpeed.SuperFast)
|
||||
{
|
||||
bounceBeat = game.targetBeat + 0.5f;
|
||||
bounceBeat = game.serveBeat + game.targetBeat + 0.5f;
|
||||
}
|
||||
|
||||
playerAnim.Play("Swing", 0, 0);
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("rhythmRally/Return", hitBeat), new MultiSound.Sound("rhythmRally/ReturnBounce", bounceBeat) });
|
||||
BounceFX(bounceBeat);
|
||||
game.ball.SetActive(true);
|
||||
}
|
||||
|
||||
void Miss()
|
||||
void NearMiss(float state)
|
||||
{
|
||||
MissBall();
|
||||
Jukebox.PlayOneShot("miss");
|
||||
playerAnim.Play("Swing", 0, 0);
|
||||
|
||||
game.missCurve.KeyPoints[0].Position = game.ball.transform.position;
|
||||
game.missCurve.transform.localScale = new Vector3(-state, 1f, 1f);
|
||||
game.missBeat = cond.songPositionInBeats;
|
||||
game.ball.SetActive(true);
|
||||
}
|
||||
|
||||
void MissBall()
|
||||
{
|
||||
game.served = false;
|
||||
game.missed = true;
|
||||
|
||||
var whistleBeat = game.targetBeat + 1f;
|
||||
var whistleBeat = game.serveBeat + game.targetBeat + 1f;
|
||||
|
||||
if (game.rallySpeed == RhythmRally.RallySpeed.Slow)
|
||||
{
|
||||
whistleBeat = game.targetBeat + 2f;
|
||||
whistleBeat = game.serveBeat + game.targetBeat + 2f;
|
||||
}
|
||||
else if (game.rallySpeed == RhythmRally.RallySpeed.SuperFast)
|
||||
{
|
||||
whistleBeat = game.targetBeat + 0.5f;
|
||||
whistleBeat = game.serveBeat + game.targetBeat + 0.5f;
|
||||
}
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("rhythmRally/Whistle", whistleBeat) });
|
||||
|
@ -117,9 +102,20 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
|
|||
});
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
public void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (state >= 1f || state <= -1f) {
|
||||
NearMiss(state);
|
||||
return;
|
||||
}
|
||||
Ace();
|
||||
}
|
||||
|
||||
public void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
MissBall();
|
||||
}
|
||||
|
||||
public void Out(PlayerActionEvent caller) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace HeavenStudio.Games.Loaders
|
|||
new GameAction("toss ball", "Toss Ball")
|
||||
{
|
||||
function = delegate { RhythmRally.instance.Toss(eventCaller.currentEntity.beat, eventCaller.currentEntity.length, 6f, true); },
|
||||
defaultLength = 2f
|
||||
defaultLength = 2f,
|
||||
resizable = true
|
||||
},
|
||||
new GameAction("rally", "Rally")
|
||||
{
|
||||
|
@ -375,16 +376,16 @@ namespace HeavenStudio.Games
|
|||
switch (rallySpeed)
|
||||
{
|
||||
case RallySpeed.Normal:
|
||||
targetBeat = serveBeat + 2f;
|
||||
targetBeat = 2f;
|
||||
bounceBeat = serveBeat + 1f;
|
||||
break;
|
||||
case RallySpeed.Fast:
|
||||
case RallySpeed.SuperFast:
|
||||
targetBeat = serveBeat + 1f;
|
||||
targetBeat = 1f;
|
||||
bounceBeat = serveBeat + 0.5f;
|
||||
break;
|
||||
case RallySpeed.Slow:
|
||||
targetBeat = serveBeat + 4f;
|
||||
targetBeat = 4f;
|
||||
bounceBeat = serveBeat + 2f;
|
||||
break;
|
||||
}
|
||||
|
@ -393,7 +394,7 @@ namespace HeavenStudio.Games
|
|||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("rhythmRally/Serve", serveBeat), new MultiSound.Sound("rhythmRally/ServeBounce", bounceBeat) });
|
||||
paddlers.BounceFX(bounceBeat);
|
||||
|
||||
paddlers.ResetState();
|
||||
ScheduleInput(serveBeat, targetBeat, InputType.STANDARD_DOWN, paddlers.Just, paddlers.Miss, paddlers.Out);
|
||||
}
|
||||
|
||||
public void Toss(float beat, float length, float height, bool firstToss = false)
|
||||
|
@ -401,6 +402,9 @@ namespace HeavenStudio.Games
|
|||
// Hide trail while tossing to prevent weirdness while teleporting ball.
|
||||
ballTrail.gameObject.SetActive(false);
|
||||
|
||||
if (firstToss)
|
||||
height *= length/2f;
|
||||
|
||||
tossCurve.transform.localScale = new Vector3(1f, height, 1f);
|
||||
tossBeat = beat;
|
||||
tossLength = length;
|
||||
|
|
Loading…
Reference in a new issue