HeavenStudioPlus/Assets/Scripts/Games/DrummingPractice/DrummerHit.cs

82 lines
2.2 KiB
C#
Raw Normal View History

2022-03-07 05:00:54 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
2022-03-07 05:00:54 +00:00
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games.Scripts_DrummingPractice
2022-03-07 05:00:54 +00:00
{
public class DrummerHit : PlayerActionObject
{
DrummingPractice game;
2022-03-07 05:00:54 +00:00
public float startBeat;
public bool applause = true;
2022-03-07 05:00:54 +00:00
// Start is called before the first frame update
void Awake()
2022-03-07 05:00:54 +00:00
{
game = DrummingPractice.instance;
2022-03-07 05:00:54 +00:00
}
void Start()
{
game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN, Just, Miss, Out);
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(startBeat+1f, delegate {
Jukebox.PlayOneShotGame("drummingPractice/drum");
game.leftDrummer.Hit(true, false);
game.rightDrummer.Hit(true, false);
}),
});
2022-03-07 05:00:54 +00:00
}
// Update is called once per frame
void Update() { }
2022-03-07 05:00:54 +00:00
private void Just(PlayerActionEvent caller, float state)
{
if (state >= 1f || state <= -1f) {
Hit(false);
2022-03-07 05:00:54 +00:00
}
Hit(true);
}
2022-03-07 05:00:54 +00:00
private void Miss(PlayerActionEvent caller)
{
game.SetFaces(2);
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
2022-03-07 05:00:54 +00:00
{
new BeatAction.Action(startBeat+2f, delegate {
game.SetFaces(0);
})
});
CleanUp();
2022-03-07 05:00:54 +00:00
}
private void Out(PlayerActionEvent caller) {}
2022-03-07 05:00:54 +00:00
public void Hit(bool _hit)
{
game.player.Hit(_hit, applause, true);
game.SetFaces(_hit ? 1 : 2);
2022-03-07 05:00:54 +00:00
if (!_hit)
{
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(startBeat+2f, delegate {
game.SetFaces(0);
}),
});
2022-03-07 05:00:54 +00:00
}
CleanUp();
2022-03-07 05:00:54 +00:00
}
public void CleanUp()
{
Destroy(gameObject);
}
}
}