From 40fbc0e5bf0a60bc3bde685755434a9f1ab72698 Mon Sep 17 00:00:00 2001 From: AstrlJelly Date: Mon, 23 Jan 2023 03:09:55 -0500 Subject: [PATCH] doesn't look like much. but I GOT ANIMATIONS WORKING. (god, i suck at C#) * bop animations, on every beat (will soon make it a toggle) * bird fly in and out, flies in when not on screen and out when on screen * did more work on "throwObject.cs" but not anything applicable yet * also found out how assigning scripts to a prefab works. ugh. so, got all those holders and objects assigned --- Assets/Resources/Games/dogNinja.prefab | 33 ++++++++----- .../Dog/{New Animation.anim => Idle.anim} | 2 +- ...New Animation.anim.meta => Idle.anim.meta} | 2 +- Assets/Scripts/Games/DogNinja/DogNinja.cs | 49 ++++++++++--------- Assets/Scripts/Games/DogNinja/ThrowObject.cs | 29 +++++++++-- 5 files changed, 71 insertions(+), 44 deletions(-) rename Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/{New Animation.anim => Idle.anim} (98%) rename Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/{New Animation.anim.meta => Idle.anim.meta} (79%) diff --git a/Assets/Resources/Games/dogNinja.prefab b/Assets/Resources/Games/dogNinja.prefab index 62381c1b4..f571e8e81 100644 --- a/Assets/Resources/Games/dogNinja.prefab +++ b/Assets/Resources/Games/dogNinja.prefab @@ -107,6 +107,8 @@ MonoBehaviour: isEligible: 0 triggersAutoplay: 1 startBeat: 0 + CurveFromLeft: {fileID: 0} + CurveFromRight: {fileID: 0} --- !u!1 &127654075222335198 GameObject: m_ObjectHideFlags: 0 @@ -1243,7 +1245,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1671099869309974123 Transform: m_ObjectHideFlags: 0 @@ -1309,14 +1311,17 @@ MonoBehaviour: EligibleHits: [] scheduledInputs: [] firstEnable: 0 - BirdAnim: {fileID: 0} - ObjectBase: {fileID: 0} + BirdAnim: {fileID: 4964290445827434540} + DogAnim: {fileID: 1770250701376598399} + ObjectLeftBase: {fileID: 5163996841361280296} + ObjectRightBase: {fileID: 119991411479083905} HalvesBase: {fileID: 0} - FullBird: {fileID: 0} - ObjectHolder: {fileID: 0} - HalvesHolder: {fileID: 0} - CurveFromLeft: {fileID: 0} - CurveFromRight: {fileID: 0} + FullBird: {fileID: 3439822116337821266} + Dog: {fileID: 7056643801436531617} + ObjectHolder: {fileID: 1671099869309974123} + HalvesHolder: {fileID: 2078672318315355962} + CurveFromLeft: {fileID: 1761052573981030483} + CurveFromRight: {fileID: 8610298732975356966} --- !u!1 &3439822116337821266 GameObject: m_ObjectHideFlags: 0 @@ -1333,7 +1338,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &6570085815560366024 Transform: m_ObjectHideFlags: 0 @@ -1806,6 +1811,8 @@ MonoBehaviour: isEligible: 0 triggersAutoplay: 1 startBeat: 0 + CurveFromLeft: {fileID: 0} + CurveFromRight: {fileID: 0} --- !u!1 &5340671340987037539 GameObject: m_ObjectHideFlags: 0 @@ -2266,7 +2273,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &824996811837558432 Transform: m_ObjectHideFlags: 0 @@ -2375,7 +2382,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -10 + m_SortingOrder: 10 m_Sprite: {fileID: 21300000, guid: 1b7d68fa62aa6fa49ac07f1dfe3aa7d8, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2656,12 +2663,12 @@ GameObject: - component: {fileID: 7071035726964846845} - component: {fileID: 6326226947728656543} m_Layer: 0 - m_Name: DogTorso (1) + m_Name: DogTorsoBottom m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &7071035726964846845 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim b/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim similarity index 98% rename from Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim rename to Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim index bb5fc5ba2..c89c10035 100644 --- a/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim +++ b/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim @@ -6,7 +6,7 @@ AnimationClip: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: New Animation + m_Name: Idle serializedVersion: 6 m_Legacy: 0 m_Compressed: 0 diff --git a/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim.meta b/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim.meta similarity index 79% rename from Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim.meta rename to Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim.meta index 7025e50d1..1f2b56426 100644 --- a/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/New Animation.anim.meta +++ b/Assets/Resources/Sprites/Games/DogNinja/Animation/Dog/Idle.anim.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6d4c8fbfedaf54844a174638b2ed95d7 +guid: 6c3c68b0289e9c9419fab88c4ef3b969 NativeFormatImporter: externalObjects: {} mainObjectFileID: 7400000 diff --git a/Assets/Scripts/Games/DogNinja/DogNinja.cs b/Assets/Scripts/Games/DogNinja/DogNinja.cs index 52c3924b1..c6712fc50 100644 --- a/Assets/Scripts/Games/DogNinja/DogNinja.cs +++ b/Assets/Scripts/Games/DogNinja/DogNinja.cs @@ -23,7 +23,7 @@ namespace HeavenStudio.Games.Loaders }, new GameAction("ThrowObjectLeft", "Throw Left Object") { - function = delegate { DogNinja.instance.ThrowObjectLeft(eventCaller.currentEntity.beat); }, + function = delegate { DogNinja.instance.ThrowObjectLeft(eventCaller.currentEntity.beat, eventCaller.currentEntity["type"]); }, defaultLength = 2, parameters = new List() { @@ -62,12 +62,14 @@ namespace HeavenStudio.Games { [Header("Animators")] public Animator BirdAnim; // Bird flying in and out - public Animator DogAnim; // Bird flying in and out + public Animator DogAnim; // Dog misc animations [Header("References")] - public GameObject ObjectBase; + public GameObject ObjectLeftBase; + public GameObject ObjectRightBase; public GameObject HalvesBase; public GameObject FullBird; + public GameObject Dog; public Transform ObjectHolder; public Transform HalvesHolder; @@ -75,6 +77,9 @@ namespace HeavenStudio.Games public BezierCurve3D CurveFromLeft; public BezierCurve3D CurveFromRight; + private float lastReportedBeat = 0f; + private bool birdOnScreen = false; + public static DogNinja instance; public enum ObjectType @@ -97,26 +102,16 @@ namespace HeavenStudio.Games private void Update() { - if (Input.GetKeyDown(KeyCode.S)) - { - Debug.Log("BOP! PLEASE"); - DogAnim.Play("bop"); - } - /* - DogAnim.SetBool("ShouldOpenMouth", foodHolder.childCount != 0); - - if (PlayerInput.GetAnyDirectionDown() && !IsExpectingInputNow(InputType.DIRECTION_DOWN)) - { - headAndBodyAnim.Play("BiteL", 0, 0); - } - else if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) - { - headAndBodyAnim.Play("BiteR", 0, 0); - } - if (Conductor.instance.ReportBeat(ref lastReportedBeat)) { - + DogAnim.Play("Bop", 0, 0); + } + + /* + if (Input.GetKeyDown(KeyCode.S)) + { + Debug.Log("bop test -AJ"); + DogAnim.Play("Bop"); } */ } @@ -126,7 +121,7 @@ namespace HeavenStudio.Games DogAnim.Play("Bop"); } - public void ThrowObjectLeft(float beat) + public void ThrowObjectLeft(float beat, int type) { Jukebox.PlayOneShotGame("dogNinja/fruit1"); } @@ -138,8 +133,14 @@ namespace HeavenStudio.Games public void CutEverything(float beat) { - Jukebox.PlayOneShotGame("dogNinja/bird_flap"); - BirdAnim.Play("FlyIn"); + if (!birdOnScreen) { + Jukebox.PlayOneShotGame("dogNinja/bird_flap"); + BirdAnim.Play("FlyIn", 0, 0); + birdOnScreen = true; + } else { + BirdAnim.Play("FlyOut", 0, 0); + birdOnScreen = false; + } } public void HereWeGo(float beat) diff --git a/Assets/Scripts/Games/DogNinja/ThrowObject.cs b/Assets/Scripts/Games/DogNinja/ThrowObject.cs index 5b86a2967..6f3947a88 100644 --- a/Assets/Scripts/Games/DogNinja/ThrowObject.cs +++ b/Assets/Scripts/Games/DogNinja/ThrowObject.cs @@ -15,7 +15,9 @@ namespace HeavenStudio.Games.Scripts_DogNinja bool flying = true; float flyBeats; - [NonSerialized] public BezierCurve3D curve; + [Header("Curves")] + public BezierCurve3D CurveFromLeft; + public BezierCurve3D CurveFromRight; private DogNinja game; @@ -26,7 +28,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja private void Start() { - game.ScheduleInput(startBeat, flyBeats, InputType.STANDARD_DOWN, Just, Out, Out); + game.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN, Just, Out, Miss); } private void Update() @@ -37,7 +39,15 @@ namespace HeavenStudio.Games.Scripts_DogNinja float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats); flyPos *= 0.6f; - transform.position = curve.GetPoint(flyPos); + /* + if (true) + { + transform.position = CurveFromLeft.GetPoint(flyPos); + } else { + transform.position = CurveFromRight.GetPoint(flyPos); + } + */ + if (flyPos > 1f) { @@ -51,7 +61,7 @@ namespace HeavenStudio.Games.Scripts_DogNinja flying = false; //game.headAndBodyAnim.Play("BiteR", 0, 0); - //Jukebox.PlayOneShotGame("blueBear/chompDonut"); + Jukebox.PlayOneShotGame("dogNinja/fruit2"); SpawnHalves(); @@ -66,7 +76,16 @@ namespace HeavenStudio.Games.Scripts_DogNinja CutObject(); } - private void Miss(PlayerActionEvent caller) {} + private void Miss(PlayerActionEvent caller) + { + Jukebox.PlayOneShot("dogNinja/fruit1"); + BeatAction.New(game.gameObject, new List() + { + new BeatAction.Action(startBeat+ 2.45f, delegate { + Destroy(this.gameObject); + }), + }); + } private void Out(PlayerActionEvent caller) {}