Merge pull request #26 from jakobwcrowe/megaminerzero

Tweezers programming fixes
This commit is contained in:
Jenny Crowe 2022-02-10 03:15:31 -07:00 committed by GitHub
commit 31b5d5408d

View file

@ -19,7 +19,7 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
public GameObject hairBase; public GameObject hairBase;
public GameObject longHairBase; public GameObject longHairBase;
[SerializeField] private GameObject HairsHolder; public GameObject HairsHolder;
[NonSerialized] public int hairsLeft = 0; [NonSerialized] public int hairsLeft = 0;
public float beatInterval = 4f; public float beatInterval = 4f;
@ -78,14 +78,18 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
} }
public void SetIntervalStart(float beat, float interval = 4f) public void SetIntervalStart(float beat, float interval = 4f)
{
// Don't do these things if the interval was already started.
if (!intervalStarted)
{ {
// End transition early if the interval starts a lil early. // End transition early if the interval starts a lil early.
StopTransitionIfActive(); StopTransitionIfActive();
hairsLeft = 0;
intervalStarted = true;
}
intervalStartBeat = beat; intervalStartBeat = beat;
beatInterval = interval; beatInterval = interval;
intervalStarted = true;
hairsLeft = 0;
} }
const float vegDupeOffset = 16.7f; const float vegDupeOffset = 16.7f;
@ -136,7 +140,9 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
// Set tweezer to follow vegetable. // Set tweezer to follow vegetable.
var currentTweezerPos = Tweezers.transform.localPosition; var currentTweezerPos = Tweezers.transform.localPosition;
Tweezers.transform.localPosition = new Vector3(currentTweezerPos.x, Vegetable.transform.localPosition.y + 1f, currentTweezerPos.z); var vegetablePos = Vegetable.transform.localPosition;
var vegetableHolderPos = VegetableHolder.transform.localPosition;
Tweezers.transform.localPosition = new Vector3(vegetableHolderPos.x, vegetablePos.y + 1f, currentTweezerPos.z);
} }
private void ResetVegetable() private void ResetVegetable()
@ -145,8 +151,10 @@ namespace RhythmHeavenMania.Games.RhythmTweezers
{ {
var go = t.gameObject; var go = t.gameObject;
if (go != hairBase) if (go != hairBase)
{
GameObject.Destroy(go); GameObject.Destroy(go);
} }
}
VegetableAnimator.Play("Idle", 0, 0); VegetableAnimator.Play("Idle", 0, 0);
} }