diff --git a/Assets/Scenes/GrappleScene.unity b/Assets/Scenes/GrappleScene.unity index 10b55fd..6009c83 100644 --- a/Assets/Scenes/GrappleScene.unity +++ b/Assets/Scenes/GrappleScene.unity @@ -3012,6 +3012,18 @@ PrefabInstance: propertyPath: m_Name value: GrappleBox (1) objectReference: {fileID: 0} + - target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3} + propertyPath: m_Radius + value: 1.85 + objectReference: {fileID: 0} + - target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3} + propertyPath: m_Offset.x + value: 0.33 + objectReference: {fileID: 0} + - target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3} + propertyPath: m_Offset.y + value: -9.03 + objectReference: {fileID: 0} - target: {fileID: 8452658923215583967, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3} propertyPath: m_RootOrder value: -1 diff --git a/Assets/Scripts/GameUIController.cs b/Assets/Scripts/GameUIController.cs index 8ef486d..442d892 100644 --- a/Assets/Scripts/GameUIController.cs +++ b/Assets/Scripts/GameUIController.cs @@ -55,4 +55,16 @@ public class GameUIController : MonoBehaviour clarinetUI.GetComponent().enabled = toggleState; } } + + public void ResetInstrumentUI() { + if (stateController.unlockedTrumpet) { + ToggleTrumpet(true); + } + if (stateController.unlockedTambourine) { + ToggleTambourine(true); + } + if (stateController.unlockedClarinet) { + ToggleClarinet(true); + } + } } diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index b22d51b..ab5f2f4 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -41,7 +41,9 @@ public class PlayerBehavior : MonoBehaviour { // initialize _rb = GetComponent(); stateController = GameObject.Find("StateController").GetComponent(); + gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent(); + gameUI.ResetInstrumentUI(); audioSource = this.gameObject.GetComponent(); audioSource.clip = footstepSound; @@ -235,8 +237,8 @@ public class PlayerBehavior : MonoBehaviour // destroy all tambourines GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine"); foreach (GameObject tambourine in currentTambourines) { - // tambourine.GetComponent().DestroySelf(); - Destroy(tambourine); + tambourine.GetComponent().DestroySelf(); + // Destroy(tambourine); } this.stateController.RespawnPlayer(); diff --git a/Assets/Scripts/TambourineBehavior.cs b/Assets/Scripts/TambourineBehavior.cs index 532817b..c1bb8fd 100644 --- a/Assets/Scripts/TambourineBehavior.cs +++ b/Assets/Scripts/TambourineBehavior.cs @@ -38,28 +38,32 @@ public class TambourineBehavior : MonoBehaviour { // if (Input.GetKeyUp(KeyCode.K)) { // Destroy(this.gameObject); // } - if (collidedObject != null && collidedObject.tag != "grappleSurface" && !returnToPlayer) { - rb.constraints = RigidbodyConstraints2D.FreezeAll; - // this.gameObject.transform.position = col.transform.position; - timeLerped += Time.deltaTime; - this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, collidedObject.transform.position, timeLerped/timeToLerp); - if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !pinned) { - animator.SetBool("pinned", true); - pinned = true; - tambourineHitSound.Play(); - } else { - // print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position); - } - } else if (returnToPlayer) { - Destroy(rb); - animator.SetBool("pinned", false); - pinned = false; + if (player == null) { + DestroySelf(); + } else { + if (collidedObject != null && collidedObject.tag != "grappleSurface" && !returnToPlayer) { + rb.constraints = RigidbodyConstraints2D.FreezeAll; + // this.gameObject.transform.position = col.transform.position; + timeLerped += Time.deltaTime; + this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, collidedObject.transform.position, timeLerped/timeToLerp); + if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !pinned) { + animator.SetBool("pinned", true); + pinned = true; + tambourineHitSound.Play(); + } else { + // print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position); + } + } else if (returnToPlayer) { + Destroy(rb); + animator.SetBool("pinned", false); + pinned = false; - timeLerped += Time.deltaTime; - this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, player.transform.position, timeLerped/0.1f); - if (this.gameObject.transform.position.x == player.transform.position.x && this.gameObject.transform.position.y == player.transform.position.y) { - player.GetComponent().SetHasTambourine(true); - Destroy(this.gameObject); + timeLerped += Time.deltaTime; + this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, player.transform.position, timeLerped/0.1f); + if (this.gameObject.transform.position.x == player.transform.position.x && this.gameObject.transform.position.y == player.transform.position.y) { + player.GetComponent().SetHasTambourine(true); + Destroy(this.gameObject); + } } } } @@ -97,14 +101,22 @@ public class TambourineBehavior : MonoBehaviour { } public void DestroySelf() { - timeLerped = 0.0f; - returnToPlayer = true; + if (player != null) { + timeLerped = 0.0f; + returnToPlayer = true; + } + if (collidedObject != null && collidedObject.tag == "Enemy") { collidedObject.GetComponent().pinned = false; collidedObject.GetComponent().TogglePin(false); } else if (collidedObject != null && collidedObject.tag == "Projectile") { collidedObject.GetComponent().Explode(); } - player.GetComponent().grapplingGun.ReleaseGrapple(); + + if (player == null) { + Destroy(this.gameObject); + } else { + player.GetComponent().grapplingGun.ReleaseGrapple(); + } } }