2022-02-28 17:17:50 +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 17:17:50 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_TapTrial
|
2022-02-28 17:17:50 +00:00
|
|
|
{
|
|
|
|
public class Tap : PlayerActionObject
|
|
|
|
{
|
|
|
|
public float startBeat;
|
|
|
|
|
|
|
|
public int type;
|
2022-03-26 02:08:46 +00:00
|
|
|
|
|
|
|
void Awake()
|
2022-02-28 17:17:50 +00:00
|
|
|
{
|
|
|
|
PlayerActionInit(this.gameObject, startBeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnAce()
|
|
|
|
{
|
|
|
|
Hit(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (Conductor.instance.GetPositionFromBeat(startBeat, 2) >= 1)
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
TapTrial.instance.player.Tap(hit, type);
|
|
|
|
|
|
|
|
if (hit)
|
|
|
|
CleanUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CleanUp()
|
|
|
|
{
|
|
|
|
Destroy(this.gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|