update crop stomp to use PlayerActionEvent
This commit is contained in:
parent
bea85ff636
commit
a232871c16
|
@ -265,6 +265,23 @@ namespace HeavenStudio
|
|||
return GameManager.instance.Beatmap.tempoChanges;
|
||||
}
|
||||
|
||||
public float GetBpmAtBeat(float beat)
|
||||
{
|
||||
var chart = GameManager.instance.Beatmap;
|
||||
float bpm = chart.bpm;
|
||||
|
||||
foreach (DynamicBeatmap.TempoChange t in GameManager.instance.Beatmap.tempoChanges)
|
||||
{
|
||||
if (t.beat > beat)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bpm = t.tempo;
|
||||
}
|
||||
|
||||
return bpm;
|
||||
}
|
||||
|
||||
public double GetSongPosFromBeat(double beat)
|
||||
{
|
||||
var chart = GameManager.instance.Beatmap;
|
||||
|
@ -292,11 +309,11 @@ namespace HeavenStudio
|
|||
}
|
||||
|
||||
//thank you @wooningcharithri#7419 for the psuedo-code
|
||||
private double BeatsToSecs(double beats, float bpm)
|
||||
public double BeatsToSecs(double beats, float bpm)
|
||||
{
|
||||
return beats / bpm * 60f;
|
||||
}
|
||||
private double SecsToBeats(double s, float bpm)
|
||||
public double SecsToBeats(double s, float bpm)
|
||||
{
|
||||
return s / 60f * bpm;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace HeavenStudio.Games.Scripts_BlueBear
|
|||
private void Start()
|
||||
{
|
||||
flyBeats = isCake ? 3f : 2f;
|
||||
game.ScheduleInput(startBeat, flyBeats, isCake ? InputType.DIRECTION_DOWN : InputType.STANDARD_DOWN, EatJust, EatOut, EatOut);
|
||||
game.ScheduleInput(startBeat, flyBeats, isCake ? InputType.DIRECTION_DOWN : InputType.STANDARD_DOWN, Just, Out, Out);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@ -73,7 +73,7 @@ namespace HeavenStudio.Games.Scripts_BlueBear
|
|||
GameObject.Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void EatJust(PlayerActionEvent caller, float state)
|
||||
private void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (state >= 1f || state <= -1f) { //todo: proper near miss feedback
|
||||
if (isCake)
|
||||
|
@ -89,7 +89,9 @@ namespace HeavenStudio.Games.Scripts_BlueBear
|
|||
EatFood();
|
||||
}
|
||||
|
||||
private void EatOut(PlayerActionEvent caller) {}
|
||||
private void Miss(PlayerActionEvent caller) {}
|
||||
|
||||
private void Out(PlayerActionEvent caller) {}
|
||||
|
||||
void SpawnCrumbs()
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace HeavenStudio.Games
|
|||
// Cue the marching proper to begin when applicable.
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(startBeat, delegate { StartMarching(startBeat); })
|
||||
new BeatAction.Action(startBeat - 0.25f, delegate { StartMarching(startBeat); })
|
||||
});
|
||||
|
||||
inactiveStart = -1f;
|
||||
|
@ -208,7 +208,7 @@ namespace HeavenStudio.Games
|
|||
PlayAnims();
|
||||
if (currentMarchBeat % 2 != 0) //step sound
|
||||
{
|
||||
Jukebox.PlayOneShotGame("cropStomp/hmm");
|
||||
MultiSound.Play(new MultiSound.Sound[] {new MultiSound.Sound("cropStomp/hmm", newBeat + marchOffset)});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
|
||||
private CropStomp game;
|
||||
|
||||
PlayerActionEvent stomp;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
game = CropStomp.instance;
|
||||
|
@ -21,38 +23,56 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
{
|
||||
if (!game.isMarching)
|
||||
return;
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(nextStompBeat, 1f);
|
||||
Conductor cond = Conductor.instance;
|
||||
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (normalizedBeat > Minigame.LateTime())
|
||||
if (stomp == null)
|
||||
{
|
||||
nextStompBeat += 2f;
|
||||
ResetState();
|
||||
if (GameManager.instance.currentGame == "cropStomp")
|
||||
stomp = game.ScheduleUserInput(nextStompBeat - 1f, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
|
||||
{
|
||||
game.bodyAnim.Play("Crouch", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
// REMARK: does not count for performance
|
||||
Stomp(state >= 1f || state <= -1f);
|
||||
}
|
||||
|
||||
private void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
if (GameManager.instance.currentGame != "cropStomp") return;
|
||||
if (!game.isMarching)
|
||||
return;
|
||||
}
|
||||
// REMARK: does not count for performance
|
||||
nextStompBeat += 2f;
|
||||
stomp?.Disable();
|
||||
stomp = game.ScheduleUserInput(nextStompBeat - 1f, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
private void Out(PlayerActionEvent caller) {}
|
||||
|
||||
void Stomp(bool ng)
|
||||
{
|
||||
if (GameManager.instance.currentGame != "cropStomp") return;
|
||||
if (!game.isMarching)
|
||||
return;
|
||||
if (ng)
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
game.Stomp();
|
||||
game.bodyAnim.Play("Stomp", 0, 0);
|
||||
nextStompBeat += 2f;
|
||||
ResetState();
|
||||
}
|
||||
else if (state.notPerfect())
|
||||
{
|
||||
game.bodyAnim.Play("Crouch", 0, 0);
|
||||
nextStompBeat += 2f;
|
||||
ResetState();
|
||||
}
|
||||
else
|
||||
{
|
||||
game.bodyAnim.Play("Crouch", 0, 0);
|
||||
}
|
||||
game.bodyAnim.Play("Crouch", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
game.Stomp();
|
||||
game.bodyAnim.Play("Stomp", 0, 0);
|
||||
}
|
||||
nextStompBeat += 2f;
|
||||
stomp?.Disable();
|
||||
stomp = game.ScheduleUserInput(nextStompBeat - 1f, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
private float pickTime = 1f;
|
||||
private int veggieState = 0;
|
||||
private bool boinked; // Player got barely when trying to pick.
|
||||
private bool pickEligible = true;
|
||||
|
||||
private float landBeat;
|
||||
|
||||
|
@ -36,6 +37,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
public void Init()
|
||||
{
|
||||
game = CropStomp.instance;
|
||||
game.ScheduleInput(targetBeat - 1, 1f, InputType.STANDARD_DOWN, StompJust, StompMiss, Out);
|
||||
|
||||
if (!isMole)
|
||||
{
|
||||
|
@ -68,30 +70,9 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
}
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
float normalizedBeat = cond.GetPositionFromMargin(targetBeat, 1f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
// In ground.
|
||||
if (veggieState == 0)
|
||||
{
|
||||
if (normalizedBeat > Minigame.LateTime())
|
||||
{
|
||||
veggieState = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
StompVeggie(false);
|
||||
}
|
||||
else if (state.notPerfect())
|
||||
{
|
||||
veggieState = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// In air.
|
||||
else if (veggieState == 1)
|
||||
|
@ -99,50 +80,82 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
float airPosition = cond.GetPositionFromBeat(stompedBeat, landBeat - stompedBeat);
|
||||
veggieTrans.position = curve.GetPoint(Mathf.Clamp(airPosition, 0, 1));
|
||||
|
||||
if (normalizedBeat > Minigame.EndTime())
|
||||
if (PlayerInput.PressedUp() && !game.IsExpectingInputNow(InputType.STANDARD_UP))
|
||||
{
|
||||
veggieState = -1;
|
||||
|
||||
if (!isMole)
|
||||
Jukebox.PlayOneShotGame("cropStomp/veggieMiss");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerInput.PressedUp())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
PickVeggie(false);
|
||||
}
|
||||
else if (state.notPerfect())
|
||||
{
|
||||
veggieState = -1;
|
||||
boinked = true;
|
||||
|
||||
curve.transform.localScale = Vector3.one; // Return curve to normal size in the case of mole curves.
|
||||
|
||||
var key1 = curve.KeyPoints[0];
|
||||
var key1Pos = key1.Position;
|
||||
key1.Position = new Vector3(key1Pos.x, veggieTrans.position.y, key1Pos.z);
|
||||
|
||||
var key2 = curve.KeyPoints[1];
|
||||
var key2Pos = key2.Position;
|
||||
key2.Position = new Vector3(key2Pos.x, veggieTrans.position.y + 2f, key2Pos.z);
|
||||
|
||||
pickedBeat = cond.songPositionInBeats;
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
MissedUpdate();
|
||||
}
|
||||
|
||||
game.bodyAnim.Play("Pick", 0, 0);
|
||||
game.isFlicking = true;
|
||||
pickEligible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StompJust(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (GameManager.instance.autoplay)
|
||||
{
|
||||
StompVeggie(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state >= 1f)
|
||||
veggieState = -1;
|
||||
else if (state > -1f)
|
||||
StompVeggie(false);
|
||||
}
|
||||
|
||||
private void StompMiss(PlayerActionEvent caller)
|
||||
{
|
||||
veggieState = -1;
|
||||
caller.Disable();
|
||||
}
|
||||
|
||||
private void Out(PlayerActionEvent caller) {}
|
||||
|
||||
private void PickJust(PlayerActionEvent caller, float state)
|
||||
{
|
||||
game.bodyAnim.Play("Pick", 0, 0);
|
||||
game.isFlicking = true;
|
||||
if (!pickEligible) return;
|
||||
if (GameManager.instance.autoplay)
|
||||
{
|
||||
PickVeggie(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state <= -1f || state >= 1f)
|
||||
{
|
||||
veggieState = -1;
|
||||
boinked = true;
|
||||
|
||||
curve.transform.localScale = Vector3.one; // Return curve to normal size in the case of mole curves.
|
||||
|
||||
var key1 = curve.KeyPoints[0];
|
||||
var key1Pos = key1.Position;
|
||||
key1.Position = new Vector3(key1Pos.x, veggieTrans.position.y, key1Pos.z);
|
||||
|
||||
var key2 = curve.KeyPoints[1];
|
||||
var key2Pos = key2.Position;
|
||||
key2.Position = new Vector3(key2Pos.x, veggieTrans.position.y + 2f, key2Pos.z);
|
||||
|
||||
pickedBeat = Conductor.instance.songPositionInBeats;
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
MissedUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
PickVeggie(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void PickMiss(PlayerActionEvent caller)
|
||||
{
|
||||
veggieState = -1;
|
||||
|
||||
if (!isMole)
|
||||
Jukebox.PlayOneShotGame("cropStomp/veggieMiss");
|
||||
caller.Disable();
|
||||
}
|
||||
|
||||
bool moleLaughing;
|
||||
private void MissedUpdate()
|
||||
{
|
||||
|
@ -205,11 +218,12 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
var cond = Conductor.instance;
|
||||
|
||||
veggieState = 1;
|
||||
game.ScheduleInput(targetBeat, isMole ? 0.5f : 1f, InputType.STANDARD_UP, PickJust, PickMiss, Out);
|
||||
targetBeat = targetBeat + (isMole ? 0.5f : 1f);
|
||||
|
||||
stompedBeat = cond.songPositionInBeats;
|
||||
|
||||
landBeat = cond.GetBeatFromPositionAndMargin(Minigame.EndTime(), targetBeat, 1f);
|
||||
landBeat = targetBeat + (float)cond.BeatsToSecs(Minigame.EndTime()-1, cond.GetBpmAtBeat(targetBeat));
|
||||
|
||||
if (autoTriggered)
|
||||
{
|
||||
|
@ -219,10 +233,9 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
|
||||
if (!isMole)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(targetBeat - 0.5f, delegate { Jukebox.PlayOneShotGame("cropStomp/veggieOh"); })
|
||||
});
|
||||
MultiSound.Play(
|
||||
new MultiSound.Sound[] { new MultiSound.Sound("cropStomp/veggieOh", targetBeat - 0.5f) }
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -233,8 +246,6 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
veggieTrans.localScale = new Vector3(veggieScale.x * 0.5f, veggieScale.y, veggieScale.z);
|
||||
squashTween = veggieTrans.DOScaleX(veggieScale.x, cond.pitchedSecPerBeat * 0.5f);
|
||||
|
||||
ResetState();
|
||||
|
||||
Update(); // Update flying veggie state immediately.
|
||||
}
|
||||
|
||||
|
@ -283,13 +294,5 @@ namespace HeavenStudio.Games.Scripts_CropStomp
|
|||
|
||||
PickedUpdate();
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
if (veggieState == 0)
|
||||
StompVeggie(true);
|
||||
else
|
||||
PickVeggie(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,9 @@ namespace HeavenStudio.Games
|
|||
|
||||
foreach(PlayerActionEvent toCompare in scheduledInputs)
|
||||
{
|
||||
// ignore inputs that are for sequencing in autoplay
|
||||
if (toCompare.autoplayOnly) continue;
|
||||
|
||||
if(closest == null)
|
||||
{
|
||||
if (input == InputType.ANY || toCompare.inputType.HasFlag(input))
|
||||
|
|
Loading…
Reference in a new issue