From 3a84c7c9bdd6e76b4456661be7f19218fd257f25 Mon Sep 17 00:00:00 2001 From: AstrlJelly Date: Sat, 18 Mar 2023 00:40:20 -0400 Subject: [PATCH] Miscellaneous Tweaks + New Scroll Script (#350) * meat grinder prefab + sprite cutting/naming done + icon title :) * Boss Bop, Miss, & Signal Anims can you read * Boss Call Anim self-explanatory * fix the z axis + new sprite still working on getting those bops working. they're a bit weird (not the anim itself) * Restored Meat Grinder Animations i have no idea what just happened with github but the animations are back * All Tack Animations Complete just missing the meat anims * Literally two lines changed skull emoji (forgot to set the light meat for the miss anim to inactive by default) * Meat Grinder Anims (should be) Done Added the Meat Hit anims * goodnight * bopping every beat * tons of sfx * meat calls with their corresponding sfx/animations have been added * prefunctions... * inputs + sfx + prefunction making swift progress here :) * little commit more cues and animation stuff so that i can have new animations * Meat Toss Anims also fixed up some of tack's hit anims to make the smear more consistent * night night * moved all the meat stuff to a new script -this should help with instantiating the meat * animations are a bit more comprehensive * man, barelies are way easier than i thought they were gonna be * instantiating works now committing to work on my pc instead of my laptop but i have been getting a lot done with the meat! it's just that most of that stuff is learning what i can't do... * Boss Animation Tweaks Adjusted Boss' bop and miss animations * woohoo animation! hi sean this is for u. tell me anything to tweak :) * Quick Meat Toss Anim Fix Prevents meat from playing the toss animation twice * meat hit animation works! sometimes there's a frame where the first frame of its animation pops up but i should be able to fix that also just general improvements + framework for different meats * it's done! or at least out of wip! * you can select which meat type is tossed (defaults to random) * ghost meat has been busted (it looped back to its first frame of anim sometimes right before being destroyed; i just added a single frame idle.) * overall just optimized code * removed WIP from game name * a few touch-ups * change all sfx to ogg -also amplified toss.ogg by 4db, was hard to hear at the same time as hitting a cue * fixed boss not bopping a beat after a signal -a very small bit hacky but it really works fine. will fix if any problems come up (but i added a check so that there shouldn't be) * i have stashed changes :P * new bg + remove references title * boss weird bopping fixed + game switches fixed * final touch-ups * random things just broke * for whatever reason animation controller for boss got reverted, breaking an animation * and we forgot to merge two spritesheets instead of just replacing one with the other. oops * sfx volume lowerd * ok cool commit time * added superscroll (MADE BY STARPELLY) * fixed dog ninja backwards compatibility * fixed meat grinder's startinterval need * added d pad controls to dog ninja and meat grinder * oops forgot to add dpad for dog ninja * remove d-pad from meat grinder :cry: --------- Co-authored-by: Seanski2 --- Assets/Resources/Games/dogNinja.prefab | 10 +-- Assets/Scripts/Common/SuperScroll.cs | 66 +++++++++++++++++ Assets/Scripts/Common/SuperScroll.cs.meta | 11 +++ Assets/Scripts/Games/CatchyTune/CatchyTune.cs | 2 +- Assets/Scripts/Games/DogNinja/DogNinja.cs | 10 +-- Assets/Scripts/Games/DogNinja/SpawnHalves.cs | 4 +- Assets/Scripts/Games/DogNinja/ThrowObject.cs | 2 +- .../Scripts/Games/MeatGrinder/MeatGrinder.cs | 70 ++++++++++--------- 8 files changed, 128 insertions(+), 47 deletions(-) create mode 100644 Assets/Scripts/Common/SuperScroll.cs create mode 100644 Assets/Scripts/Common/SuperScroll.cs.meta diff --git a/Assets/Resources/Games/dogNinja.prefab b/Assets/Resources/Games/dogNinja.prefab index 8af53c63..caa36ae7 100644 --- a/Assets/Resources/Games/dogNinja.prefab +++ b/Assets/Resources/Games/dogNinja.prefab @@ -509,7 +509,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 180 + m_SortingOrder: -12 m_Sprite: {fileID: -1966485124414453226, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1312,7 +1312,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2488711815545919274} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 13.030002, y: -0.67999995, z: 0} + m_LocalPosition: {x: 13.030002, y: -0.94, z: 0} m_LocalScale: {x: 1, y: 1, z: 0} m_Children: - {fileID: 2559293408959807264} @@ -1960,7 +1960,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 3645160475886178620} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 11.33, y: -1.42, z: 0} + m_LocalPosition: {x: 11.33, y: -1.6800001, z: 0} m_LocalScale: {x: 1, y: 1, z: 0} m_Children: - {fileID: 5591757540497211147} @@ -2673,7 +2673,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5441481875736147362} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 2.04, y: -0.67999995, z: 0} + m_LocalPosition: {x: 2.04, y: -0.94, z: 0} m_LocalScale: {x: 1, y: 1, z: 0} m_Children: - {fileID: 2024227379699074830} @@ -3364,7 +3364,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7029759971272808179} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.33999994, y: -1.42, z: 0} + m_LocalPosition: {x: 0.33999994, y: -1.6800001, z: 0} m_LocalScale: {x: 1, y: 1, z: 0} m_Children: - {fileID: 3764752037029567640} diff --git a/Assets/Scripts/Common/SuperScroll.cs b/Assets/Scripts/Common/SuperScroll.cs new file mode 100644 index 00000000..44037b9b --- /dev/null +++ b/Assets/Scripts/Common/SuperScroll.cs @@ -0,0 +1,66 @@ +using UnityEngine; + +namespace HeavenStudio.Common +{ + public class SuperScroll : MonoBehaviour + { + #region Private + + [SerializeField] + private Renderer _renderer; + + [SerializeField] + private Sprite _sprite; + + #endregion + + #region Public + + public float NormalizedX = 0.0f; + public float NormalizedY = 0.0f; + public Vector2 Normalized { get { return new Vector2(NormalizedX, NormalizedY); } set { NormalizedX = value.x; NormalizedY = value.y; } } + + public float TileX = 1.0f; + public float TileY = 1.0f; + public Vector2 Tile { get { return new Vector2(TileX, TileY); } set { TileX = value.x; TileY = value.y; } } + + public Material Material => _renderer.material; + + #endregion + + #region MonoBehaviour + + private void Start() + { + _renderer.material = new Material(Shader.Find("Unlit/Transparent")); + + var spriteRect = _sprite.rect; + var tex = CropTexture(_sprite.texture, new Rect(spriteRect.x, spriteRect.y, spriteRect.width, spriteRect .height)); + tex.wrapMode = TextureWrapMode.Repeat; + Material.mainTexture = tex; + } + + public void LateUpdate() + { + _renderer.material.mainTextureScale = Tile; + _renderer.material.mainTextureOffset = new Vector2(NormalizedX, -NormalizedY) * Tile; + } + + #endregion + + #region Custom + + private Texture2D CropTexture(Texture2D original, Rect rect) + { + var colors = original.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); + var newTex = new Texture2D((int)rect.width - (int)rect.x, (int)rect.height - (int)rect.y); + + newTex.SetPixels(colors); + newTex.Apply(); + + return newTex; + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/SuperScroll.cs.meta b/Assets/Scripts/Common/SuperScroll.cs.meta new file mode 100644 index 00000000..6e7f9dbf --- /dev/null +++ b/Assets/Scripts/Common/SuperScroll.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0479575deb5a235418550268de76edaa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/CatchyTune/CatchyTune.cs b/Assets/Scripts/Games/CatchyTune/CatchyTune.cs index d85650b0..9adfff50 100644 --- a/Assets/Scripts/Games/CatchyTune/CatchyTune.cs +++ b/Assets/Scripts/Games/CatchyTune/CatchyTune.cs @@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Loaders // minigame menu items public static Minigame AddGame(EventCaller eventCaller) { - return new Minigame("catchyTune", "Catchy Tune", "00b3ff", false, false, new List() + return new Minigame("catchyTune", "Catchy Tune", "f2f2f2", false, false, new List() { new GameAction("orange", "Orange") { diff --git a/Assets/Scripts/Games/DogNinja/DogNinja.cs b/Assets/Scripts/Games/DogNinja/DogNinja.cs index c6c057f6..89a760bc 100644 --- a/Assets/Scripts/Games/DogNinja/DogNinja.cs +++ b/Assets/Scripts/Games/DogNinja/DogNinja.cs @@ -78,7 +78,7 @@ namespace HeavenStudio.Games.Loaders }, new GameAction("ThrowObjectBoth", "Throw Object Both") { - function = delegate { var e = eventCaller.currentEntity; DogNinja.instance.ThrowBothObject(e.beat, e["typeL"], e["typeR"]); }, + function = delegate { var e = eventCaller.currentEntity; DogNinja.instance.ThrowObject(e.beat, 2, e["typeL"], e["typeR"]); }, defaultLength = 2, hidden = true, parameters = new List() @@ -186,7 +186,7 @@ namespace HeavenStudio.Games DogAnim.SetBool("needPrepare", true); } - if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) + if (PlayerInput.Pressed(true) && !IsExpectingInputNow(InputType.STANDARD_DOWN)) { System.Random rd = new System.Random(); string slice; @@ -224,7 +224,7 @@ namespace HeavenStudio.Games || ((typeL == 0 || typeR == 0) && direction == 2)) { // random object code. it makes a random number from 1-6 and sets that as the sprite System.Random rd = new System.Random(); - ObjSprite = rd.Next(1, 6); + ObjSprite = rd.Next(1, 7); WhichObject.sprite = ObjectTypes[ObjSprite]; typeL = ObjSprite; typeR = ObjSprite; @@ -257,8 +257,8 @@ namespace HeavenStudio.Games // only here for backwards compatibility public void ThrowBothObject(float beat, int ObjType1, int ObjType2) { - ThrowObject(beat, 0, ObjType1, 0); - ThrowObject(beat, 1, 0, ObjType2); + ThrowObject(beat, 2, ObjType1, ObjType2); + //ThrowObject(beat, 1, 0, ObjType2); } public void CutEverything(float beat, bool sound, string customText) diff --git a/Assets/Scripts/Games/DogNinja/SpawnHalves.cs b/Assets/Scripts/Games/DogNinja/SpawnHalves.cs index 7131afc8..8f8178d4 100644 --- a/Assets/Scripts/Games/DogNinja/SpawnHalves.cs +++ b/Assets/Scripts/Games/DogNinja/SpawnHalves.cs @@ -41,8 +41,8 @@ namespace HeavenStudio.Games.Scripts_DogNinja private void Update() { - float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f)*(Conductor.instance.GetPositionFromBeat(songPos, 3f)))+Conductor.instance.GetPositionFromBeat(songPos, 1f); - flyPosHalves = (flyPosHalves*0.2f)+0.34f; + float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f)*(Conductor.instance.GetPositionFromBeat(songPos, 2f)))+Conductor.instance.GetPositionFromBeat(songPos, 1f); + flyPosHalves = (flyPosHalves*0.2f)+0.35f; transform.position = curve.GetPoint(flyPosHalves)+objPos; float rot = rotSpeed; diff --git a/Assets/Scripts/Games/DogNinja/ThrowObject.cs b/Assets/Scripts/Games/DogNinja/ThrowObject.cs index ea860023..e1b13b33 100644 --- a/Assets/Scripts/Games/DogNinja/ThrowObject.cs +++ b/Assets/Scripts/Games/DogNinja/ThrowObject.cs @@ -52,7 +52,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja if (direction == 2 && fromLeft) {} else { Jukebox.PlayOneShotGame(sfxNum+"1"); } - game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN, Hit, Miss, Out); + game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, Hit, Miss, Out); DogAnim.SetBool("needPrepare", true); } diff --git a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs index c2bef46c..24b4595f 100644 --- a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs +++ b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs @@ -30,6 +30,11 @@ namespace HeavenStudio.Games.Loaders }, defaultLength = 0.5f, priority = 2, + preFunctionLength = 1f, + preFunction = delegate { + var e = eventCaller.currentEntity; + MeatGrinder.PreMeatCall(e.beat); + }, }, new GameAction("StartInterval", "Start Interval") { @@ -40,6 +45,7 @@ namespace HeavenStudio.Games.Loaders defaultLength = 4f, resizable = true, priority = 1, + preFunctionLength = 2f, preFunction = delegate { var e = eventCaller.currentEntity; MeatGrinder.PreInterval(e.beat, e.length); @@ -69,11 +75,7 @@ namespace HeavenStudio.Games using Scripts_MeatGrinder; public class MeatGrinder : Minigame { - static List queuedInputs = new List(); - struct QueuedMeatInput - { - public float beatAwayFromStart; - } + static List queuedInputs = new List(); [Header("Objects")] public GameObject MeatBase; @@ -87,6 +89,7 @@ namespace HeavenStudio.Games float intervalStartBeat; float beatInterval = 4f; bool bossBop = true; + bool dontCall = false; public bool bossAnnoyed = false; private float lastReportedBeat = 0f; const string sfxName = "meatGrinder/"; @@ -106,24 +109,22 @@ namespace HeavenStudio.Games void OnDestroy() { - if (!Conductor.instance.isPlaying || Conductor.instance.isPaused) - { + if (!Conductor.instance.isPlaying || Conductor.instance.isPaused) { if (queuedInputs.Count > 0) queuedInputs.Clear(); } } private void Update() { - if (!Conductor.instance.isPlaying || Conductor.instance.isPaused) - { + if (!Conductor.instance.isPlaying || Conductor.instance.isPaused) { if (queuedInputs.Count > 0) queuedInputs.Clear(); } - if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted) - { + + if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted) { intervalStarted = false; } - if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) - { + + if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) { ScoreMiss(); TackAnim.DoScaledAnimationAsync("TackEmptyHit", 0.5f); TackAnim.SetBool("tackMeated", false); @@ -168,32 +169,28 @@ namespace HeavenStudio.Games public static void PreInterval(float beat, float interval) { + if (!MeatGrinder.instance.intervalStarted && !MeatGrinder.instance.dontCall) { + MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound(sfxName+"startSignal", beat - 1f), }, forcePlay: true); + + BeatAction.New(instance.gameObject, new List() { + new BeatAction.Action(beat - 1, delegate { instance.BossAnim.DoScaledAnimationAsync("BossSignal", 0.5f); }), }); + } + + MeatGrinder.instance.dontCall = true; MeatGrinder.instance.beatInterval = interval; - - BeatAction.New(instance.gameObject, new List() - { - new BeatAction.Action(beat - 1, delegate { instance.BossAnim.DoScaledAnimationAsync("BossSignal", 0.5f); }), - }); - - MultiSound.Play(new MultiSound.Sound[] { - new MultiSound.Sound(sfxName+"startSignal", beat - 1f), - }, forcePlay: true); } public void StartInterval(float beat, float interval) { intervalStartBeat = beat; - if (!intervalStarted) - { - intervalStarted = true; - } + if (!intervalStarted) { intervalStarted = true; } BeatAction.New(gameObject, new List() { new BeatAction.Action(beat + interval - 1, delegate { PassTurn(beat); }), }); } - + public void MeatToss(float beat) { Jukebox.PlayOneShotGame(sfxName+"toss"); @@ -205,6 +202,15 @@ namespace HeavenStudio.Games Meat.meatType = "DarkMeat"; } + public static void PreMeatCall(float beat) + { + if (!MeatGrinder.instance.dontCall) { + BeatAction.New(instance.gameObject, new List() { + new BeatAction.Action(beat - 1, delegate { MeatGrinder.PreInterval(beat, instance.beatInterval); }), + }); + } + } + public void MeatCall(float beat) { BossAnim.DoScaledAnimationAsync("BossCall", 0.5f); @@ -215,23 +221,21 @@ namespace HeavenStudio.Games StartInterval(beat, beatInterval); } - queuedInputs.Add(new QueuedMeatInput() - { - beatAwayFromStart = beat - intervalStartBeat, - }); + queuedInputs.Add(beat - intervalStartBeat); } public void PassTurn(float beat) { + dontCall = false; intervalStarted = false; foreach (var input in queuedInputs) { BeatAction.New(instance.gameObject, new List() { - new BeatAction.Action(input.beatAwayFromStart + beat, delegate { + new BeatAction.Action(input + beat, delegate { MeatToss Meat = Instantiate(MeatBase).GetComponent(); Meat.startBeat = beat; - Meat.cueLength = beatInterval + input.beatAwayFromStart; + Meat.cueLength = beatInterval + input; Meat.cueBased = false; Meat.meatType = "LightMeat"; }),