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
|
|
|
|
{
|
|
|
|
public float startBeat;
|
2022-03-07 17:10:50 +00:00
|
|
|
public bool applause = true;
|
2022-03-07 05:00:54 +00:00
|
|
|
private bool hit = false;
|
|
|
|
private bool hasHit = false;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
PlayerActionInit(gameObject, startBeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnAce()
|
|
|
|
{
|
|
|
|
Hit(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (Conductor.instance.GetPositionFromBeat(startBeat, 2) >= 1)
|
|
|
|
{
|
|
|
|
DrummingPractice.instance.SetFaces(0);
|
|
|
|
CleanUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hit && Conductor.instance.GetPositionFromBeat(startBeat, 1) >= 1)
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("drummingPractice/drum");
|
2022-03-07 17:10:50 +00:00
|
|
|
DrummingPractice.instance.leftDrummer.Hit(true, false);
|
|
|
|
DrummingPractice.instance.rightDrummer.Hit(true, false);
|
2022-03-07 05:00:54 +00:00
|
|
|
hit = true;
|
|
|
|
if (hasHit) CleanUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 1f);
|
|
|
|
StateCheck(normalizedBeat);
|
|
|
|
|
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
Hit(true);
|
|
|
|
} else if (state.notPerfect())
|
|
|
|
{
|
|
|
|
Hit(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Hit(bool _hit)
|
|
|
|
{
|
|
|
|
if (!hasHit)
|
|
|
|
{
|
2022-03-07 17:10:50 +00:00
|
|
|
DrummingPractice.instance.player.Hit(_hit, applause, true);
|
2022-03-07 05:00:54 +00:00
|
|
|
DrummingPractice.instance.SetFaces(_hit ? 1 : 2);
|
|
|
|
|
|
|
|
hasHit = true;
|
|
|
|
|
|
|
|
if (hit) CleanUp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CleanUp()
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|