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

52 lines
1.3 KiB
C#
Raw Normal View History

2022-02-09 03:58:25 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.RhythmTweezers
{
public class Tweezers : MonoBehaviour
{
public int hitOnFrame;
private Animator anim;
2022-02-09 06:52:50 +00:00
private Animator vegetableAnim;
2022-02-09 03:58:25 +00:00
private void Start()
{
anim = GetComponent<Animator>();
2022-02-09 06:52:50 +00:00
vegetableAnim = RhythmTweezers.instance.VegetableAnimator;
2022-02-09 03:58:25 +00:00
}
private void LateUpdate()
{
if (PlayerInput.Pressed())
{
hitOnFrame = 0;
}
}
public void Pluck(bool ace, Hair hair)
{
anim.Play("Tweezers_Pluck", 0, 0);
if (hitOnFrame > 0) return;
// tweezer pluck anim here
if (ace)
{
var game = RhythmTweezers.instance;
2022-02-09 03:58:25 +00:00
Jukebox.PlayOneShotGame($"rhythmTweezers/shortPluck{Random.Range(1, 21)}");
Destroy(hair.gameObject);
game.hairsLeft--;
if (game.hairsLeft <= 0)
vegetableAnim.Play("HopFinal", 0, 0);
else
vegetableAnim.Play("Hop", 0, 0);
2022-02-09 03:58:25 +00:00
}
}
}
}