2022-02-08 14:26:55 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.RhythmTweezers
|
|
|
|
{
|
2022-02-09 03:58:25 +00:00
|
|
|
// use PlayerActionObject for the actual tweezers but this isn't playable rn so IDC
|
2022-02-08 14:26:55 +00:00
|
|
|
public class RhythmTweezers : Minigame
|
|
|
|
{
|
2022-02-09 03:58:25 +00:00
|
|
|
public GameObject Vegetable;
|
2022-02-09 06:52:50 +00:00
|
|
|
public Animator VegetableAnimator;
|
|
|
|
public Tweezers Tweezers;
|
2022-02-09 03:58:25 +00:00
|
|
|
|
|
|
|
[SerializeField] private GameObject HairsHolder;
|
|
|
|
|
|
|
|
public float tweezersBeatOffset;
|
|
|
|
public Vector2 tweezersRotOffset;
|
|
|
|
public float rotSpd;
|
|
|
|
public float offset;
|
|
|
|
|
|
|
|
public static RhythmTweezers instance { get; set; }
|
|
|
|
|
|
|
|
private void Awake()
|
2022-02-08 14:26:55 +00:00
|
|
|
{
|
2022-02-09 03:58:25 +00:00
|
|
|
instance = this;
|
|
|
|
}
|
2022-02-08 14:26:55 +00:00
|
|
|
|
2022-02-09 03:58:25 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
float beat = 0;
|
|
|
|
float offset = 0f;
|
|
|
|
BeatAction.New(HairsHolder, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + offset, delegate { SpawnHair(beat + offset); }),
|
|
|
|
new BeatAction.Action(beat + 1f + offset, delegate { SpawnHair(beat + 1f + offset); }),
|
|
|
|
new BeatAction.Action(beat + 2f + offset, delegate
|
|
|
|
{
|
|
|
|
SpawnHair(beat + 2f + offset);
|
|
|
|
}),
|
|
|
|
new BeatAction.Action(beat + 3f + offset, delegate { SpawnHair(beat + 3f + offset); }),
|
|
|
|
});
|
2022-02-08 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 03:58:25 +00:00
|
|
|
private void SpawnHair(float beat)
|
2022-02-08 14:26:55 +00:00
|
|
|
{
|
2022-02-09 03:58:25 +00:00
|
|
|
Jukebox.PlayOneShotGame("rhythmTweezers/shortAppear", beat);
|
|
|
|
GameObject hair = Instantiate(HairsHolder.transform.GetChild(0).gameObject, HairsHolder.transform);
|
|
|
|
hair.SetActive(true);
|
|
|
|
|
|
|
|
float rot = ((offset / 3f) * (beat * 2f)) - offset;
|
2022-02-08 14:26:55 +00:00
|
|
|
|
2022-02-09 03:58:25 +00:00
|
|
|
hair.transform.eulerAngles = new Vector3(0, 0, rot);
|
|
|
|
hair.GetComponent<Hair>().createBeat = beat;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(tweezersBeatOffset, rotSpd);
|
|
|
|
float rot = Mathf.Lerp(tweezersRotOffset.x, tweezersRotOffset.y, normalizedBeat);
|
|
|
|
Tweezers.transform.eulerAngles = new Vector3(0, 0, rot);
|
2022-02-08 14:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|