From 5096e4ab35dfd91c5ce7272af2599c845f0ca19a Mon Sep 17 00:00:00 2001 From: Kaj Forney Date: Mon, 1 Nov 2021 01:54:04 -0600 Subject: [PATCH] Start game only when player finishes falling. --- Assets/Scenes/level1.unity | 2 +- Assets/Scripts/startTrigger.cs | 24 ++++++++++++++++++++++++ Assets/Scripts/startTrigger.cs.meta | 11 +++++++++++ Assets/Scripts/tetrominoSpawnManager.cs | 6 ------ 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 Assets/Scripts/startTrigger.cs create mode 100644 Assets/Scripts/startTrigger.cs.meta diff --git a/Assets/Scenes/level1.unity b/Assets/Scenes/level1.unity index b7d6d3a..cd967fb 100644 --- a/Assets/Scenes/level1.unity +++ b/Assets/Scenes/level1.unity @@ -1726,7 +1726,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1149029299} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -41, y: 2.388, z: 0} + m_LocalPosition: {x: -41, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scripts/startTrigger.cs b/Assets/Scripts/startTrigger.cs new file mode 100644 index 0000000..db0f535 --- /dev/null +++ b/Assets/Scripts/startTrigger.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class startTrigger : MonoBehaviour +{ + private tetrominoSpawnManager TetrominoSpawnManager; + + // Start is called before the first frame update + void Start() + { + TetrominoSpawnManager = FindObjectOfType(); + } + + private void OnTriggerEnter2D(Collider2D other) + { + if (other.gameObject.tag == "Player") + { + TetrominoSpawnManager.spawnTetromino(); + gameObject.SetActive(false); + } + } +} diff --git a/Assets/Scripts/startTrigger.cs.meta b/Assets/Scripts/startTrigger.cs.meta new file mode 100644 index 0000000..3b0039f --- /dev/null +++ b/Assets/Scripts/startTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 07be5b25cb965ac52b42bcc180bd0f59 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/tetrominoSpawnManager.cs b/Assets/Scripts/tetrominoSpawnManager.cs index 2cf0a6c..1e69997 100644 --- a/Assets/Scripts/tetrominoSpawnManager.cs +++ b/Assets/Scripts/tetrominoSpawnManager.cs @@ -15,12 +15,6 @@ public class tetrominoSpawnManager : MonoBehaviour private int nextTetromino = 0; private GameObject nextTetrominoObject; - // Start is called before the first frame update - void Start() - { - spawnTetromino(); - } - public void spawnTetromino() { nextTetromino = Random.Range(1, 7);