Added basic start screen

This commit is contained in:
Trianta
2024-02-08 19:15:28 -06:00
parent b88079bb61
commit 8ebf5e222b
7 changed files with 823 additions and 3 deletions
+2
View File
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Apple : MonoBehaviour
{
@@ -17,6 +18,7 @@ public class Apple : MonoBehaviour
{
if (transform.position.y < bottomY) {
Destroy(this.gameObject);
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
// Get a reference to the ApplePicker component of Main Camera
ApplePicker apScript = Camera.main.GetComponent<ApplePicker>();
// Call the public AppleDestroyed() method of apScript
+2
View File
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ApplePicker : MonoBehaviour
{
@@ -27,6 +28,7 @@ public class ApplePicker : MonoBehaviour
basketList.Add(tBasketGO);
}
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
GameObject roundGO = GameObject.Find("RoundCounter");
roundGT = roundGO.GetComponent<Text>();
roundGT.text = "Round 1";
+5
View File
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Basket : MonoBehaviour
{
@@ -10,6 +11,7 @@ public class Basket : MonoBehaviour
// Start is called before the first frame update
void Start()
{
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
// Find a reference to the ScoreCounter GameObject
GameObject scoreGO = GameObject.Find("ScoreCounter");
// Get the Text Component of that GameObject
@@ -21,6 +23,7 @@ public class Basket : MonoBehaviour
// Update is called once per frame
void Update()
{
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
// Get the current screen position of the mouse from Input
Vector3 mousePos2D = Input.mousePosition;
// The Camera's z position sets how far to push the mouse into 3D
@@ -39,6 +42,7 @@ public class Basket : MonoBehaviour
switch (collidedWith.tag) {
case "Apple":
Destroy(collidedWith);
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
// Parse the text of the scoreGT into an int
int score = int.Parse(scoreGT.text);
// Add points for catching the apple
@@ -50,6 +54,7 @@ public class Basket : MonoBehaviour
break;
case "RottenApple":
Destroy(collidedWith);
if (SceneManager.GetActiveScene().name == "_Scene_2") { return; }
ApplePicker apScript = Camera.main.GetComponent<ApplePicker>();
apScript.RottenAppleDestroyed();
break;
+3 -2
View File
@@ -11,13 +11,14 @@ public class Reset : MonoBehaviour
void Start()
{
m_ResetButton.onClick.AddListener(() => ButtonClicked());
this.gameObject.SetActive(false);
if (SceneManager.GetActiveScene().name == "_Scene_0") { this.gameObject.SetActive(false); }
else { this.gameObject.SetActive(true); }
}
void ButtonClicked() {
SceneManager.LoadScene("_Scene_0");
Time.timeScale = 1;
this.gameObject.SetActive(false);
SceneManager.LoadScene("_Scene_0");
}
// Update is called once per frame