diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 7cfaf4b..deb0f6a 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -461,6 +461,7 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::SharkSpawner sharkPrefab: {fileID: 1185323843861964289, guid: 4bb45ba16a3bbd351a45d39c3f0b62f9, type: 3} gameBoardSpriteRenderer: {fileID: 297740151} + player: {fileID: 1002905792} --- !u!1 &83016091 GameObject: m_ObjectHideFlags: 0 @@ -492,7 +493,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 2111939185} + m_Father: {fileID: 200357627} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &83016093 MonoBehaviour: @@ -882,6 +883,42 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::PlayerGun player: {fileID: 1002905792} +--- !u!1 &200357626 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 200357627} + m_Layer: 0 + m_Name: Managers + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &200357627 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 200357626} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 950242260} + - {fileID: 933658175} + - {fileID: 2071167547} + - {fileID: 683765008} + - {fileID: 83016092} + m_Father: {fileID: 2111939185} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &205614404 GameObject: m_ObjectHideFlags: 0 @@ -2059,7 +2096,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 2111939185} + m_Father: {fileID: 200357627} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &683765009 MonoBehaviour: @@ -2913,7 +2950,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 2111939185} + m_Father: {fileID: 200357627} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!82 &933658176 AudioSource: @@ -3043,7 +3080,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 2111939185} + m_Father: {fileID: 200357627} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &950242261 MonoBehaviour: @@ -6245,7 +6282,7 @@ GameObject: - component: {fileID: 2071167548} m_Layer: 0 m_Name: WorldFiller - m_TagString: Untagged + m_TagString: WorldFiller m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -6263,7 +6300,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 2111939185} + m_Father: {fileID: 200357627} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &2071167548 MonoBehaviour: @@ -6489,13 +6526,9 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 950242260} - {fileID: 485553219} - - {fileID: 933658175} - - {fileID: 2071167547} - {fileID: 449049743} - - {fileID: 683765008} - - {fileID: 83016092} + - {fileID: 200357627} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &2111939186 diff --git a/Assets/Scripts/Game/Balls/BallBase.cs b/Assets/Scripts/Game/Balls/BallBase.cs index a890cda..1c41833 100644 --- a/Assets/Scripts/Game/Balls/BallBase.cs +++ b/Assets/Scripts/Game/Balls/BallBase.cs @@ -54,6 +54,14 @@ public class BallBase : MonoBehaviour { player.GetComponent().OnBarHit(); } + + // Notify other systems if needed. + var worldFiller = GameObject.FindGameObjectWithTag("WorldFiller"); + + if (worldFiller != null) + { + worldFiller.GetComponent().ClearWalls(); + } } } diff --git a/Assets/Scripts/Game/LevelEnder.cs b/Assets/Scripts/Game/LevelEnder.cs index 3b932eb..8bf503b 100644 --- a/Assets/Scripts/Game/LevelEnder.cs +++ b/Assets/Scripts/Game/LevelEnder.cs @@ -107,6 +107,12 @@ public class LevelEnder : MonoBehaviour { addScoreTimer = 0.0f; addScoreToPlayer = AddScore(); + + if (!addScoreToPlayer) + { + tallyShown = false; + StartCoroutine(ProceedToNextLevel()); + } } } } @@ -260,4 +266,47 @@ public class LevelEnder : MonoBehaviour yield return new WaitForSeconds(7.3f - 3.0f - (player.multiplier != 1.0f ? 0.75f : 0.0f)); addScoreToPlayer = true; } + + private IEnumerator ProceedToNextLevel() + { + musicManager.PauseMusic(); + + yield return new WaitForSeconds(1.0f); + + player.OnLevelEnd(); + + // Reenable spawners. + multiplierSpawner.StartSpawning(); + sharkSpawner.StartSpawning(); + cakeSpawner.StartSpawning(); + ballSpawner.StartSpawning(); + + // Reset state. + levelEnded = false; + tallyShown = false; + addScoreToPlayer = false; + scoreTotal = 0; + addScoreTimer = 0.0f; + + // Clear text labels. + timeBonus.text = ""; + totalBonus.text = ""; + isolationBonus.text = ""; + overachieverBonus.text = ""; + isolationCount.text = ""; + overachieverPercent.text = ""; + multiplierBonus.text = ""; + overarchieverPercentLabel.enabled = false; + isolationCountSingleLabel.enabled = false; + isolationCountPluralLabel.enabled = false; + + // Hide score tally. + levelEndTally.enabled = false; + levelEndTallyBackground.enabled = false; + + // TODO: Reset balls. + + // Restart music. + musicManager.ResumeMusic(); + } } diff --git a/Assets/Scripts/Game/MusicManager.cs b/Assets/Scripts/Game/MusicManager.cs index e758638..08dea5f 100644 --- a/Assets/Scripts/Game/MusicManager.cs +++ b/Assets/Scripts/Game/MusicManager.cs @@ -65,12 +65,22 @@ public class MusicManager : MonoBehaviour { if (needsReset) { + if (audioSource.isPlaying) + { + audioSource.Stop(); + } + + audioSource.clip = null; clipsQueue.Clear(); ResetQueue(); needsReset = false; } - audioSource.UnPause(); + if (audioSource.clip != null && !audioSource.isPlaying) + { + audioSource.UnPause(); + } + isPaused = false; } diff --git a/Assets/Scripts/Game/Spawners/SharkSpawner.cs b/Assets/Scripts/Game/Spawners/SharkSpawner.cs index cda1901..ea38731 100644 --- a/Assets/Scripts/Game/Spawners/SharkSpawner.cs +++ b/Assets/Scripts/Game/Spawners/SharkSpawner.cs @@ -6,6 +6,8 @@ public class SharkSpawner : Spawner public SpriteRenderer gameBoardSpriteRenderer; + public Player player; + private Bounds gameBoardBounds; private float spawnTimer = 0f; @@ -28,7 +30,7 @@ public class SharkSpawner : Spawner { spawnTimer += Time.fixedDeltaTime; - if (spawnTimer >= 1f && isActive && isSpawning) + if (spawnTimer >= 1f && isActive && isSpawning && player.level >= 10) { spawnTimer = 0f; if (Random.value < spawnProbability) @@ -36,7 +38,7 @@ public class SharkSpawner : Spawner GameObject shark = Instantiate(sharkPrefab, spawnPosition, Quaternion.identity); Shark sharkScript = shark.GetComponent(); sharkScript.gameBoardSpriteRenderer = gameBoardSpriteRenderer; - sharkScript.player = FindAnyObjectByType(); + sharkScript.player = player; isActive = false; } } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index ba43da4..869a1ad 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -17,6 +17,7 @@ TagManager: - Multiplier - Yummy - Cake + - WorldFiller layers: - Default - TransparentFX