mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 03:17:40 +02:00
bread2unity BCCAD interpreter setup
This commit is contained in:
40
Assets/Scripts/Games/RhythmTweezers/LongHair.cs
Normal file
40
Assets/Scripts/Games/RhythmTweezers/LongHair.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
{
|
||||
public class LongHair : PlayerActionObject
|
||||
{
|
||||
public float createBeat;
|
||||
private RhythmTweezers game;
|
||||
private Tweezers tweezers;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = RhythmTweezers.instance;
|
||||
tweezers = game.Tweezers;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float stateBeat = Conductor.instance.GetPositionFromBeat(createBeat + game.tweezerBeatOffset, game.beatInterval);
|
||||
StateCheck(stateBeat);
|
||||
|
||||
if (PlayerInput.Pressed() && tweezers.hitOnFrame == 0)
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Ace()
|
||||
{
|
||||
tweezers.LongPluck(true, this);
|
||||
|
||||
tweezers.hitOnFrame++;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/RhythmTweezers/LongHair.cs.meta
Normal file
11
Assets/Scripts/Games/RhythmTweezers/LongHair.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3279e585337e95a40b3621073b3c77b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -17,6 +17,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
public Animator VegetableAnimator;
|
||||
public Tweezers Tweezers;
|
||||
public GameObject hairBase;
|
||||
public GameObject longHairBase;
|
||||
|
||||
[SerializeField] private GameObject HairsHolder;
|
||||
[NonSerialized] public int hairsLeft = 0;
|
||||
@ -57,6 +58,25 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
hairsLeft++;
|
||||
}
|
||||
|
||||
public void SpawnLongHair(float beat)
|
||||
{
|
||||
StopTransitionIfActive();
|
||||
|
||||
if (!intervalStarted)
|
||||
{
|
||||
SetIntervalStart(beat, beatInterval);
|
||||
}
|
||||
|
||||
Jukebox.PlayOneShotGame("rhythmTweezers/longAppear", beat);
|
||||
LongHair hair = Instantiate(longHairBase, HairsHolder.transform).GetComponent<LongHair>();
|
||||
hair.gameObject.SetActive(true);
|
||||
|
||||
float rot = -58f + 116 * Mathp.Normalize(beat, intervalStartBeat, intervalStartBeat + beatInterval - 1f);
|
||||
hair.transform.eulerAngles = new Vector3(0, 0, rot);
|
||||
hair.createBeat = beat;
|
||||
hairsLeft++;
|
||||
}
|
||||
|
||||
public void SetIntervalStart(float beat, float interval = 4f)
|
||||
{
|
||||
// End transition early if the interval starts a lil early.
|
||||
|
@ -11,11 +11,14 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
public int hitOnFrame;
|
||||
private Animator anim;
|
||||
private Animator vegetableAnim;
|
||||
private RhythmTweezers game;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
vegetableAnim = RhythmTweezers.instance.VegetableAnimator;
|
||||
|
||||
game = RhythmTweezers.instance;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
@ -35,8 +38,6 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
|
||||
if (ace)
|
||||
{
|
||||
var game = RhythmTweezers.instance;
|
||||
|
||||
Jukebox.PlayOneShotGame($"rhythmTweezers/shortPluck{Random.Range(1, 21)}");
|
||||
Destroy(hair.gameObject);
|
||||
|
||||
@ -48,5 +49,24 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
|
||||
vegetableAnim.Play("Hop", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void LongPluck(bool ace, LongHair hair)
|
||||
{
|
||||
anim.Play("Tweezers_Pluck", 0, 0);
|
||||
|
||||
if (hitOnFrame > 0) return;
|
||||
|
||||
if (ace)
|
||||
{
|
||||
float beat = Conductor.instance.songPositionInBeats;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound($"rhythmTweezers/longPull{Random.Range(1, 5)}", beat),
|
||||
new MultiSound.Sound("rhythmTweezers/longPullEnd", beat + 0.5f),
|
||||
});
|
||||
|
||||
Destroy(hair.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user