From e7df4bc7c1abf025ba71132ad573c52d0e1682aa Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Sun, 4 Feb 2024 20:59:24 +0100 Subject: [PATCH] bug fix and huh choice --- .../Games/LumBEARjack/LBJSmallObject.cs | 22 +++++++++-- .../Scripts/Games/LumBEARjack/LumBEARjack.cs | 38 ++++++++++++++----- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs b/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs index 5bfb9e257..b4bfc0588 100644 --- a/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs +++ b/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs @@ -21,6 +21,7 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack private LBJBear _bear; private LumBEARjack.SmallType _type; + private LumBEARjack.HuhChoice _huh; private double _rotationBeat; private double _rotationLength; @@ -33,10 +34,11 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack _broom.SetActive(false); } - public void Init(LBJBear bear, double beat, double length, LumBEARjack.SmallType type, double startUpBeat = -1) + public void Init(LBJBear bear, double beat, double length, LumBEARjack.SmallType type, LumBEARjack.HuhChoice huh, double startUpBeat = -1) { _bear = bear; _type = type; + _huh = huh; switch (type) { @@ -93,8 +95,22 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack }; SoundByte.PlayOneShotGame("lumbearjack/" + cutSound); - if (_type != LumBEARjack.SmallType.log) SoundByte.PlayOneShotGame("lumbearjack/huh", caller.startBeat + caller.timer + 1); - _bear.Cut(caller.startBeat + caller.timer, _type != LumBEARjack.SmallType.log, false); // Add proper logic for direction + // Add proper logic for direction + + switch (_huh) + { + case LumBEARjack.HuhChoice.ObjectSpecific: + if (_type != LumBEARjack.SmallType.log) SoundByte.PlayOneShotGame("lumbearjack/huh", caller.startBeat + caller.timer + 1); + _bear.Cut(caller.startBeat + caller.timer, _type != LumBEARjack.SmallType.log, false); + break; + case LumBEARjack.HuhChoice.On: + SoundByte.PlayOneShotGame("lumbearjack/huh", caller.startBeat + caller.timer + 1); + _bear.Cut(caller.startBeat + caller.timer, true, false); + break; + default: + _bear.Cut(caller.startBeat + caller.timer, false, false); + break; + } Destroy(gameObject); } diff --git a/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs b/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs index 6c2b44a31..f4ac11aa8 100644 --- a/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs +++ b/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs @@ -45,13 +45,14 @@ namespace HeavenStudio.Games.Loaders function = delegate { var e = eventCaller.currentEntity; - LumBEARjack.instance.SpawnSmallObject(e.beat, e.length, (LumBEARjack.SmallType)e["type"]); + LumBEARjack.instance.SpawnSmallObject(e.beat, e.length, (LumBEARjack.SmallType)e["type"], (LumBEARjack.HuhChoice)e["huh"]); }, defaultLength = 3, parameters = new() { new("type", LumBEARjack.SmallType.log, "Type"), - new("sound", true, "Cue Sound") + new("sound", true, "Cue Sound"), + new("huh", LumBEARjack.HuhChoice.ObjectSpecific, "Huh") } }, new("big", "Big Object") @@ -122,13 +123,14 @@ namespace HeavenStudio.Games.Loaders function = delegate { var e = eventCaller.currentEntity; - LumBEARjack.instance.SpawnSmallObject(e.beat, e.length, (LumBEARjack.SmallType)e["type"]); + LumBEARjack.instance.SpawnSmallObject(e.beat, e.length, (LumBEARjack.SmallType)e["type"], (LumBEARjack.HuhChoice)e["huh"]); }, defaultLength = 3, parameters = new() { new("type", LumBEARjack.SmallType.log, "Type"), - new("sound", true, "Cue Sound") + new("sound", true, "Cue Sound"), + new("huh", LumBEARjack.HuhChoice.ObjectSpecific, "Huh") }, resizable = true }, @@ -214,6 +216,13 @@ namespace HeavenStudio.Games None = 3 } + public enum HuhChoice + { + ObjectSpecific, + Off, + On + } + [Header("Components")] [SerializeField] private LBJBear _bear; [SerializeField] private LBJSmallObject _smallObjectPrefab; @@ -254,14 +263,14 @@ namespace HeavenStudio.Games #region Spawn Objects - public void SpawnSmallObject(double beat, double length, SmallType type, double startUpBeat = -1) + public void SpawnSmallObject(double beat, double length, SmallType type, HuhChoice huh, double startUpBeat = -1) { BeatAction.New(this, new() { new(beat + (length / 3), delegate { LBJSmallObject spawnedObject = Instantiate(_smallObjectPrefab, _cutObjectHolder); - spawnedObject.Init(_bear, beat, length, type, startUpBeat); + spawnedObject.Init(_bear, beat, length, type, huh, startUpBeat); }) }); } @@ -321,7 +330,7 @@ namespace HeavenStudio.Games case "small": case "smallS": SmallObjectSound(e.beat, e.length, (SmallType)e["type"], beat); - SpawnSmallObject(e.beat, e.length, (SmallType)e["type"], beat); + SpawnSmallObject(e.beat, e.length, (SmallType)e["type"], (HuhChoice)e["huh"], beat); break; case "big": case "bigS": @@ -350,7 +359,7 @@ namespace HeavenStudio.Games case "small": case "smallS": _bearNoBopBeats.Add(e.beat + (e.length / 3 * 2)); - if ((SmallType)e["type"] != SmallType.log) + if (((SmallType)e["type"] != SmallType.log || (HuhChoice)e["huh"] == HuhChoice.On) && (HuhChoice)e["huh"] != HuhChoice.Off) { _bearNoBopBeats.Add(e.beat + e.length); _bearNoBopBeats.Add(e.beat + e.length + 1); @@ -390,7 +399,18 @@ namespace HeavenStudio.Games foreach (var e in allEvents) { - if (e.beat + _catAnimationOffsetStart < beat || e.beat < nextGameSwitchBeat) + float effectiveLength = e.length / (e.datamodel.Split(1) switch + { + "small" => 3, + "smallS" => 3, + "big" => 4, + "bigS" => 4, + "huge" => 6, + "hugeS" => 6, + _ => 3 + }); + + if ((e.beat + _catAnimationOffsetStart < beat && e.beat + effectiveLength + _catAnimationOffsetEnd > beat) || (e.beat >= beat && e.beat < nextGameSwitchBeat)) { switch (e.datamodel.Split(1)) {