diff --git a/Assets/Scripts/Games/LumBEARjack/LBJBigObject.cs b/Assets/Scripts/Games/LumBEARjack/LBJBigObject.cs index 5ef72e738..8f9bc8390 100644 --- a/Assets/Scripts/Games/LumBEARjack/LBJBigObject.cs +++ b/Assets/Scripts/Games/LumBEARjack/LBJBigObject.cs @@ -11,12 +11,12 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack private LumBEARjack.BigType _type; private PlayerActionEvent _cutActionEvent; - public void Init(LBJBear bear, double beat, double length, LumBEARjack.BigType type) + public void Init(LBJBear bear, double beat, double length, LumBEARjack.BigType type, double startUpBeat = -1) { _bear = bear; _type = type; - LumBEARjack.instance.ScheduleInput(beat, length / 4 * 2, Minigame.InputAction_BasicPress, JustHit, Miss, Blank); + if (startUpBeat <= beat + (length / 4 * 2)) LumBEARjack.instance.ScheduleInput(beat, length / 4 * 2, Minigame.InputAction_BasicPress, JustHit, Miss, Blank); _cutActionEvent = LumBEARjack.instance.ScheduleInput(beat, length / 4 * 3, Minigame.InputAction_BasicPress, JustCut, Miss, Blank); } diff --git a/Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs b/Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs index a9a3594d2..d2e65d92a 100644 --- a/Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs +++ b/Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs @@ -11,14 +11,14 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack private LumBEARjack.HugeType _type; private PlayerActionEvent[] _soundsToDeleteIfMiss = new PlayerActionEvent[3]; - public void Init(LBJBear bear, double beat, double length, LumBEARjack.HugeType type) + public void Init(LBJBear bear, double beat, double length, LumBEARjack.HugeType type, double startUpBeat = -1) { _bear = bear; _type = type; - LumBEARjack.instance.ScheduleInput(beat, length / 6 * 2, Minigame.InputAction_BasicPress, JustHit1, Miss, Blank); - _soundsToDeleteIfMiss[0] = LumBEARjack.instance.ScheduleInput(beat, length / 6 * 3, Minigame.InputAction_BasicPress, JustHit2, Miss, Blank); - _soundsToDeleteIfMiss[1] = LumBEARjack.instance.ScheduleInput(beat, length / 6 * 4, Minigame.InputAction_BasicPress, JustHit3, Miss, Blank); + if (startUpBeat <= beat + (length / 6 * 2)) LumBEARjack.instance.ScheduleInput(beat, length / 6 * 2, Minigame.InputAction_BasicPress, JustHit1, Miss, Blank); + if (startUpBeat <= beat + (length / 6 * 3)) _soundsToDeleteIfMiss[0] = LumBEARjack.instance.ScheduleInput(beat, length / 6 * 3, Minigame.InputAction_BasicPress, JustHit2, Miss, Blank); + if (startUpBeat <= beat + (length / 6 * 4)) _soundsToDeleteIfMiss[1] = LumBEARjack.instance.ScheduleInput(beat, length / 6 * 4, Minigame.InputAction_BasicPress, JustHit3, Miss, Blank); _soundsToDeleteIfMiss[2] = LumBEARjack.instance.ScheduleInput(beat, length / 6 * 5, Minigame.InputAction_BasicPress, JustCut, Miss, Blank); } diff --git a/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs b/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs index 078f44ffe..242ba23c1 100644 --- a/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs +++ b/Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs @@ -10,7 +10,7 @@ namespace HeavenStudio.Games.Scripts_LumBEARjack private LBJBear _bear; private LumBEARjack.SmallType _type; - public void Init(LBJBear bear, double beat, double length, LumBEARjack.SmallType type) + public void Init(LBJBear bear, double beat, double length, LumBEARjack.SmallType type, double startUpBeat = -1) { _bear = bear; _type = type; diff --git a/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs b/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs index 5a45127d4..1e070bf32 100644 --- a/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs +++ b/Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs @@ -25,6 +25,7 @@ namespace HeavenStudio.Games.Loaders preFunction = delegate { var e = eventCaller.currentEntity; + if (!e["sound"]) return; LumBEARjack.SmallObjectSound(e.beat, e.length, (LumBEARjack.SmallType)e["type"]); }, function = delegate @@ -35,7 +36,8 @@ namespace HeavenStudio.Games.Loaders defaultLength = 3, parameters = new() { - new("type", LumBEARjack.SmallType.log, "Type") + new("type", LumBEARjack.SmallType.log, "Type"), + new("sound", true, "Cue Sound") } }, new("big", "Big Object") @@ -43,6 +45,7 @@ namespace HeavenStudio.Games.Loaders preFunction = delegate { var e = eventCaller.currentEntity; + if (!e["sound"]) return; LumBEARjack.BigObjectSound(e.beat, e.length, (LumBEARjack.BigType)e["type"]); }, function = delegate @@ -53,7 +56,8 @@ namespace HeavenStudio.Games.Loaders defaultLength = 4, parameters = new() { - new("type", LumBEARjack.BigType.log, "Type") + new("type", LumBEARjack.BigType.log, "Type"), + new("sound", true, "Cue Sound") } }, new("huge", "Huge Object") @@ -61,6 +65,7 @@ namespace HeavenStudio.Games.Loaders preFunction = delegate { var e = eventCaller.currentEntity; + if (!e["sound"]) return; LumBEARjack.HugeObjectSound(e.beat, e.length, (LumBEARjack.HugeType)e["type"]); }, function = delegate @@ -71,9 +76,83 @@ namespace HeavenStudio.Games.Loaders defaultLength = 6, parameters = new() { - new("type", LumBEARjack.HugeType.log, "Type") + new("type", LumBEARjack.HugeType.log, "Type"), + new("sound", true, "Cue Sound") } - } + }, + new("sigh", "Sigh") + { + preFunction = delegate + { + SoundByte.PlayOneShotGame("lumbearjack/sigh" + (UnityEngine.Random.Range(1, 3) == 1 ? "A" : "B"), eventCaller.currentEntity.beat, 1, 1, false, true); + } + }, + + // Stretchable Objects + + new("smallS", "Small Object (Stretchable)") + { + preFunction = delegate + { + var e = eventCaller.currentEntity; + if (!e["sound"]) return; + LumBEARjack.SmallObjectSound(e.beat, e.length, (LumBEARjack.SmallType)e["type"]); + }, + function = delegate + { + var e = eventCaller.currentEntity; + LumBEARjack.instance.SpawnSmallObject(e.beat, e.length, (LumBEARjack.SmallType)e["type"]); + }, + defaultLength = 3, + parameters = new() + { + new("type", LumBEARjack.SmallType.log, "Type"), + new("sound", true, "Cue Sound") + }, + resizable = true + }, + new("bigS", "Big Object (Stretchable)") + { + preFunction = delegate + { + var e = eventCaller.currentEntity; + if (!e["sound"]) return; + LumBEARjack.BigObjectSound(e.beat, e.length, (LumBEARjack.BigType)e["type"]); + }, + function = delegate + { + var e = eventCaller.currentEntity; + LumBEARjack.instance.SpawnBigObject(e.beat, e.length, (LumBEARjack.BigType)e["type"]); + }, + defaultLength = 4, + parameters = new() + { + new("type", LumBEARjack.BigType.log, "Type"), + new("sound", true, "Cue Sound") + }, + resizable = true + }, + new("hugeS", "Huge Object (Stretchable)") + { + preFunction = delegate + { + var e = eventCaller.currentEntity; + if (!e["sound"]) return; + LumBEARjack.HugeObjectSound(e.beat, e.length, (LumBEARjack.HugeType)e["type"]); + }, + function = delegate + { + var e = eventCaller.currentEntity; + LumBEARjack.instance.SpawnHugeObject(e.beat, e.length, (LumBEARjack.HugeType)e["type"]); + }, + defaultLength = 6, + parameters = new() + { + new("type", LumBEARjack.HugeType.log, "Type"), + new("sound", true, "Cue Sound") + }, + resizable = true + }, } ); } @@ -133,121 +212,158 @@ namespace HeavenStudio.Games #region Spawn Objects - public void SpawnSmallObject(double beat, double length, SmallType type) + public void SpawnSmallObject(double beat, double length, SmallType type, double startUpBeat = -1) { BeatAction.New(this, new() { new(beat + (length / 3), delegate { LBJSmallObject spawnedObject = Instantiate(_smallObjectPrefab, transform); - spawnedObject.Init(_bear, beat, length, type); + spawnedObject.Init(_bear, beat, length, type, startUpBeat); }) }); } - public void SpawnBigObject(double beat, double length, BigType type) + public void SpawnBigObject(double beat, double length, BigType type, double startUpBeat = -1) { BeatAction.New(this, new() { new(beat + (length / 4), delegate { LBJBigObject spawnedObject = Instantiate(_bigObjectPrefab, transform); - spawnedObject.Init(_bear, beat, length, type); + spawnedObject.Init(_bear, beat, length, type, startUpBeat); }) }); } - public void SpawnHugeObject(double beat, double length, HugeType type) + public void SpawnHugeObject(double beat, double length, HugeType type, double startUpBeat = -1) { BeatAction.New(this, new() { new(beat + (length / 6), delegate { LBJHugeObject spawnedObject = Instantiate(_hugeObjectPrefab, transform); - spawnedObject.Init(_bear, beat, length, type); + spawnedObject.Init(_bear, beat, length, type, startUpBeat); }) }); } #endregion + #region StartUp Methods + + public override void OnGameSwitch(double beat) + { + PersistObjects(beat); + } + + public override void OnPlay(double beat) + { + PersistObjects(beat); + } + + private void PersistObjects(double beat) + { + List allEligibleEvents = EventCaller.GetAllInGameManagerList("lumbearjack", new string[] { "small", "big", "huge", "smallS", "bigS", "hugeS" }).FindAll(x => x.beat < beat && x.beat + x.length > beat); + + for (int i = 0; i < allEligibleEvents.Count; i++) + { + var e = allEligibleEvents[i]; + + switch (e.datamodel.Split(1)) + { + case "small": + case "smallS": + SmallObjectSound(e.beat, e.length, (SmallType)e["type"], beat); + SpawnSmallObject(e.beat, e.length, (SmallType)e["type"], beat); + break; + case "big": + case "bigS": + BigObjectSound(e.beat, e.length, (BigType)e["type"], beat); + SpawnBigObject(e.beat, e.length, (BigType)e["type"], beat); + break; + case "huge": + case "hugeS": + HugeObjectSound(e.beat, e.length, (HugeType)e["type"], beat); + SpawnHugeObject(e.beat, e.length, (HugeType)e["type"], beat); + break; + } + } + } + + #endregion + #region PreSounds - public static void SmallObjectSound(double beat, float length, SmallType type) + public static void SmallObjectSound(double beat, float length, SmallType type, double startUpBeat = -1) { - switch (type) + List sounds = new(); + if (beat >= startUpBeat) sounds.Add(new("lumbearjack/readyVoice", beat)); + if (beat + (length / 3) >= startUpBeat) { - case SmallType.bat: - case SmallType.log: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/smallLogPut", beat + (length / 3)) - }, true, true); - break; - case SmallType.can: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/canPut", beat + (length / 3)) - }, true, true); - break; - case SmallType.broom: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/broomPut", beat + (length / 3)) - }, true, true); - break; - default: - break; + switch (type) + { + case SmallType.bat: + case SmallType.log: + sounds.Add(new("lumbearjack/smallLogPut", beat + (length / 3))); + break; + case SmallType.can: + sounds.Add(new("lumbearjack/canPut", beat + (length / 3))); + break; + case SmallType.broom: + sounds.Add(new("lumbearjack/broomPut", beat + (length / 3))); + break; + default: + break; + } } + + if (sounds.Count > 0) MultiSound.Play(sounds.ToArray(), true, true); } - public static void BigObjectSound(double beat, float length, BigType type) + public static void BigObjectSound(double beat, float length, BigType type, double startUpBeat = -1) { - switch (type) + List sounds = new(); + if (beat >= startUpBeat) sounds.Add(new("lumbearjack/readyVoice", beat)); + if (beat + (length / 4) >= startUpBeat) { - case BigType.log: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/bigLogPut", beat + (length / 4)) - }, true, true); - break; - default: - break; + switch (type) + { + case BigType.log: + sounds.Add(new("lumbearjack/bigLogPut", beat + (length / 4))); + break; + default: + break; + } } + + if (sounds.Count > 0) MultiSound.Play(sounds.ToArray(), true, true); } - public static void HugeObjectSound(double beat, float length, HugeType type) + public static void HugeObjectSound(double beat, float length, HugeType type, double startUpBeat = -1) { - switch (type) + List sounds = new(); + + if (beat >= startUpBeat) sounds.Add(new("lumbearjack/readyVoice", beat)); + if (beat + (length / 6) >= startUpBeat) { - case HugeType.log: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/hugeLogPut", beat + (length / 6)) - }, true, true); - break; - case HugeType.freezer: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/freezerPut", beat + (length / 6)) - }, true, true); - break; - case HugeType.peach: - MultiSound.Play(new MultiSound.Sound[] - { - new("lumbearjack/readyVoice", beat), - new("lumbearjack/peachPut", beat + (length / 6)) - }, true, true); - break; - default: - break; + switch (type) + { + case HugeType.log: + sounds.Add(new("lumbearjack/hugeLogPut", beat + (length / 6))); + break; + case HugeType.freezer: + sounds.Add(new("lumbearjack/freezerPut", beat + (length / 6))); + break; + case HugeType.peach: + sounds.Add(new("lumbearjack/peachPut", beat + (length / 6))); + break; + default: + break; + } } + + if (sounds.Count > 0) MultiSound.Play(sounds.ToArray(), true, true); } #endregion diff --git a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset index 0adc10b9e..dc0c65749 100644 --- a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset +++ b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset @@ -18,5 +18,8 @@ MonoBehaviour: _disableAutoReloadInBackground: 0 ImportedScriptPaths: - Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs + - Assets/Scripts/Games/LumBEARjack/LumBEARjack.cs + - Assets/Scripts/Games/LumBEARjack/LBJBigObject.cs + - Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs PathsToSkipImportEvent: [] PathsToIgnoreOverwriteSettingOnAttribute: []