HeavenStudioPlus/Assets/Scripts/Games/RhythmTweezers/Hair.cs

63 lines
1.5 KiB
C#
Raw Normal View History

2022-02-09 03:58:25 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
2022-02-09 03:58:25 +00:00
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games.Scripts_RhythmTweezers
2022-02-09 03:58:25 +00:00
{
public class Hair : PlayerActionObject
{
public float createBeat;
public GameObject hairSprite;
public GameObject stubbleSprite;
public GameObject missedSprite;
private RhythmTweezers game;
2022-02-09 06:52:50 +00:00
private Tweezers tweezers;
private bool plucked;
2022-02-09 06:52:50 +00:00
private void Awake()
{
game = RhythmTweezers.instance;
tweezers = game.Tweezers;
2022-02-09 06:52:50 +00:00
}
2022-02-09 03:58:25 +00:00
private void Update()
{
if (plucked) return;
float stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.tweezerBeatOffset + game.beatInterval, 1f);
2022-02-09 03:58:25 +00:00
StateCheck(stateBeat);
if (PlayerInput.Pressed(true))
2022-02-09 03:58:25 +00:00
{
if (state.perfect)
{
Ace();
}
else if (state.notPerfect())
{
Miss();
}
2022-02-09 03:58:25 +00:00
}
}
public void Ace()
{
tweezers.Pluck(true, this);
tweezers.hitOnFrame++;
plucked = true;
}
2022-02-09 03:58:25 +00:00
public void Miss()
{
tweezers.Pluck(false, this);
2022-02-09 03:58:25 +00:00
tweezers.hitOnFrame++;
plucked = true;
}
public override void OnAce()
{
Ace();
2022-02-09 03:58:25 +00:00
}
}
}