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
|
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
DrummingPractice game;
|
2022-03-07 05:00:54 +00:00
|
|
|
public float startBeat;
|
2022-03-07 17:10:50 +00:00
|
|
|
public bool applause = true;
|
2022-03-07 05:00:54 +00:00
|
|
|
|
|
|
|
// Start is called before the first frame update
|
2022-03-26 02:08:46 +00:00
|
|
|
void Awake()
|
2022-03-07 05:00:54 +00:00
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
game = DrummingPractice.instance;
|
2022-03-07 05:00:54 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 04:33:37 +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
|
2023-01-15 04:33:37 +00:00
|
|
|
void Update() { }
|
2022-03-07 05:00:54 +00:00
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Just(PlayerActionEvent caller, float state)
|
|
|
|
{
|
|
|
|
if (state >= 1f || state <= -1f) {
|
|
|
|
Hit(false);
|
2022-03-07 05:00:54 +00:00
|
|
|
}
|
2023-01-15 04:33:37 +00:00
|
|
|
Hit(true);
|
|
|
|
}
|
2022-03-07 05:00:54 +00:00
|
|
|
|
2023-01-15 04:33:37 +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
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
new BeatAction.Action(startBeat+2f, delegate {
|
|
|
|
game.SetFaces(0);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
CleanUp();
|
2022-03-07 05:00:54 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Out(PlayerActionEvent caller) {}
|
|
|
|
|
2022-03-07 05:00:54 +00:00
|
|
|
public void Hit(bool _hit)
|
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
game.player.Hit(_hit, applause, true);
|
|
|
|
game.SetFaces(_hit ? 1 : 2);
|
2022-03-07 05:00:54 +00:00
|
|
|
|
2023-01-15 04:33:37 +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
|
|
|
}
|
2023-01-15 04:33:37 +00:00
|
|
|
CleanUp();
|
2022-03-07 05:00:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void CleanUp()
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|