HeavenStudioPlus/Assets/Scripts/Games/CropStomp/Farmer.cs

84 lines
2.4 KiB
C#
Raw Normal View History

2022-02-28 08:33:11 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
2022-02-28 08:33:11 +00:00
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games.Scripts_CropStomp
2022-02-28 08:33:11 +00:00
{
public class Farmer : MonoBehaviour
2022-02-28 08:33:11 +00:00
{
public float nextStompBeat;
private CropStomp game;
PlayerActionEvent stomp;
public void Init()
2022-02-28 08:33:11 +00:00
{
game = CropStomp.instance;
}
private void Update()
{
if (!game.isMarching)
return;
Conductor cond = Conductor.instance;
2022-02-28 08:33:11 +00:00
if (stomp == null && cond.isPlaying)
{
if (GameManager.instance.currentGame == "cropStomp")
{
stomp = game.ScheduleUserInput(nextStompBeat - 1f, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
stomp.countsForAccuracy = false;
}
}
2022-02-28 08:33:11 +00:00
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
2022-02-28 08:33:11 +00:00
{
game.bodyAnim.Play("Crouch", 0, 0);
2022-02-28 08:33:11 +00:00
}
}
2022-02-28 08:33:11 +00:00
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);
stomp.countsForAccuracy = false;
}
private void Out(PlayerActionEvent caller) {}
void Stomp(bool ng)
{
if (GameManager.instance.currentGame != "cropStomp") return;
if (!game.isMarching)
return;
if (ng)
{
game.bodyAnim.Play("Crouch", 0, 0);
}
else
2022-02-28 08:33:11 +00:00
{
game.Stomp();
game.bodyAnim.Play("Stomp", 0, 0);
2022-02-28 08:33:11 +00:00
}
nextStompBeat += 2f;
stomp?.Disable();
stomp = game.ScheduleUserInput(nextStompBeat - 1f, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
stomp.countsForAccuracy = false;
2022-02-28 08:33:11 +00:00
}
}
}