update blue bear to use PlayerActionEvent

This commit is contained in:
minenice55 2023-01-14 17:08:19 -05:00
parent 0115333d8b
commit b6b0232a4a
2 changed files with 22 additions and 40 deletions

View file

@ -68,11 +68,11 @@ namespace HeavenStudio.Games
{
headAndBodyAnim.SetBool("ShouldOpenMouth", foodHolder.childCount != 0);
if (PlayerInput.GetAnyDirectionDown())
if (PlayerInput.GetAnyDirectionDown() && !IsExpectingInputNow(InputType.DIRECTION_DOWN))
{
headAndBodyAnim.Play("BiteL", 0, 0);
}
else if (PlayerInput.Pressed())
else if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
{
headAndBodyAnim.Play("BiteR", 0, 0);
}

View file

@ -27,6 +27,7 @@ namespace HeavenStudio.Games.Scripts_BlueBear
game = BlueBear.instance;
flyBeats = isCake ? 3f : 2f;
game.ScheduleInput(startBeat, flyBeats, isCake ? InputType.DIRECTION_DOWN : InputType.STANDARD_DOWN, EatJust, EatOut, EatOut);
}
private void Update()
@ -47,46 +48,9 @@ namespace HeavenStudio.Games.Scripts_BlueBear
float rot = isCake ? rotSpeed : -rotSpeed;
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (rot * Time.deltaTime));
float normalizedBeat = cond.GetPositionFromMargin(startBeat + flyBeats, 1f);
StateCheck(normalizedBeat);
if (PlayerInput.Pressed())
{
if (!isCake)
{
if (state.perfect)
{
flying = false;
Jukebox.PlayOneShotGame("blueBear/chompDonut");
SpawnCrumbs();
GameObject.Destroy(gameObject);
}
}
}
else if (PlayerInput.GetAnyDirection())
{
if (isCake)
{
if (state.perfect)
{
flying = false;
Jukebox.PlayOneShotGame("blueBear/chompCake");
SpawnCrumbs();
GameObject.Destroy(gameObject);
}
}
}
}
}
public override void OnAce()
void EatFood()
{
flying = false;
@ -106,6 +70,24 @@ namespace HeavenStudio.Games.Scripts_BlueBear
GameObject.Destroy(gameObject);
}
private void EatJust(PlayerActionEvent caller, float state)
{
if (state >= 1f || state <= -1f) { //todo: proper near miss feedback
if (isCake)
{
game.headAndBodyAnim.Play("BiteL", 0, 0);
}
else
{
game.headAndBodyAnim.Play("BiteR", 0, 0);
}
return;
}
EatFood();
}
private void EatOut(PlayerActionEvent caller) {}
void SpawnCrumbs()
{
var crumbsGO = GameObject.Instantiate(game.crumbsBase, game.crumbsHolder);