From c8087d97f670d4650a6209ec6ce153cf1d64a772 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Tue, 8 Feb 2022 23:52:50 -0700 Subject: [PATCH] Tweezers:: Code cleanup --- Assets/Resources/Games/rhythmTweezers.prefab | 2 +- Assets/Scripts/Games/RhythmTweezers/Hair.cs | 9 +++++++-- Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs | 3 ++- Assets/Scripts/Games/RhythmTweezers/Tweezers.cs | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Assets/Resources/Games/rhythmTweezers.prefab b/Assets/Resources/Games/rhythmTweezers.prefab index 3957b2c1..0d21825d 100644 --- a/Assets/Resources/Games/rhythmTweezers.prefab +++ b/Assets/Resources/Games/rhythmTweezers.prefab @@ -907,7 +907,7 @@ MonoBehaviour: EligibleHits: [] firstEnable: 0 Vegetable: {fileID: 3177931334588542204} - Tweezers: {fileID: 3684904985109994079} + Tweezers: {fileID: 3391455012319192365} HairsHolder: {fileID: 2002856028339003249} tweezersBeatOffset: 2 tweezersRotOffset: {x: -202, y: 180} diff --git a/Assets/Scripts/Games/RhythmTweezers/Hair.cs b/Assets/Scripts/Games/RhythmTweezers/Hair.cs index f954a109..0021dd08 100644 --- a/Assets/Scripts/Games/RhythmTweezers/Hair.cs +++ b/Assets/Scripts/Games/RhythmTweezers/Hair.cs @@ -7,13 +7,19 @@ namespace RhythmHeavenMania.Games.RhythmTweezers public class Hair : PlayerActionObject { public float createBeat; + private Tweezers tweezers; + + private void Awake() + { + tweezers = RhythmTweezers.instance.Tweezers; + } private void Update() { float stateBeat = Conductor.instance.GetPositionFromBeat(createBeat, 4f); StateCheck(stateBeat); - if (PlayerInput.Pressed() && RhythmTweezers.instance.Tweezers.GetComponent().hitOnFrame == 0) + if (PlayerInput.Pressed() && tweezers.hitOnFrame == 0) { if (state.perfect) { @@ -24,7 +30,6 @@ namespace RhythmHeavenMania.Games.RhythmTweezers public void Ace() { - Tweezers tweezers = RhythmTweezers.instance.Tweezers.GetComponent(); tweezers.Pluck(true, this); tweezers.hitOnFrame++; diff --git a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs index 1f96d2cf..d5998e35 100644 --- a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs +++ b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs @@ -10,7 +10,8 @@ namespace RhythmHeavenMania.Games.RhythmTweezers public class RhythmTweezers : Minigame { public GameObject Vegetable; - public GameObject Tweezers; + public Animator VegetableAnimator; + public Tweezers Tweezers; [SerializeField] private GameObject HairsHolder; diff --git a/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs b/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs index eb519193..f4a49c0e 100644 --- a/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs +++ b/Assets/Scripts/Games/RhythmTweezers/Tweezers.cs @@ -10,10 +10,12 @@ namespace RhythmHeavenMania.Games.RhythmTweezers { public int hitOnFrame; private Animator anim; + private Animator vegetableAnim; private void Start() { anim = GetComponent(); + vegetableAnim = RhythmTweezers.instance.VegetableAnimator; } private void LateUpdate()