From 3108c3148915db60c943f6ba287a20533fc3016f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 3 May 2023 13:16:44 -0700 Subject: [PATCH] added trumpet visual --- Assets/Prefabs/Player.prefab | 67 ++++++++++++++++++++++++++-- Assets/Scripts/DebugSceneSwitcher.cs | 1 + Assets/Scripts/PlayerController.cs | 23 +++++++++- 3 files changed, 86 insertions(+), 5 deletions(-) diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index f7f292d..721d30f 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -10,6 +10,7 @@ GameObject: m_Component: - component: {fileID: 5260309551442468847} - component: {fileID: 4810862233826936571} + - component: {fileID: 6243080859493935262} m_Layer: 2 m_Name: Trumpet m_TagString: Untagged @@ -24,14 +25,14 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2460619873126572304} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -0.227, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalRotation: {x: 0, y: 0, z: -0.38268343, w: 0.92387956} + m_LocalPosition: {x: 0.149, y: -0.138, z: 0} + m_LocalScale: {x: 0.33, y: 0.33, z: 0.33} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 5885597207104481986} m_RootOrder: -1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -45} --- !u!82 &4810862233826936571 AudioSource: m_ObjectHideFlags: 0 @@ -128,6 +129,58 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!212 &6243080859493935262 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2460619873126572304} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 2fc7c6c786dc74f23a25d37c648e9b6d, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 1 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.64, y: 0.64} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &5885597207104481991 GameObject: m_ObjectHideFlags: 0 @@ -365,6 +418,11 @@ MonoBehaviour: playerInput: {fileID: 1407172087} launcher: {fileID: 6559806128767475056} hasTambourine: 1 + maxDashTime: 3 + dashStopSpeed: 0.1 + moveDirection: {x: 0, y: 0, z: 0} + dashDistance: 0.2 + isDash: 0 grapplingGun: {fileID: 3465910379319867675} grapplingRope: {fileID: 7648135587659148198} playerController: {fileID: 5559747613460074786} @@ -388,6 +446,7 @@ MonoBehaviour: trumpet: 0 in_range: 0 enemy: {fileID: 0} + trumpetSprite: {fileID: 6243080859493935262} _groundCheckSize: {x: 0.22, y: 0.62} _groundCheckOffset: 0.29 _wallCheckSize: {x: 0, y: 0} diff --git a/Assets/Scripts/DebugSceneSwitcher.cs b/Assets/Scripts/DebugSceneSwitcher.cs index 579b903..c10511a 100644 --- a/Assets/Scripts/DebugSceneSwitcher.cs +++ b/Assets/Scripts/DebugSceneSwitcher.cs @@ -37,5 +37,6 @@ public class DebugSceneSwitcher : MonoBehaviour public void ChangeScene(int index) { // print(index); GameObject.FindGameObjectWithTag("SceneManager").GetComponent().LoadChosenScene(index); + this.gameObject.SetActive(false); } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 7cb723e..9e65a8c 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -30,9 +30,14 @@ public class PlayerMovement : MonoBehaviour public float LastOnWallRightTime { get; private set; } public float LastOnWallLeftTime { get; private set; } + // trumpet public int trumpet = 0; public bool in_range = false; public GameObject enemy; + bool unlockedTrumpet; + [SerializeField] SpriteRenderer trumpetSprite; + bool trumpetActive = false; + //Jump private bool _isJumpCut; @@ -48,7 +53,6 @@ public class PlayerMovement : MonoBehaviour Tutorial_GrapplingRope grapplingRope; bool wasGrappling = false; - bool unlockedTrumpet; //Set all of these up in the inspector [Header("Checks")] @@ -78,6 +82,7 @@ public class PlayerMovement : MonoBehaviour stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent(); audioSource = GetComponent(); gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent(); + trumpetSprite.enabled = false; } private void Start() @@ -204,8 +209,10 @@ public class PlayerMovement : MonoBehaviour _isJumpFalling = false; Jump(); + // determine if trumpet jump if (!IsGrounded() && in_range && trumpet > 0) { + StartCoroutine(ActivateTrumpetSprite()); gameObject.transform.Find("Trumpet").GetComponent().Play(); enemy.GetComponent().DefeatEnemy(); enemy = null; @@ -217,6 +224,7 @@ public class PlayerMovement : MonoBehaviour } // check if double jump, play sound if (trumpet == 0) { + StartCoroutine(ActivateTrumpetSprite()); gameObject.transform.Find("Trumpet").GetComponent().Play(); } } @@ -537,4 +545,17 @@ public class PlayerMovement : MonoBehaviour Gizmos.DrawWireCube(this.transform.position, _wallCheckSize); } #endregion + + #region ADDITIONAL TRUMPET METHODS + IEnumerator ActivateTrumpetSprite() { + if (!trumpetActive) { + trumpetActive = true; + trumpetSprite.enabled = true; + yield return new WaitForSeconds(.5f); + trumpetSprite.enabled = false; + trumpetActive = false; + } + } + #endregion + }