diff --git a/Assets/Resources/Games/dogNinja.prefab b/Assets/Resources/Games/dogNinja.prefab index 9774004dc..cb32b6388 100644 --- a/Assets/Resources/Games/dogNinja.prefab +++ b/Assets/Resources/Games/dogNinja.prefab @@ -109,9 +109,8 @@ MonoBehaviour: RightCurve: {fileID: 8538313959133990924} BarelyLeftCurve: {fileID: 5959598018215963193} BarelyRightCurve: {fileID: 4156529297438955755} - HalvesLeftBase: {fileID: 8462363345267808632} - HalvesRightBase: {fileID: 997672822965154321} - ObjectParent: {fileID: 0} + HalvesLeftBase: {fileID: 3507681361263350449} + HalvesRightBase: {fileID: 5646879835731180444} objectLeftHalves: - {fileID: -5050977528292827191, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} - {fileID: -6734710479057769413, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} @@ -541,7 +540,7 @@ MonoBehaviour: rotSpeed: 140 fallLeftCurve: {fileID: 7764367815067799206} fallRightCurve: {fileID: 7122240029612248645} - halvesParent: {fileID: 2078672318315355962} + sr: {fileID: 7206843505938361017} --- !u!1 &1203023033644261752 GameObject: m_ObjectHideFlags: 0 @@ -1730,13 +1729,8 @@ MonoBehaviour: DogAnim: {fileID: 1770250701376598399} BirdAnim: {fileID: 4964290445827434540} ObjectBase: {fileID: 4494871422713187218} - FullBird: {fileID: 3439822116337821266} WhichObject: {fileID: 1780506401517458247} - WhichLeftHalf: {fileID: 8550182553065708291} - WhichRightHalf: {fileID: 7206843505938361017} - cutEverythingText: {fileID: 8405214087581042494} - CurveFromLeft: {fileID: 2592536718110886033} - CurveFromRight: {fileID: 8538313959133990924} + CutEverythingText: {fileID: 8405214087581042494} ObjectTypes: - {fileID: 0} - {fileID: -2307065246004786754, guid: 1c59b9cd0adef0941bc4bd4bde66a759, type: 3} @@ -4202,7 +4196,7 @@ MonoBehaviour: rotSpeed: -140 fallLeftCurve: {fileID: 7191847337805905266} fallRightCurve: {fileID: 5028931464679965393} - halvesParent: {fileID: 2078672318315355962} + sr: {fileID: 8550182553065708291} --- !u!1 &8691542995859896262 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/DogNinja/DogNinja.cs b/Assets/Scripts/Games/DogNinja/DogNinja.cs index bbdaa4fa9..9267acbd5 100644 --- a/Assets/Scripts/Games/DogNinja/DogNinja.cs +++ b/Assets/Scripts/Games/DogNinja/DogNinja.cs @@ -18,16 +18,15 @@ namespace HeavenStudio.Games.Loaders { if (datamodel == "dogNinja/ThrowObject" && e.version == 0) { - Debug.Log("entity at beat " + e.beat + " is the same? " + (e["typeL"] == e["typeR"])); - bool diff = e["typeL"] == e["typeR"]; - Debug.Log("entity at beat " + e.beat + " is the same? " + (e["typeL"] == e["typeR"])); - e.CreateProperty("type", diff ? e["typeL"] : DogNinja.ObjectType.Random); + e["diffObjs"] = e["direction"] == 2 && e["typeL"] != e["typeR"]; + e["type"] = e["direction"] is 0 or 2 ? (int)e["typeL"] : e["typeR"]; e.version = 1; return e; } return null; } + // // Beatmap.Entities isn't available in a riqentity updater... // RiqEntity BirdUpdater(string datamodel, RiqEntity e) // { // if (datamodel == "dogNinja/CutEverything" && e.version == 0) @@ -143,15 +142,8 @@ namespace HeavenStudio.Games [Header("References")] [SerializeField] ThrowObject ObjectBase; - [SerializeField] GameObject FullBird; [SerializeField] SpriteRenderer WhichObject; - public SpriteRenderer WhichLeftHalf; - public SpriteRenderer WhichRightHalf; - [SerializeField] TMP_Text cutEverythingText; - - [Header("Curves")] - [SerializeField] BezierCurve3D CurveFromLeft; - [SerializeField] BezierCurve3D CurveFromRight; + [SerializeField] TMP_Text CutEverythingText; [SerializeField] Sprite[] ObjectTypes; @@ -228,22 +220,21 @@ namespace HeavenStudio.Games public override void OnGameSwitch(double beat) { - foreach (var e in gameManager.Beatmap.Entities.FindAll(e => e.datamodel is "dogNinja/ThrowObject" && beat > e.beat - 2 && beat < e.beat + 1)) + foreach (var e in gameManager.Beatmap.Entities.FindAll(e => e.datamodel is "dogNinja/ThrowObject" && beat >= e.beat - 2 && beat < e.beat + 1)) { - // if (!e.dynamicData.ContainsKey("throwData")) { - // QueueObject(e.beat, e["direction"], e["diffObjs"], e["type"], e["typeL"], e["typeR"], e["shouldPrepare"], true, e); - // } QueuedThrow t = e["throwData"]; - DogAnim.Play("Prepare", 0, 1); - preparing = true; - ThrowObject(e.beat, e["direction"], t.types, t.sfxNumL, t.sfxNumR); + if (beat > e.beat) { + DogAnim.Play("Prepare", 0, 1); + preparing = true; + } + ThrowObject(e.beat, e["direction"], ((beat <= e.beat) && e["shouldPrepare"]), t.types, t.sfxNumL, t.sfxNumR); } } private void Update() { // prepare queuing stuff - if (queuePrepare && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop"))) + if (queuePrepare && !preparing && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop"))) { DogAnim.DoScaledAnimationAsync("Prepare", 0.5f); preparing = true; @@ -253,8 +244,9 @@ namespace HeavenStudio.Games // controls stuff if (PlayerInput.GetIsAction(InputAction_TouchPress) && !GameManager.instance.autoplay) { - queuePrepare = true; + // queuePrepare = true; DogAnim.DoScaledAnimationAsync("Prepare", 0.5f); + preparing = true; } if (PlayerInput.GetIsAction(InputAction_TouchRelease) && (!IsExpectingInputNow(InputAction_Press)) && (!GameManager.instance.autoplay)) { @@ -268,20 +260,10 @@ namespace HeavenStudio.Games DogAnim.DoScaledAnimationAsync(slice, 0.5f); SoundByte.PlayOneShotGame("dogNinja/whiff"); - queuePrepare = false; + StopPrepare(); } } - private void LateUpdate() - { - // // prepare queuing stuff - // if (queuePrepare && (DogAnim.IsAnimationNotPlaying() || DogAnim.IsPlayingAnimationNames("Bop", "Idle"))) - // { - // DogAnim.DoScaledAnimationAsync("Prepare", 0.5f); - // queuePrepare = false; - // } - } - public void Bop(double beat, float length, bool auto, bool bop) { autoBop = auto; @@ -313,14 +295,9 @@ namespace HeavenStudio.Games } } - if (GameManager.instance.minigameObj.TryGetComponent(out DogNinja instance)) { - instance.ThrowObject(beat, direction, types, sfxNums[0], sfxNums[1]); + if (GameManager.instance.minigame is DogNinja instance) { + instance.ThrowObject(beat, direction, prepare, types, sfxNums[0], sfxNums[1]); - if (prepare) { - BeatAction.New(instance, new() { - new(beat, () => instance.queuePrepare = PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch || GameManager.instance.autoplay) - }); - } } else { var queuedThrow = new QueuedThrow() { types = types, @@ -334,8 +311,13 @@ namespace HeavenStudio.Games } } - public void ThrowObject(double beat, int direction, int[] types, string sfxNumL, string sfxNumR) + public void ThrowObject(double beat, int direction, bool prepare, int[] types, string sfxNumL, string sfxNumR) { + if (prepare) { + BeatAction.New(this, new() { + new(beat, () => queuePrepare = PlayerInput.CurrentControlStyle != InputController.ControlStyles.Touch || GameManager.instance.autoplay) + }); + } for (int i = 0; i < (direction == 2 ? 2 : 1); i++) { bool l = direction is 2 ? i == 0 : direction == 0; @@ -344,7 +326,7 @@ namespace HeavenStudio.Games obj.startBeat = beat; obj.direction = direction; obj.fromLeft = l; - obj.type = types[i]; + obj.type = l ? types[0] : types[1]; obj.sfxNum = l ? sfxNumL : sfxNumR; if (direction == 2) obj.shouldSfx = l == (types[0] == types[1]); } @@ -354,7 +336,7 @@ namespace HeavenStudio.Games { if (sound) SoundByte.PlayOneShotGame("dogNinja/bird_flap"); BirdAnim.DoScaledAnimationAsync("FlyIn", 0.5f); - cutEverythingText.text = customText; + CutEverythingText.text = customText; BeatAction.New(this, new() { new(beat + length, () => BirdAnim.Play("FlyOut", 0, 0)) diff --git a/Assets/Scripts/Games/DogNinja/SpawnHalves.cs b/Assets/Scripts/Games/DogNinja/SpawnHalves.cs index b2ef7aba7..094086e9b 100644 --- a/Assets/Scripts/Games/DogNinja/SpawnHalves.cs +++ b/Assets/Scripts/Games/DogNinja/SpawnHalves.cs @@ -7,11 +7,11 @@ using NaughtyBezierCurves; namespace HeavenStudio.Games.Scripts_DogNinja { + // this code sucks but i don't wanna touch it. it works fine enough. sorry! public class SpawnHalves : MonoBehaviour { public double startBeat; public Vector3 objPos; - private Vector3 posModifier; public bool lefty; float bpmModifier; double songPos; @@ -22,24 +22,18 @@ namespace HeavenStudio.Games.Scripts_DogNinja [SerializeField] BezierCurve3D fallLeftCurve; [SerializeField] BezierCurve3D fallRightCurve; BezierCurve3D curve; - [SerializeField] Transform halvesParent; - - - private void Awake() - { - bpmModifier = Conductor.instance.songBpm / 100; - songPos = Conductor.instance.songPositionInBeatsAsDouble; - } + public SpriteRenderer sr; private void Start() { + bpmModifier = Conductor.instance.songBpm / 100; + songPos = Conductor.instance.songPositionInBeatsAsDouble; curve = lefty ? fallRightCurve : fallLeftCurve; } private void Update() { - // holy shit - float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f)*(Conductor.instance.GetPositionFromBeat(songPos, 2f)))+Conductor.instance.GetPositionFromBeat(songPos, 1f); + 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; @@ -50,12 +44,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja // clean-up logic if (flyPosHalves > 1f) { Destroy(gameObject); - }; - - if ((!Conductor.instance.isPlaying && !Conductor.instance.isPaused) - || GameManager.instance.currentGame != "dogNinja") { - Destroy(gameObject); - }; + } } } } diff --git a/Assets/Scripts/Games/DogNinja/ThrowObject.cs b/Assets/Scripts/Games/DogNinja/ThrowObject.cs index f3722bae9..81856af4d 100644 --- a/Assets/Scripts/Games/DogNinja/ThrowObject.cs +++ b/Assets/Scripts/Games/DogNinja/ThrowObject.cs @@ -33,9 +33,8 @@ namespace HeavenStudio.Games.Scripts_DogNinja private BezierCurve3D barelyCurve; [SerializeField] BezierCurve3D BarelyLeftCurve; [SerializeField] BezierCurve3D BarelyRightCurve; - [SerializeField] GameObject HalvesLeftBase; - [SerializeField] GameObject HalvesRightBase; - [SerializeField] Transform ObjectParent; + [SerializeField] SpawnHalves HalvesLeftBase; + [SerializeField] SpawnHalves HalvesRightBase; public Sprite[] objectLeftHalves; public Sprite[] objectRightHalves; @@ -50,9 +49,8 @@ namespace HeavenStudio.Games.Scripts_DogNinja private void Update() { - float flyPos = game.conductor.GetPositionFromBeat(startBeat, 1f)+1.1f; - float flyPosBarely = game.conductor.GetPositionFromBeat(barelyTime, 1f)+1f; if (isActive) { + float flyPos = game.conductor.GetPositionFromBeat(startBeat, 1f)+1.1f; flyPos *= 0.31f; transform.position = curve.GetPoint(flyPos); objPos = curve.GetPoint(flyPos); @@ -61,6 +59,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja Destroy(gameObject); } } else { + float flyPosBarely = game.conductor.GetPositionFromBeat(barelyTime, 1f)+1f; flyPosBarely *= 0.3f; transform.position = barelyCurve.GetPoint(flyPosBarely) + objPos; float rot = fromLeft ? 200f : -200f; @@ -69,11 +68,6 @@ namespace HeavenStudio.Games.Scripts_DogNinja Destroy(gameObject); } } - - if ((!game.conductor.isPlaying && !game.conductor.isPaused) - || game.gameManager.currentGame != "dogNinja") { - Destroy(gameObject); - } } private void Hit(PlayerActionEvent caller, float state) @@ -89,16 +83,16 @@ namespace HeavenStudio.Games.Scripts_DogNinja barelyTime = game.conductor.songPositionInBeatsAsDouble; DogAnim.DoScaledAnimationAsync("Barely" + dir, 0.5f); - SoundByte.PlayOneShotGame("dogNinja/barely"); + if (shouldSfx) SoundByte.PlayOneShotGame("dogNinja/barely"); } else { DogAnim.DoScaledAnimationAsync("Slice" + dir, 0.5f); if (shouldSfx) SoundByte.PlayOneShotGame(sfxNum + "2"); Debug.Log("type - 1 : " + (type - 1)); - game.WhichLeftHalf.sprite = objectLeftHalves[type - 1]; - game.WhichRightHalf.sprite = objectRightHalves[type - 1]; + HalvesLeftBase.sr.sprite = objectLeftHalves[type - 1]; + HalvesRightBase.sr.sprite = objectRightHalves[type - 1]; for (int i = 0; i < 2; i++) { - SpawnHalves half = Instantiate(i == 0 ? HalvesLeftBase : HalvesRightBase, game.transform).GetComponent(); + SpawnHalves half = Instantiate(i == 0 ? HalvesLeftBase : HalvesRightBase, game.transform); half.startBeat = startBeat; half.lefty = fromLeft; half.objPos = objPos; @@ -110,7 +104,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja private void Miss(PlayerActionEvent caller) { - if (!game.queuePrepare) return; + if (!game.preparing) return; DogAnim.DoScaledAnimationAsync("Unprepare", 0.5f); game.StopPrepare(); }