bread2unity BCCAD interpreter setup

This commit is contained in:
Braedon
2022-02-10 03:13:54 -05:00
parent 5dc432a9d9
commit 772ab2783c
19 changed files with 541 additions and 108 deletions

View 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++;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3279e585337e95a40b3621073b3c77b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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.

View File

@ -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);
}
}
}
}