diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index fe6883192a6af324a146e6c7f00a9a79f560df42..3824b6598655318ae4bef8d0ed3cd23cb42ab09e 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -2949,7 +2949,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 3 + m_IntArgument: 2 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -3443,7 +3443,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 5 + m_IntArgument: 4 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -5279,7 +5279,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 6 + m_IntArgument: 5 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -5493,7 +5493,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 1 + m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -6425,11 +6425,11 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 + m_IntArgument: 6 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 - m_CallState: 0 + m_CallState: 2 --- !u!114 &1029320363 MonoBehaviour: m_ObjectHideFlags: 0 @@ -7105,7 +7105,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 2 + m_IntArgument: 1 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 @@ -8789,7 +8789,7 @@ MonoBehaviour: m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 4 + m_IntArgument: 3 m_FloatArgument: 0 m_StringArgument: m_BoolArgument: 0 diff --git a/Assets/Scripts/Chest.cs b/Assets/Scripts/Chest.cs index 48e04a9d882e3c22154ab71f341e7cc3c626bfab..7cbf8388cab308c85156f2f1ee29930219e1c0de 100644 --- a/Assets/Scripts/Chest.cs +++ b/Assets/Scripts/Chest.cs @@ -5,6 +5,8 @@ using UnityEngine; public class Chest : MonoBehaviour { [SerializeField] GameObject coin; + List<GameObject> pool = new List<GameObject>(); + bool running = false; void OnCollisionEnter2D(Collision2D collisionInfo) { @@ -13,7 +15,7 @@ public class Chest : MonoBehaviour { print("opening chest"); gameObject.GetComponent<Animator>().Play("chest"); - StartCoroutine("EndGame"); + if (!running) StartCoroutine("EndGame"); } else { @@ -22,21 +24,44 @@ public class Chest : MonoBehaviour } IEnumerator EndGame() { - if (running) yield break; running = true; - float time = 0f; while (true) { - GameObject go = Instantiate(coin,transform.position, Quaternion.identity); + GameObject go; + if (pool.Count == 0) + { + go = Instantiate(coin, transform.position, Quaternion.identity); + } + else { + go = pool[pool.Count - 1]; + pool.RemoveAt(pool.Count - 1); + go.transform.position = transform.position; + go.SetActive(true); + } //go.AddComponent<EndCoin>(); go.GetComponent<BoxCollider2D>().isTrigger = true; Rigidbody2D rb = go.GetComponent<Rigidbody2D>(); rb.gravityScale = 1; - Vector2 dir = new Vector2((Random.value * 2 - 1)*100, Random.value * 100); + rb.velocity = Vector2.zero; + Vector2 dir = new Vector2((Random.value * 2 - 1) * 100, Random.value * 100); rb.AddForce(dir); - time += Time.deltaTime; - //yield return new WaitForSeconds(0.1f); yield return null; } } + + IEnumerator ReturnToPool(GameObject go) { + yield return new WaitForSeconds(5); + go.SetActive(false); + pool.Add(go); + } + + private void OnBecameInvisible() + { + StopCoroutine("EndGame"); + } + + private void OnBecameVisible() + { + if (running) StartCoroutine("EndGame"); + } } diff --git a/Assets/Scripts/State.cs b/Assets/Scripts/State.cs index 024cb5ce480de209cfd4f1e002116363026a117d..2ec412aa914af6a38ee6e3aafbc83fa6a165e078 100644 --- a/Assets/Scripts/State.cs +++ b/Assets/Scripts/State.cs @@ -75,7 +75,6 @@ public class State : MonoBehaviour } public void AddMoney() { - print("Adding money"); this.money += this.coin; ui.DisplayCoins(money); } diff --git a/Assets/Scripts/Trash.cs b/Assets/Scripts/Trash.cs index eacb2cd532bd25b3e0399b31103c1e6b40dac3d8..97e89108ff330945c00d17a37aeed8afec428bfe 100644 --- a/Assets/Scripts/Trash.cs +++ b/Assets/Scripts/Trash.cs @@ -39,9 +39,12 @@ public class Trash : MonoBehaviour state.RemoveGas(5); state.SetStatusMessage("Oops! You spilled some gas."); } - foreach (AudioSource a in gameObject.GetComponents<AudioSource>()) + if (collider.tag == "Player") { - a.Play(); + foreach (AudioSource a in gameObject.GetComponents<AudioSource>()) + { + a.Play(); + } } } } diff --git a/Assets/Scripts/UI/Controller.cs b/Assets/Scripts/UI/Controller.cs index 10e52cf6f7b4991dc798df3243c8703b7589fb44..ee5d385408f98491b237a98916c5d6b152ce5494 100644 --- a/Assets/Scripts/UI/Controller.cs +++ b/Assets/Scripts/UI/Controller.cs @@ -167,9 +167,12 @@ public class Controller : MonoBehaviour public void Buy_upgrade(int itemIndex) { Store store = GameObject.FindGameObjectWithTag("Store").GetComponent<Store>(); + Debug.Log("Buying "+ itemIndex); if (store.BuyItem(itemIndex)) { + Debug.Log("Buying1 "+ itemIndex); if (itemIndex == 6) { + Debug.Log("Buying2 "+ itemIndex); ui_Manager.hideUI(); SceneManager.LoadScene("Victory_scene"); return; diff --git a/Assets/Scripts/UI/InGameUI.cs b/Assets/Scripts/UI/InGameUI.cs index 1ff0d8fff5c7c63e66ce49e3d4918171dc9e8195..3eef79d3051b4c497a439f01de8d37592f64824d 100644 --- a/Assets/Scripts/UI/InGameUI.cs +++ b/Assets/Scripts/UI/InGameUI.cs @@ -35,9 +35,7 @@ public class InGameUI : MonoBehaviour public void DisplayStatusMessage(string message) { GameObject obj = GameObject.FindWithTag("StatusMessage"); - print(obj); Text textComponent = obj.GetComponent<Text>(); - print(textComponent); textComponent.text = message; } diff --git a/Cover.png b/Cover.png new file mode 100644 index 0000000000000000000000000000000000000000..821ce22bb02e70412bbe14ef467f1ea41a7b22f1 Binary files /dev/null and b/Cover.png differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index fbb46cb6db708f729e3620766623ccca2e311e3a..4af0698eee70f00704bee5a0b38e31bfa869db17 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -44,8 +44,8 @@ PlayerSettings: m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1920 defaultScreenHeight: 1080 - defaultScreenWidthWeb: 960 - defaultScreenHeightWeb: 600 + defaultScreenWidthWeb: 1024 + defaultScreenHeightWeb: 768 m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 @@ -557,7 +557,7 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLCompressionFormat: 0 + webGLCompressionFormat: 1 webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0