mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:27:40 +02:00
Long hair rhythm tweezers but very buggy (read desc)
Hair plucking is a bit weird a beat after a long pull. The tweezers don't automatically skip to the beat they're supposed to be when pulling since it can put things out of sync. You can't pull two long hairs at a time for some reason. The long hair doesn't rotate correctly towards the tweezers. I'm very tired if someone could go in and clean some of this up that would be great.
This commit is contained in:
@ -2,14 +2,23 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
{
|
||||
public class LongHair : PlayerActionObject
|
||||
{
|
||||
public float createBeat;
|
||||
public GameObject hairSprite;
|
||||
public GameObject stubbleSprite;
|
||||
private RhythmTweezers game;
|
||||
private Tweezers tweezers;
|
||||
|
||||
private bool isHolding = false;
|
||||
private float holdBeat = 0f;
|
||||
|
||||
public GameObject holder;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = RhythmTweezers.instance;
|
||||
@ -25,13 +34,42 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Ace();
|
||||
Jukebox.PlayOneShotGame($"rhythmTweezers/longPull{UnityEngine.Random.Range(1, 5)}");
|
||||
isHolding = true;
|
||||
holdBeat = Conductor.instance.songPositionInBeats;
|
||||
}
|
||||
}
|
||||
|
||||
if (isHolding && Conductor.instance.songPositionInBeats >= holdBeat + 0.5f)
|
||||
{
|
||||
Destroy(holder.transform.GetChild(0).gameObject);
|
||||
isHolding = false;
|
||||
Ace();
|
||||
}
|
||||
|
||||
|
||||
if (isHolding)
|
||||
{
|
||||
holder.transform.eulerAngles = new Vector3(0, 0, tweezers.transform.eulerAngles.z * 1.056f);
|
||||
holder.transform.GetChild(0).transform.localScale = Vector2.one / holder.transform.localScale;
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(holdBeat, 0.5f);
|
||||
GetComponent<Animator>().Play("LoopPull", 0, normalizedBeat);
|
||||
tweezers.anim.Play("Tweezers_LongPluck", 0, normalizedBeat);
|
||||
// float angleBetweenTweezersAndHair = angleBtw2Points(tweezers.transform.position, holder.transform.position);
|
||||
// holder.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angleBetweenTweezersAndHair));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float angleBtw2Points(Vector3 a, Vector3 b)
|
||||
{
|
||||
return Mathf.Atan2(a.y - b.y, a.x - b.x) * Mathf.Rad2Deg;
|
||||
}
|
||||
|
||||
public void Ace()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("rhythmTweezers/longPullEnd");
|
||||
tweezers.LongPluck(true, this);
|
||||
|
||||
tweezers.hitOnFrame++;
|
||||
|
@ -58,6 +58,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
Jukebox.PlayOneShotGame("rhythmTweezers/shortAppear", beat);
|
||||
Hair hair = Instantiate(hairBase, HairsHolder.transform).GetComponent<Hair>();
|
||||
hair.gameObject.SetActive(true);
|
||||
hair.GetComponent<Animator>().Play("SmallAppear", 0, 0);
|
||||
|
||||
float rot = -58f + 116 * Mathp.Normalize(beat, intervalStartBeat, intervalStartBeat + beatInterval - 1f);
|
||||
hair.transform.eulerAngles = new Vector3(0, 0, rot);
|
||||
@ -77,6 +78,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
Jukebox.PlayOneShotGame("rhythmTweezers/longAppear", beat);
|
||||
LongHair hair = Instantiate(longHairBase, HairsHolder.transform).GetComponent<LongHair>();
|
||||
hair.gameObject.SetActive(true);
|
||||
hair.GetComponent<Animator>().Play("LongAppear", 0, 0);
|
||||
|
||||
float rot = -58f + 116 * Mathp.Normalize(beat, intervalStartBeat, intervalStartBeat + beatInterval - 1f);
|
||||
hair.transform.eulerAngles = new Vector3(0, 0, rot);
|
||||
|
@ -79,21 +79,26 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
|
||||
public void LongPluck(bool ace, LongHair hair)
|
||||
{
|
||||
anim.Play("Tweezers_Pluck", 0, 0);
|
||||
|
||||
if (hitOnFrame > 0) return;
|
||||
DropHeldHair();
|
||||
|
||||
if (ace)
|
||||
{
|
||||
float beat = Conductor.instance.songPositionInBeats;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"rhythmTweezers/longPull{UnityEngine.Random.Range(1, 5)}", beat),
|
||||
new MultiSound.Sound("rhythmTweezers/longPullEnd", beat + 0.5f),
|
||||
});
|
||||
hair.hairSprite.SetActive(false);
|
||||
hair.stubbleSprite.SetActive(true);
|
||||
|
||||
Destroy(hair.gameObject);
|
||||
game.hairsLeft--;
|
||||
game.eyeSize = Mathf.Clamp(game.eyeSize + 1, 0, 10);
|
||||
|
||||
if (game.hairsLeft <= 0)
|
||||
vegetableAnim.Play("HopFinal", 0, 0);
|
||||
else
|
||||
vegetableAnim.Play("Hop" + game.eyeSize.ToString(), 0, 0);
|
||||
|
||||
anim.Play("Tweezers_Pluck_Success", 0, 0);
|
||||
}
|
||||
|
||||
pluckingThisFrame = true;
|
||||
holdingHair = true;
|
||||
}
|
||||
|
||||
public void DropHeldHair()
|
||||
@ -110,6 +115,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
|
||||
// Make the hair spin.
|
||||
// (The prefab has a Rigidbody2D component already so that it falls)
|
||||
droppedHair.GetComponent<Rigidbody2D>().interpolation = RigidbodyInterpolation2D.Interpolate;
|
||||
droppedHair.GetComponent<Rigidbody2D>().angularVelocity = UnityEngine.Random.Range(-120f, 120f);
|
||||
|
||||
holdingHair = false;
|
||||
|
Reference in New Issue
Block a user