mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
Tweezers: Plucking animation additions. Autoplay support.
This commit is contained in:
@ -166,6 +166,11 @@ namespace RhythmHeavenMania
|
||||
return a;
|
||||
}
|
||||
|
||||
public float GetPositionFromMargin(float targetBeat, float margin)
|
||||
{
|
||||
return GetPositionFromBeat(targetBeat - margin, margin);
|
||||
}
|
||||
|
||||
public float GetSongPosFromBeat(float beat)
|
||||
{
|
||||
return secPerBeat * beat;
|
||||
|
@ -1,14 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
{
|
||||
public class Hair : PlayerActionObject
|
||||
{
|
||||
public float createBeat;
|
||||
public GameObject hairSprite;
|
||||
public GameObject stubbleSprite;
|
||||
public GameObject missedSprite;
|
||||
private RhythmTweezers game;
|
||||
private Tweezers tweezers;
|
||||
private bool plucked;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -18,23 +23,41 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float stateBeat = Conductor.instance.GetPositionFromBeat(createBeat + game.tweezerBeatOffset, game.beatInterval);
|
||||
if (plucked) return;
|
||||
|
||||
float stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.tweezerBeatOffset + game.beatInterval, 1f);
|
||||
StateCheck(stateBeat);
|
||||
|
||||
if (PlayerInput.Pressed() && tweezers.hitOnFrame == 0)
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
else if (state.notPerfect())
|
||||
{
|
||||
Miss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Ace()
|
||||
{
|
||||
tweezers.Pluck(true, this);
|
||||
|
||||
tweezers.hitOnFrame++;
|
||||
plucked = true;
|
||||
}
|
||||
|
||||
public void Miss()
|
||||
{
|
||||
tweezers.Pluck(false, this);
|
||||
tweezers.hitOnFrame++;
|
||||
plucked = true;
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
}
|
||||
}
|
@ -150,7 +150,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
foreach (Transform t in HairsHolder.transform)
|
||||
{
|
||||
var go = t.gameObject;
|
||||
if (go != hairBase)
|
||||
if (go != hairBase && go != longHairBase)
|
||||
{
|
||||
GameObject.Destroy(go);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
@ -9,9 +10,10 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
public class Tweezers : MonoBehaviour
|
||||
{
|
||||
public int hitOnFrame;
|
||||
private Animator anim;
|
||||
[NonSerialized] public Animator anim;
|
||||
private Animator vegetableAnim;
|
||||
private RhythmTweezers game;
|
||||
private bool plucking;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -25,21 +27,23 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
{
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
hitOnFrame = 0;
|
||||
if (!plucking) // Did you do a successful pluck earlier in the frame?
|
||||
{
|
||||
anim.Play("Tweezers_Pluck", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
plucking = false;
|
||||
}
|
||||
|
||||
public void Pluck(bool ace, Hair hair)
|
||||
{
|
||||
anim.Play("Tweezers_Pluck", 0, 0);
|
||||
|
||||
if (hitOnFrame > 0) return;
|
||||
// tweezer pluck anim here
|
||||
|
||||
if (ace)
|
||||
{
|
||||
Jukebox.PlayOneShotGame($"rhythmTweezers/shortPluck{Random.Range(1, 21)}");
|
||||
Destroy(hair.gameObject);
|
||||
Jukebox.PlayOneShotGame($"rhythmTweezers/shortPluck{UnityEngine.Random.Range(1, 21)}");
|
||||
|
||||
hair.hairSprite.SetActive(false);
|
||||
hair.stubbleSprite.SetActive(true);
|
||||
|
||||
game.hairsLeft--;
|
||||
|
||||
@ -47,7 +51,23 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
vegetableAnim.Play("HopFinal", 0, 0);
|
||||
else
|
||||
vegetableAnim.Play("Hop", 0, 0);
|
||||
|
||||
anim.Play("Tweezers_Pluck_Success", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame($"rhythmTweezers/shortPluck{UnityEngine.Random.Range(1, 21)}");
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
hair.hairSprite.SetActive(false);
|
||||
hair.missedSprite.SetActive(true);
|
||||
|
||||
vegetableAnim.Play("Blink", 0, 0);
|
||||
|
||||
anim.Play("Tweezers_Pluck_Fail", 0, 0);
|
||||
}
|
||||
|
||||
plucking = true; // Prevents standard pluck from playing in LateUpdate().
|
||||
}
|
||||
|
||||
public void LongPluck(bool ace, LongHair hair)
|
||||
@ -61,7 +81,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
float beat = Conductor.instance.songPositionInBeats;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"rhythmTweezers/longPull{Random.Range(1, 5)}", beat),
|
||||
new MultiSound.Sound($"rhythmTweezers/longPull{UnityEngine.Random.Range(1, 5)}", beat),
|
||||
new MultiSound.Sound("rhythmTweezers/longPullEnd", beat + 0.5f),
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user